rect flip
@author
int X_NUM = 5;
int Y_NUM = 5;
void setup(){
size(640, 640);
rectMode(CENTER);
noStroke();
fill(100);
}
void draw(){
background(230);
translate(width / 2, height / 2);
for(int y = 0; y < Y_NUM; y++){
for(int x = 0; x < X_NUM; x++){
float angle = PI * float(x + y * X_NUM) / (X_NUM * Y_NUM);
float v = pow(abs(sin(angle - frameCount * 0.03)), 12);
pushMatrix();
translate((x - (X_NUM - 1) / 2.0) * 100, (y - (Y_NUM - 1) / 2.0) * 100);
drawRect(v);
popMatrix();
}
}
}
void drawRect(float v){
float posY = map(v, 0, 1, 0, -20);
float sizeX = map(sin(v * PI), 0, 1, 40, 0);
fill(lerpColor(color(255, 105, 180), color(105, 240, 255), v));
rect(0, posY, sizeX, 40);
}