Created
December 3, 2012 00:52
-
-
Save yyolk/4191910 to your computer and use it in GitHub Desktop.
stareiii
This file contains hidden or 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
// Based on Sketch4 - | |
// "Stare Long - II" | |
// http://bit.ly/fbMlxO | |
NP foo[]; | |
int iterations = 6; | |
void setup(){ | |
size(600,600); | |
foo = new NP[9]; | |
foo[0] = new NP(1, 2, #FF5555); | |
foo[1] = new NP(0.2, 1.2, #FFF7F7); | |
foo[2] = new NP(0.4, .9, #C7F464); | |
foo[3] = new NP(0.1, 4, #FF6B6B); | |
foo[4] = new NP(1, 4, #C44D58); | |
foo[5] = new NP(7, 9, #4ECDC4); | |
foo[6] = new NP(1, 2, #556270); | |
foo[7] = new NP(3, 5, #E8614A); | |
foo[8] = new NP(8, 13, #FF8263); | |
frameRate(30); | |
background(0); | |
} | |
void draw(){ | |
fill(0, 1); | |
rect(0,0,width,height); | |
translate(width/2,height/2); | |
for (int j = 0; j<iterations; j++){ | |
for (int i = 0; i<foo.length; i++){ | |
foo[i].draw(); | |
} | |
rotate(PI/(floor(random(10)))); | |
} | |
} | |
class NP{ | |
float s1; | |
float s2; | |
float v1; | |
float x, y; | |
color c; | |
NP(float s1, float s2, color c){ | |
this.s1 = s1; | |
this.s2 = s2; | |
this.c = c; | |
this.v1 = floor(random(255)); | |
} | |
void generate(){ | |
s1 += random(1)*.01; | |
s2 += random(1)*.01; | |
x = noise(s1) * (width/2); | |
y = noise(s2) * (height/2); | |
} | |
void draw(){ | |
generate(); | |
rotate(HALF_PI*.5); | |
fill(c); | |
stroke(c); | |
switch(floor(random(3))){ | |
case 0: | |
beginShape(QUAD_STRIP); | |
break; | |
case 1: | |
beginShape(TRIANGLES); | |
break; | |
case 2: | |
beginShape(LINES); | |
break; | |
} | |
vertex(x,y); | |
vertex(y,x); | |
vertex(-y,x); | |
vertex(-x,y); | |
endShape(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
http://fundamentals.yolk.cc/post/3952116643/stare-iii