xxxxxxxxxx
28
function setup() {
createCanvas(600, 120);
}
function draw() {
background(220);
var x= 100;//initialize the variable to 0 so that the x position of the 1st shape will be 20
while(x<width){ //check for a condition (keep this loop going as long as this is true)
rainbowCircle(x, 60)
x=x+100//increment the variable (every time you run through the loop, add 100 to x)
}
}
function rainbowCircle(x, y){
fill(255,0,0);//add a red fill
ellipse(x,y,40,40); //draw an ellipse at the x-location of the variable x
fill(0,255,0);//add a green fill
ellipse(x,y,30,30);//draw another ellipse at the same x location but smaller
fill(0,0,255);//add a blue fill
ellipse(x,y,20,20)//draw another ellipse at the same x location but smaller
fill(255,0,255);//add a purple fill
ellipse(x,y,10,10)//draw another ellipse at the same x location but smaller
}