1.
size(500,500);
fill(250, 0, 0);
rect(230, 230, 50, 50);
2.
size(500,500);
stroke(250,0,0);
line(230, 230, 100, 160);
strokeCap(SQUARE);
stroke(255,255,255);
strokeWeight(2);
line(230, 225, 100, 155);
strokeCap(ROUND);
strokeWeight(4);
stroke(0,0,0);
line(230, 215, 100, 145);
3. The visiable difference is the edges between the two ellipses, one is smooth (smooth()), and when the noSmooth() is activated then the outline of the elipse is jagged. Smooth() function is activated my default, you need to specificly call noSmooth().
4. After the code is finished running, X will equal 5 and Y will equal 10.
5. The code tells where each vertex is going to be with the parameters of a X and Y axis The beginShape starts the shape and endShape(Close) connects them all together.
6. The float num will equal a random number anywhere from 0-20.
7. The code looks to see if num is less than 10, If it is less than 10 then it will fill a triangle of (20, 20, 20, 100, 120, 100) with the color of (0, 255, 0); but if the number is 10 or greater then the code will create an ellipse with (width/2, height/2, 50,50) with a fill of (0,0,255).
B. If you would like to draw a red triangle instead of a green triangle, you would change the second parameter of fill to 0, and the first parameter to 255.
8. To create 100 ellipses on the screen you would change the for loop to check for i < = 100.
B To make each ellipse a random color you would just need to create three variables with a random number up to 255 inside the for loop and add a fill with the three variables in the parameters.
CODE:
size(400,400);
float x;
float y;
float z;
float q;
float a;
for (int i = 0; i <= 100; i = i+1) {
x = random(360);
y = random(360);
z = random(255);
q = random(255);
a = random(255);
fill(z,q,a);
ellipse(x+20, y+20, 20,20);
}