Initial commit.
void setup() {
size( 510, 510 );
smooth();
background( 200 );
}
void draw() {
if ( mousePressed ) {
rects(1);
}
else {
rects(0);
}
}
void rects( int rand ) {
int cwidth = 50;
int cheight = 50;
int curwidth = cwidth-(cwidth/5);
int curheight = cheight-(cwidth/5);
noStroke();
for ( int y = cheight/5; y <= height; y += cheight ) {
for ( int x = cwidth/5; x <= width; x += cwidth ) {
if ( rand == 1 ) {
fill( random(180,220) );
}
else {
fill( 210 );
}
if ( (mouseX > x) && (mouseX < x + curwidth) &&
(mouseY > y) && (mouseY < y + curheight) ) {
// mouse is inside rectangle
}
else {
rect( x, y, curwidth, curheight );
}
}
}
}