-
-
Save naikrovek/43fd9e6ac9039a29100c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// by dw @ 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 = 108; | |
float shutterAngle = .6; | |
boolean recording = true; | |
void setup_() { | |
size(500,500); | |
noStroke(); | |
} | |
float d = 26, sp = d*2.2; | |
float x, y, tt; | |
int N = 12; | |
float mn = .5*sqrt(3); | |
color ff; | |
float df; | |
void draw_() { | |
background(250); | |
pushMatrix(); | |
translate(width/2, height/2); | |
rotate(TWO_PI*(t+.5)/12); | |
for(int i=-N; i<=N; i++){ | |
for(int j=-N; j<=N; j++){ | |
x = i*sp; y = j*mn*sp; | |
if(j%2 != 0) | |
x += .5*sp; | |
tt = constrain(2.55*t - dist(x,y,0,0)*0.002,0,1); | |
tt = .5*tt + 1.5*tt*tt - tt*tt*tt; | |
ff = lerpColor(color(32),color(250),sq(tt)); | |
df = pow(.5,tt); | |
x *= df; | |
y *= df; | |
fill(32); | |
if(j%2 != 0 || (i+j/2+20)%2 != 0) | |
fill(ff); | |
pushMatrix(); | |
rotate(TWO_PI*tt/12); | |
ellipse(x,y,d,d); | |
popMatrix(); | |
} | |
} | |
popMatrix(); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment