Skip to content

Instantly share code, notes, and snippets.

@jessherzog
Created September 21, 2015 16:04
Show Gist options
  • Save jessherzog/2a79a764437b616a4069 to your computer and use it in GitHub Desktop.
Save jessherzog/2a79a764437b616a4069 to your computer and use it in GitHub Desktop.
int value;
void setup() {
size(640, 360);
}
void draw() {
background(102);
pushMatrix();
translate(width*0.2, height*0.5);
rotate(frameCount / 16.0);
star(0, 0, 5, 70, 3);
popMatrix();
fill(value);
pushMatrix();
translate(width*0.8, height*0.5);
rotate(frameCount / 7.0);
star(0, 0, 10, 700, 30);
popMatrix();
fill(value);
pushMatrix();
translate(width*0.9, height*1.0);
rotate(frameCount / 2.0);
star(0, 0, 12, 750, 80);
popMatrix();
pushMatrix();
translate(width*0.5, height*0.5);
rotate(frameCount / 50.0);
star(0, 0, 80, 100, 40);
popMatrix();
pushMatrix();
translate(width*0.8, height*0.5);
rotate(frameCount / -100.0);
star(6, 0, 30, 70, 5);
popMatrix();
}
void star(float x, float y, float radius1, float radius2, int npoints) {
float angle = TWO_PI / npoints;
float halfAngle = angle/2.0;
beginShape();
for (float a = 0; a < TWO_PI; a += angle) {
float sx = x + cos(a) * radius2;
float sy = y + sin(a) * radius2;
vertex(sx, sy);
sx = x + cos(a+halfAngle) * radius1;
sy = y + sin(a+halfAngle) * radius1;
vertex(sx, sy);
}
endShape(CLOSE);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment