Watch Fun Programming [video 32]
Simplify this program using a function:
float r;
void setup()
{
size(400,400);
background(255);
noStroke();
fill(0);
rectMode(CENTER);
r = 0;
}
void draw()
{
background(255);
fill(#FF850A);
translate(100,100);
rotate(r);
rect(0,0,60,60);
resetMatrix();
fill(#00FFFF);
translate(100,200);
rotate(-1*r);
rect(0,0,60,60);
resetMatrix();
fill(#FF00FF);
translate(100,300);
rotate(r);
rect(0,0,60,60);
resetMatrix();
fill(#FFFF00);
translate(200,100);
rotate(-1*r);
rect(0,0,60,60);
resetMatrix();
fill(#00FF00);
translate(200,200);
rotate(r);
rect(0,0,60,60);
resetMatrix();
fill(#FF0000);
translate(200,300);
rotate(-1*r);
rect(0,0,60,60);
resetMatrix();
fill(#0000FF);
translate(300,100);
rotate(r);
rect(0,0,60,60);
resetMatrix();
fill(#FF78FF);
translate(300,200);
rotate(-1*r);
rect(0,0,60,60);
resetMatrix();
fill(#78FF78);
translate(300,300);
rotate(r);
rect(0,0,60,60);
r = r + 0.05;
}
Show a mentor, mark the board & claim a prize.