Skip to content

Instantly share code, notes, and snippets.

@jkwok91
Last active August 29, 2015 14:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jkwok91/b17369442359afd8850c to your computer and use it in GitHub Desktop.
Save jkwok91/b17369442359afd8850c to your computer and use it in GitHub Desktop.
/*
jan 27, 2015
*/
void setup() {
size(243,243);
background(255);
}
void draw() {
stroke(0);
pushMatrix();
translate(0, 2*height/3);
iterate(width, 5); // looks bad after this
popMatrix();
}
void iterate(int len, int iteration) {
if (iteration == 1) {
line(0, 0, len, 0);
} else {
int oneThird = (int)(len/3);
int twoThirds = 2*oneThird;
PVector start_p = new PVector(oneThird, 0);
PVector start_2p = new PVector(oneThird, -1*oneThird);
PVector start_3p = new PVector(twoThirds, -1*oneThird);
PVector start_4p = new PVector(twoThirds, 0);
iterate(oneThird, iteration-1);
pushMatrix();
translate(start_p.x, start_p.y);
rotate(-PI/2);
iterate(oneThird, iteration-1);
popMatrix();
pushMatrix();
translate(start_2p.x, start_2p.y);
iterate(oneThird, iteration-1);
popMatrix();
pushMatrix();
translate(start_3p.x, start_3p.y);
rotate(PI/2);
iterate(oneThird, iteration-1);
popMatrix();
pushMatrix();
translate(start_4p.x, start_4p.y);
iterate(oneThird, iteration-1);
popMatrix();
}
}
@jkwok91
Copy link
Author

jkwok91 commented Jan 28, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment