Assignment 3.1
Post date: Jun 22, 2010 4:19:45 AM
code to make this image:
void setup() {
size(400, 400); // sets size to 400 x 400 pixels
background(0); // sets background color to black
}
void draw(){
stroke(0); // sets stroke color to black
fill(225, 225, 0); // sets fill color to bright yellow
ellipse(width/2, height/2, 400, 400); // draws ellipse centered with diameter 400
fill(225, 0, 0); // sets fill color to bright red
rect(25, 25, 350, 350); // draws rectangle from corner (25, 25) with width/height of 350
fill(180, 180, 0); // sets fill color to a darker yellow
ellipse(width/2, height/2, 350, 350); // draws ellipse centered with diameter 350
fill(168.75, 0, 0); // sets fill color to a darker red
rect(50, 50, 300, 300); // draws rectangle from corner (50, 50) with width/height of 300
fill(135, 135, 0); // sets fill color to a medium yellow
ellipse(width/2, height/2, 300, 300); // draws ellipse centered with diameter 300
fill(112.5, 0, 0); // sets fill color to a medium red
rect(75, 75, 250, 250); // draws rectangle from corner (75, 75) with width/height of 250
fill(90, 90, 0); // sets fill color to dark yellow
ellipse(width/2, height/2, 250, 250); // draws ellipse centered with diameter 250
fill(56.25, 0, 0); // sets fill color to dark red
rect(100, 100, 200, 200); // draws rectangle with corner at (100, 100) and width/height of 200
fill(45, 45, 0); // sets fill color to very dark yellow
ellipse(width/2, height/2, 200, 200); // draws ellipse centered with diameter 200
fill(0); // sets fill color to black
rect(125, 125, 150, 150); // draws rectangle with corner at (125, 125) and width/height of 150
stroke(0, 225, 0); // sets stroke color to bright green
line(200, 125, 125, 200); // draws line from (200, 125) to (125, 200)
line(200, 125, 275, 200); // draws line from (200, 125) to (275, 200)
line(125, 200, 200, 275); // draws line from (125, 200) to (200, 175)
line(275, 200, 200, 275); // draws line from (275, 200) to (200, 275)
fill(0, 0, 0, 0); // sets fill to transparent black
rect(145, 145, 110, 110); // draws rectangle with corner at (145, 145) and width/height 110
stroke(0); // sets stroke color to black
fill(0, 0, 25); // sets fill color to a very dark blue
ellipse(width/2, height/2, 100, 100); // draws ellipse with center at middle and diameter of 100
fill(0, 0, 75); // sets fill color to dark blue
ellipse(width/2, height/2, 80, 80); // draws ellipse centered with diameter 80
fill(0, 0, 125); // sets fill color to blue
ellipse(width/2, height/2, 60, 60); // draws ellipse centered with diameter 60
fill(0, 0, 175); // sets fill color to bright blue
ellipse(width/2, height/2, 40, 40); // draws ellipse centered with diameter 40
fill(0, 0, 225); // sets fill color to a very bright blue
ellipse(width/2, height/2, 20, 20); // draws ellipse centered with diameter 20
stroke(0, 0, 125); // sets stroke color to bright blue
line(25, 25, 375, 375); // draws line from (0, 0) to (400, 400)
line(375, 25, 25, 375); // draws line from (400, 0) to (0, 400)
line(200, 0, 200, 400); // draws line from (200, 0) to (200, 400)
line(0, 200, 400, 200); // draws line from (0, 200) to (400, 200)
}
Problems:
At first I had trouble figuring out how to get different parts on different levels, but after a little playing with it I figured out I just had to put the code in the order I wanted it to appear (bottom first with each level going up in order).
The green diamond in the middle was tricky. I had to draw it line by line, and it took a few tries to get the coordinates right.
Using (width/2, height/2, x, y) helped a lot with centering everything.
I used a calculator to figure out which numbers to use in order to get an even color fade throughout the pattern.
No animation/interaction. I could not figure out how to draw shapes and have them stay there, as in paint. I assume it would use the mousePressed ( ) function, but when I used the following, the line would not stay after the mouse button was released. Any ideas?
void mousePressed() {
stroke(0);
line(width/2, height/2, mouseX, mouseY);
}