flip-flop
@author
int CIRCLE_NUM = 10;
float CIRCLE_SIZE = 50;
color bg, c1, c2;
void setup(){
size(500, 500);
mousePressed();
}
void mousePressed(){
c1 = color(random(255), random(255), random(255));
c2 = color(255 - red(c1), 255 - green(c1), 255 - blue(c1));
bg = color(random(255), random(255), random(255));
}
void draw(){
background(bg);
noStroke();
float sinVal = sin(frameCount * 0.25);
for(int x = 0; x < CIRCLE_NUM; x++){
for(int y = 0; y < CIRCLE_NUM; y++){
if(sin < 0){
if((x + y) % 2 == 0){
fill(c1);
} else {
fill(c2);
}
} else {
if((x + y) % 2 == 0){
fill(c2);
} else {
fill(c1);
}
}
ellipse((x + 0.5) * CIRCLE_SIZE, (y + 0.5) * CIRCLE_SIZE, abs(sinVal * CIRCLE_SIZE), CIRCLE_SIZE);
}
}
}