Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save sebguilbaud/1c82c320ba1c122732a2 to your computer and use it in GitHub Desktop.
Save sebguilbaud/1c82c320ba1c122732a2 to your computer and use it in GitHub Desktop.
// by dave @ beesandbombs.tumblr.com >:)
int[][] result;
float t;
void setup() {
setup_();
result = new int[width*height][3];
}
void draw() {
if (!recording) {
t = mouseX*1.0/width;
draw_();
} else {
for (int i=0; i<width*height; i++)
for (int a=0; a<3; a++)
result[i][a] = 0;
for (int sa=0; sa<samplesPerFrame; sa++) {
t = map(frameCount-1 + sa*shutterAngle/samplesPerFrame, 0, numFrames, 0, 1);
draw_();
loadPixels();
for (int i=0; i<pixels.length; i++) {
result[i][0] += pixels[i] >> 16 & 0xff;
result[i][1] += pixels[i] >> 8 & 0xff;
result[i][2] += pixels[i] & 0xff;
}
}
loadPixels();
for (int i=0; i<pixels.length; i++)
pixels[i] = 0xff << 24 | (result[i][0]/samplesPerFrame) << 16 |
(result[i][1]/samplesPerFrame) << 8 | (result[i][2]/samplesPerFrame);
updatePixels();
saveFrame("f###.gif");
if (frameCount==numFrames)
exit();
}
}
//////////////////////////////////////////////////////////////////////////////
int samplesPerFrame = 4;
int numFrames = 201;
float shutterAngle = .6;
boolean recording = true;
void setup_() {
size(500, 500, P2D);
smooth(8);
strokeCap(SQUARE);
noFill();
}
float d = 150;
int N = 8;
float g = 16;
void draw_() {
background(0);
strokeWeight(3.8);
pushMatrix();
translate(width/2, height/2);
scale(1.15);
rotate(TWO_PI*t/N);
stroke(240);
for (int i=0; i<N; i++) {
pushMatrix();
rotate(i*TWO_PI/N);
arc(d/2, 0, d, d, 2*TWO_PI*t, PI+2*TWO_PI*t);
popMatrix();
}
strokeWeight(6);
stroke(0);
for (int i=0; i<N; i++) {
pushMatrix();
rotate((i+.5)*TWO_PI/N);
arc(d/2, 0, d-g, d-g, HALF_PI+TWO_PI*t, PI+HALF_PI+TWO_PI*t);
popMatrix();
}
strokeWeight(1.7);
stroke(255);
for (int i=0; i<N; i++) {
pushMatrix();
rotate((i+.5)*TWO_PI/N);
arc(d/2, 0, d-g, d-g, HALF_PI+TWO_PI*t, PI+HALF_PI+TWO_PI*t);
popMatrix();
}
popMatrix();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment