Skip to content

Instantly share code, notes, and snippets.

@am17an
Created November 29, 2016 18:42
Show Gist options
  • Select an option

  • Save am17an/2dd3978604496687768de3c71bfb5f9f to your computer and use it in GitHub Desktop.

Select an option

Save am17an/2dd3978604496687768de3c71bfb5f9f to your computer and use it in GitHub Desktop.
PVector[] stars;
float[] phase;
void setup() {
size(600, 600, P3D);
stars = new PVector[1000];
phase = new float[1000];
for(int i = 0 ; i < 1000; ++i) {
stars[i] = new PVector(random(width), random(height));
phase[i] = random(TWO_PI);
}
}
float t =0;
void draw() {
background(0);
for(int i = 0 ; i < stars.length; ++i) {
float r = map(sin(t + phase[i]), -1, 1, 2, 4);
noStroke();
fill(255);
ellipse(stars[i].x, stars[i].y, r, r);
}
t += 0.1; // if t >= TWO_PI, it will loop
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment