Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
void setup() {
size(500, 500);
rectMode(CENTER);
noStroke();
}
float x, y, t, tt;
color c1 = color(32), c2 = color(240, 0, 0), cb = color(245);
int N = 10;
float spm = 60, sp, l1 = spm/2, l2 = spm/4;
void draw() {
t = frameCount/42.0;
tt = 3*t*t - 2*t*t*t;
sp = spm*pow(2,.5*tt);
background(cb);
pushMatrix();
translate(width/2, height/2);
rotate(QUARTER_PI*t);
for (int i=-N; i<=N; i++) {
for (int j=-N; j<=N; j++) {
x = i*sp;
y = j*sp;
pushMatrix();
translate(x, y);
rotate(QUARTER_PI+QUARTER_PI*t);
fill(c1);
rect(0, 0, l1, l1);
popMatrix();
x = (i+.5)*sp;
y = (j+.5)*sp;
pushMatrix();
translate(x, y);
rotate(QUARTER_PI-QUARTER_PI*t);
fill(lerpColor(c2,c1,t));
rect(0, 0, lerp(l2,l1,t), lerp(l2,l1,t));
popMatrix();
x = (i+.5)*sp;
y = j*sp;
pushMatrix();
translate(x, y);
rotate(-2*QUARTER_PI*t);
fill(c2);
rect(0, 0, l2*tt, l2*tt);
popMatrix();
x = i*sp;
y = (j+.5)*sp;
pushMatrix();
translate(x, y);
rotate(QUARTER_PI+QUARTER_PI*t);
fill(c2);
rect(0, 0, l2*tt, l2*tt);
popMatrix();
}
}
popMatrix();
if(frameCount == 42)
exit();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment