Created
September 2, 2013 19:28
-
-
Save reuk/6416455 to your computer and use it in GitHub Desktop.
folding prism walk thing
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
void setup() { | |
size(500, 500, P3D); | |
frameRate(25); | |
blendMode(ADD); | |
ortho(); | |
} | |
void draw() { | |
background(0); | |
noFill(); | |
stroke(0, 255, 255, 127); | |
strokeWeight(5); | |
translate(width / 2, height * 0.7); | |
rotateX(-PI / 6); | |
rotateY(PI / 3); | |
float rad = 100; | |
PVector maxy = new PVector(0, 0); | |
float ang = (-frameCount * 2 * PI * 0.05) / 3; | |
PVector[] v = new PVector[3]; | |
for (int i = 0; i != v.length; ++i) { | |
float angle = ((2 * PI * i) / 3) + ang; | |
float x = sin(angle) * rad; | |
float y = cos(angle) * rad; | |
maxy = y > maxy.y ? new PVector(x, y) : maxy; | |
v[i] = new PVector(x, y); | |
} | |
translate(0, -maxy.y); | |
beginShape(TRIANGLES); | |
for (int i = 0; i != v.length; ++i) vertex(v[i].x, v[i].y, rad); | |
for (int i = 0; i != v.length; ++i) vertex(v[i].x, v[i].y, -rad); | |
endShape(); | |
for(int i = 0; i != v.length; ++i) line(v[i].x, v[i].y, rad, v[i].x, v[i].y, -rad); | |
int segs = 10; | |
float extra = 2 * cos(PI / 6) * rad; | |
for (int i = 1; i != segs; ++i) { | |
line(maxy.x + extra * i, maxy.y, rad, maxy.x + extra * i, maxy.y, -rad); | |
} | |
line(maxy.x, maxy.y, rad, maxy.x + segs * extra, maxy.y, rad); | |
line(maxy.x, maxy.y, -rad, maxy.x + segs * extra, maxy.y, -rad); | |
saveFrame("###-fold.png"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment