Skip to content

Instantly share code, notes, and snippets.

@colbygk
Forked from anonymous/gist:5967ec3bb006a687d3bb
Created September 1, 2014 03:03
Show Gist options
  • Save colbygk/e93e8be6ab19587eab6f to your computer and use it in GitHub Desktop.
Save colbygk/e93e8be6ab19587eab6f 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###.png");
if (frameCount==numFrames)
exit();
}
}
//////////////////////////////////////////////////////////////////////////////
int samplesPerFrame = 32;
int numFrames = 96;
float shutterAngle = .6;
boolean recording = true;
void setup_() {
size(500, 500, P3D);
noStroke();
smooth(8);
colorMode(HSB, 1);
}
int N = 12;
float d1 = 60, d2 = 18, d3 = 9;
float r2 = 165, r3 = 45;
float hu;
void draw_() {
background(24.0/255);
ambientLight(0, 0, .85);
directionalLight(0, 0, .15, 1, 1, -4);
pushMatrix();
translate(width/2, height*.45, -50);
rotateX(-.75);
fill(1);
sphere(d1);
for (int i=0; i<N; i++) {
hu = ((i-2*t)/float(N) + 2) % 1;
pushMatrix();
rotateY((i-2*t)*TWO_PI/N);
translate(r2, 0, 0);
fill(hu, .9, .85);
sphere(d2);
pushMatrix();
rotateZ(TWO_PI*t + (i-2*t)*TWO_PI/N);
translate(r3, 0);
fill((hu+.5)%1, .05, .7);
sphere(d3);
popMatrix();
popMatrix();
}
popMatrix();
noLights();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment