Skip to content

Instantly share code, notes, and snippets.

@LadyScream
Created October 2, 2018 03:29
Show Gist options
  • Save LadyScream/4c84a695f98749ae7fc1565819afe7de to your computer and use it in GitHub Desktop.
Save LadyScream/4c84a695f98749ae7fc1565819afe7de to your computer and use it in GitHub Desktop.
boolean recording = false;
int frame = 1;
float time = -PI/2;
float c = 10;
void setup(){
size(720, 720, P2D);
}
void draw(){
if (time < TWO_PI-PI/2 || !recording){
background(200);
fill(28);
noStroke();
rectMode(CENTER);
for (int i = (int)(-width/c); i <= width; i += (int)(width/c)){
for (int j = (int)(-height/c); j <= height; j += (int)(height/c)){
pushMatrix();
if (sin(time) < 0){
translate(map(sin(time), -1, 1, i, i+width/c),j);
rotate(map(sin(time), -1, 1, 0, PI));
} else {
translate(i-width/c/2, map(sin(time), -1, 1, j, j+height/c)-height/c/2);
rotate(map(sin(time), -1, 1, 0, PI));
}
float s = sqrt(sq(width/c)/2);
rect(0, 0, s, s);
popMatrix();
}
}
time += 0.01;
if (recording) save(frame+".gif");
frame++;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment