Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
// 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 |
int(result[i][0]*1.0/samplesPerFrame) << 16 |
int(result[i][1]*1.0/samplesPerFrame) << 8 |
int(result[i][2]*1.0/samplesPerFrame);
updatePixels();
saveFrame("f###.gif");
if (frameCount==numFrames)
exit();
}
}
//////////////////////////////////////////////////////////////////////////////
int samplesPerFrame = 8;
int numFrames = 80;
float shutterAngle = .6;
boolean recording = true;
void setup_() {
size(500, 500, P2D);
smooth(8);
rectMode(CENTER);
fill(80);
noStroke();
}
float x, y, tt;
float r = 100, th, ph;
float d = 28, dd;
int N = 5;
float aa;
void draw_() {
background(32,30,30);
pushMatrix();
translate(width/2, height/2);
for (int a=-30; a<10; a++) {
aa = a + 2*t;
pushMatrix();
scale(pow(1.4,aa));
for (int i=0; i<14; i++) {
dd = d;
th = (i+.5*(a%2))*TWO_PI/14;
pushMatrix();
rotate(th);
fill(250);
ellipse(r,0,dd,dd);
popMatrix();
pushMatrix();
rotate(th + TWO_PI*sin(TWO_PI*t - PI*aa/6 - th)/50);
fill(32,30,30);
ellipse(r,0,dd*1.04,dd*1.04);
popMatrix();
}
popMatrix();
}
popMatrix();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment