-
-
Save davidblitz/5e99606d50d9d53f1ec4b48fbe5d175f to your computer and use it in GitHub Desktop.
// 10PRINT tunnel-rosette Processing 3 code, thanks to @shiffman and @jmutterer!
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
// 10PRINT rosette Processing 3 code | |
// thanks to @shiffman and @jmutterer! | |
static float r=30; | |
static float s=10; | |
int i, j; | |
static int maxI = 60; | |
static int maxJ = 25; | |
float directions[][] = new float[maxJ][maxI]; | |
void setup() { | |
size(650, 650); | |
frameRate(10); | |
i = 0; | |
j = 0; | |
} | |
void draw() { | |
background(72, 58, 170); | |
translate (width/2, height/2); | |
scale (1, -1); | |
strokeWeight(1.5); | |
stroke (134, 122, 222); | |
/* | |
if(j < maxJ-1) i++; | |
if (i == maxI){ | |
++j; | |
i = 0; | |
println(j); | |
//j == 13 hits borders | |
} | |
*/ | |
j++; | |
for(int i=0; i<maxI; ++i) { | |
stroke (134, 122, 222, 255-15*j); | |
float direction = (random(1)>0.5)?-1:1; | |
directions[j][i] = direction; | |
} | |
for(int y = 0; y < j; ++y) { | |
for(int x = 0; x < maxI && !(y == j && x > i); ++x) { | |
stroke (134, 122, 222, 50+8*y); | |
float a = (x-directions[y][x]/2)*2*PI/60; | |
float b = (x+directions[y][x]/2)*2*PI/60; | |
line ((r+(maxJ - y)*s)*sin(a), (r+(maxJ - y)*s)*cos(a), | |
(r+(maxJ - (y+1))*s)*sin(b), (r+(maxJ - (y+1))*s)*cos(b)); | |
} | |
} | |
if(j == maxJ - 1) { | |
for(int y = 0; y < maxJ - 1; ++y) { | |
for(int x = 0; x < maxI; ++x) { | |
directions[y][x] = directions[y+1][x]; | |
} | |
} | |
j--; | |
i = 0; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment