Skip to content

Instantly share code, notes, and snippets.

@naikrovek
Forked from anonymous/gist:88b64161fc6e023419ac
Last active January 25, 2016 19:08
Show Gist options
  • Select an option

  • Save naikrovek/aae3db68f8b0a83524cd to your computer and use it in GitHub Desktop.

Select an option

Save naikrovek/aae3db68f8b0a83524cd 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("g###.png");
if (frameCount==numFrames)
exit();
}
}
//////////////////////////////////////////////////////////////////////////////
int samplesPerFrame = 4;
int numFrames = 72;
float shutterAngle = .8;
boolean recording = false;
int N = 12;
float d, y;
void setup_() {
size(500, 500);
colorMode(HSB, 1);
strokeWeight(9);
fill(.1);
}
void draw_() {
background(.1);
pushMatrix();
translate(width/2, height/2);
for (int i=-N; i<4*N; i++) {
stroke((i/float(N)+4)%1, .7, .9);
y = 300*(t+i/float(N));
pushMatrix();
rotate(TWO_PI*i/N);
d = lerp(250, 600, i/float(N)+t);
ellipse(0, y, d, d);
popMatrix();
}
popMatrix();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment