This file contains 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
| // when 'recording' is false mouseX controls time | |
| // when it's set to true, frames are saved in sketch folder | |
| void setup() { | |
| size(500, 500); | |
| colorMode(HSB, 1); | |
| noStroke(); | |
| } | |
| float time, xpos; | |
| int numFrames = 100, numDots = 16; | |
| float diam = 15; | |
| boolean recording = false; | |
| void draw() { | |
| if (recording) | |
| time = frameCount*1.0/numFrames; | |
| else | |
| time = mouseX*1.0/width; | |
| pushMatrix(); | |
| translate(width/2, height/2); | |
| background(0); | |
| for (int i=0; i<numDots; i++) { | |
| fill(i*1.0/numDots, 1, 1); | |
| xpos = 120 + 80*cos(TWO_PI*time + 3*TWO_PI*i/numDots); | |
| pushMatrix(); | |
| rotate(TWO_PI*i/numDots); | |
| ellipse(xpos, 0, diam, diam); | |
| popMatrix(); | |
| } | |
| popMatrix(); | |
| if (recording) { | |
| saveFrame("f###.gif"); | |
| if (frameCount == numFrames) | |
| exit(); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment