Skip to content

Instantly share code, notes, and snippets.

Created July 19, 2014 19:55
Show Gist options
  • Save anonymous/d8fc4d707367d0c305a0 to your computer and use it in GitHub Desktop.
Save anonymous/d8fc4d707367d0c305a0 to your computer and use it in GitHub Desktop.
// by dave @ bees & bombs
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 = 32;
int numFrames = 300;
float shutterAngle = .5;
boolean recording = false;
void setup_() {
size(500,500);
strokeWeight(1.1);
fill(32);
}
// some very nice variable names here
float ma = .56;
int N = 13;
float d, th;
float ll = 3200, l;
int os = 3;
void draw_() {
background(248);
pushMatrix();
translate(width/2, 40);
for(int i=0; i<N; i++){
th = -sin(TWO_PI*(i+os)*t)*ma; // close enough >:)
pushMatrix();
rotate(th);
stroke(32);
l = ll*pow(i+os,-2);
d = l*.025 + 4;
line(0,0,0,l);
noStroke();
ellipse(0,l,d,d);
popMatrix();
}
popMatrix();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment