Skip to content

Instantly share code, notes, and snippets.

@yyolk
Created December 3, 2012 00:54
Show Gist options
  • Save yyolk/4191925 to your computer and use it in GitHub Desktop.
Save yyolk/4191925 to your computer and use it in GitHub Desktop.
Stare 3 ½
// Based on
// Sketch 4 - "Stare Long II"
// http://bit.ly/fbMlxO
NP foo[];
int iterations = 6;
int posy, posx;
posy = posx = 0;
void setup(){
size(600,600);
foo = new NP[9];
foo[0] = new NP(1, 2, #FFE6D1);
foo[1] = new NP(0.2, 1.2, #E1230F);
foo[2] = new NP(0.4, .9, #1C1B1B);
foo[3] = new NP(0.1, 4, #E1230F);
foo[4] = new NP(1, 4, #FFE6D1);
foo[5] = new NP(7, 9, #E1230F);
foo[6] = new NP(1, 2, #324259);
foo[7] = new NP(3, 5, #1C1B1B);
foo[8] = new NP(8, 13, #1C1B1B);
frameRate(30);
background(0);
}
void draw(){
if(mousePressed){ fill(255);}
else{ fill(0,75);}
rect(0,0, width, height);
translate(width/2+75, height/2+75);
for (int j = 0; j<iterations; j++){
for (int i = 0; i<foo.length; i++){
translate(j*(width/100), i*(width/75));
foo[i].draw();
}
}
}
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)*.00932;
s2 += random(1)*.00741;
x = noise(s1) * (width*1.3);
y = noise(s2) * (height*.5);
y = y%(height/2);
x = x%(width/2);
}
void draw(){
generate();
rotate(HALF_PI*.35);
// fill(c,50);
// stroke(c,150);
strokeWeight(13);
// noStroke();
if(mousePressed){noStroke();}else{stroke(c,150);}
beginShape(LINES);
vertex(x,y);
vertex(y,x);
vertex(-y,x);
// vertex(-x,y);
//
vertex(y,-x);
vertex(x, -y);
//
endShape();
if (mousePressed){ fill(0);}else{fill(255);}
noStroke();
ellipse(x,y, 5,5);
ellipse(y,x, 5,5);
ellipse(y,-x, 5,5);
ellipse(x,-y, 5,5);
}
}
@yyolk
Copy link
Author

yyolk commented Dec 3, 2012

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