Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save naikrovek/71a314c3499d13695a91 to your computer and use it in GitHub Desktop.
Save naikrovek/71a314c3499d13695a91 to your computer and use it in GitHub Desktop.
// by Dave @ Bees & Bombs >:)
int[][] result;
float time;
void setup() {
setup_();
result = new int[width*height][3];
}
void draw() {
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++) {
time = 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 = 150;
float shutterAngle = .6;
void setup_() {
size(500, 500, P2D);
smooth(8);
stroke(32);
noFill();
}
int N = 12;
float d = 25, dd;
float r = 175;
float sc = .2;
float th, x, y, t;
float om;
int n = 12;
float spr;
void draw_() {
om = 12*pow(time,1.5);
spr = TWO_PI/N*pow(max(0,1.5*time-0.5),3);
background(240);
pushMatrix();
translate(0,-100);
translate(width/2, height/2);
scale(3.8);
scale(pow(.5*d/r,time));
translate(0,r + 13.5);
for (int i=0; i<N; i++) {
for (int a=0; a<n; a++) {
th = i*TWO_PI/N + om*time + spr*a/n;
x = r*cos(th);
y = r*sin(th);
dd = lerp(d, 2.5*r/d, t);
ellipse(x, y, dd, dd);
strokeWeight(lerp(2.5, dd, sq(time)));
}
}
popMatrix();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment