-
-
Save jkwok91/eb0f317679765b13d34c to your computer and use it in GitHub Desktop.
sorry fo real. this is some jank shit.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
serpinski arrow head | |
january 28th, 2015 | |
*/ | |
// doin what i do best son | |
void setup() { | |
size(512,512); | |
background(255); | |
stroke(0); | |
} | |
void draw() { | |
pushMatrix(); | |
translate(0,height-5); | |
iterate(width, 7, 7, 1); // ewwwww | |
popMatrix(); | |
} | |
void iterate(int len, int starting, int i, int segment) { | |
if (i == 0) { | |
line(0,0,len,0); | |
} else { | |
int flgg = (starting%2==0) ? 1 : -1; // this is fugly as shit son | |
int i_flag = (i%2 == 0) ? -1 : 1; | |
int s_flag = (segment%2==0) ? -1 : 1; | |
int flag = flgg*i_flag*s_flag; | |
// starting points | |
PVector p1 = new PVector(0,0); | |
//ellipse(p1.x,p1.y,5,5); | |
PVector p2 = new PVector(len/4,flag*(sqrt(3)*len/4)); | |
//ellipse(p2.x,p2.y,5,5); | |
PVector p3 = new PVector(3*len/4,flag*(sqrt(3)*len/4)); | |
//ellipse(p3.x,p3.y,5,5); | |
pushMatrix(); | |
translate(p1.x,p1.y); | |
rotate(flag*PI/3); | |
iterate(len/2,starting,i-1,segment*3); | |
popMatrix(); | |
pushMatrix(); | |
translate(p2.x,p2.y); | |
iterate(len/2,starting,i-1,segment*3+1); | |
popMatrix(); | |
pushMatrix(); | |
translate(p3.x,p3.y); | |
rotate(-1*flag*PI/3); | |
iterate(len/2,starting,i-1,segment*3+2); | |
popMatrix(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment