A1.
//the idea basically is using “for” for loops.
//calculate the radius of circle which can make it easier to fit the screen size
//draw both circles left and right at once (same y value)
//change x value and y value, loop 10 times in total
int xPos=25;
int yPos=25;
void setup(){
background(255);
size(500, 500);
fill(255, 0, 0);
stroke(0, 0, 255);
strokeWeight(3);
smooth();
}
void draw(){
for (int i = 0; i < 10; i++)
{
ellipse(xPos, yPos, 50, 50);
ellipse(500 – xPos, yPos, 50, 50);
xPos += 50;
yPos += 50;
}
}
A2.
//draw the lines first with give out the x and y value
//then draw four large squares and draw four little squares last
//basic idea is the last drawing will on the top layer
//notice: fill colour part should write before drawing shapes
int xPos=125;
int yPos=125;
void setup(){
background(0);
size(500, 500);
smooth();
strokeWeight(2);
stroke(230,0,230);
line(0,0,500,500);
line(500,0,0,500);
}
void draw(){
fill(100);
rect(xPos, yPos, 75, 75);
rect(500-xPos-75, yPos, 75, 75);
rect(xPos, 500-yPos-75, 75, 75);
rect(500-xPos-75, 500-yPos-75, 75, 75);
fill(180);
rect(xPos+50, yPos+50, 25, 25);
rect(500-xPos-75, yPos+50, 25, 25);
rect(xPos+50, 500-yPos-75, 25, 25);
rect(500-xPos-75, 500-yPos-75, 25, 25);
}
A3.
//in this drawing, it divides into 5 parts
//calculate the relative position between lines and circles
//draw first group of lines, using “for” for loop
//draw first group of circles, using “for” for loop
//draw second group of lines
//draw second group of circles
//draw the quadrilateral by giving the x y value of four angles
int xPos;
int yPos;
int yLine;
void setup(){
background(0, 0, 255);
size(500, 500);
stroke(255, 0, 0);
strokeWeight(1);
smooth();
fill(0, 255, 0);
}
void draw(){
for (int yLine=0; yLine<=100; yLine+=4){
line(0, yLine, width, yLine);
}
for (int xPos=0; xPos<=width; xPos+=50){
ellipse(xPos, 125, 50, 50);
}
for (int yLine=150; yLine<=250; yLine+=4){
line(0, yLine, width, yLine);
}
quad(100, 250+50, width-50, 250, 300, height-100, 50, height-100);
for (int xPos=0; xPos<=width; xPos+=50){
ellipse(xPos, height-50, 50, 50);
}
}