Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
// 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