Created
November 29, 2016 18:42
-
-
Save am17an/2dd3978604496687768de3c71bfb5f9f to your computer and use it in GitHub Desktop.
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
| 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