Skip to content

Instantly share code, notes, and snippets.

@jordanorelli
Created April 25, 2014 19:09
Show Gist options
  • Save jordanorelli/11299866 to your computer and use it in GitHub Desktop.
Save jordanorelli/11299866 to your computer and use it in GitHub Desktop.
int strokeFrames = 100;
int strokeCount = 0;
int saveFrame = 1;
boolean up = true;
void setup() {
size(500, 500);
}
void draw() {
background(255);
int x = 65;
int y = -65;
noFill();
stroke(0);
strokeWeight(20);
if (up) {
rect(20+x, 230+y, 250, 250);
line(270+x, 230+y, 370+x, 130+y);
redline();
rect(120+x, 130+y, 250, 250);
line(20+x, 223+y, 112+x, 130+y);
line(20+x, 480+y, 120+x, 380+y);
line(276+x, 480+y, 370+x, 386+y);
} else {
rect(120+x, 130+y, 250, 250);
line(20+x, 223+y, 112+x, 130+y);
line(20+x, 480+y, 120+x, 380+y);
line(276+x, 480+y, 370+x, 386+y);
redline();
rect(20+x, 230+y, 250, 250);
line(270+x, 230+y, 370+x, 130+y);
}
if (strokeCount == 1 || strokeCount == 2) {
String fname = nf(saveFrame, 3) + ".png";
save(fname);
saveFrame++;
println(fname);
}
}
void redline() {
pushMatrix();
translate(width*0.5, height*0.5);
rotate(PI*0.25);
noStroke();
float n = norm(frameCount % strokeFrames, 0, strokeFrames);
float t = (1.0 - cos(n*TWO_PI)) * 0.5;
if (frameCount % strokeFrames == 0) {
up = !up;
strokeCount++;
}
fill(255, 0, 0);
rectMode(RADIUS);
rect(0, 0, 25+140*t, 25+140*t);
popMatrix();
noFill();
stroke(0);
strokeWeight(20);
rectMode(CORNER);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment