Created
June 14, 2014 16:55
-
-
Save anonymous/23a4aa44b4ddf28c6575 to your computer and use it in GitHub Desktop.
'expansion' — http://beesandbombs.tumblr.com/post/88500088219/
This file contains hidden or 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 Dave @ beesandbombs >:) | |
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 = 96; | |
float shutterAngle = .6; | |
void setup_() { | |
size(500,500,P2D); | |
smooth(8); | |
noStroke(); | |
fill(32); | |
} | |
float x, y, t, tt, t1; | |
float d = 18, sp = 22; | |
float d1, d2; | |
float td; | |
int N = 18; | |
void draw_() { | |
background(248); | |
pushMatrix(); | |
translate(250,250); | |
for(int i=-N; i<=N; i++){ | |
for(int j=-N; j<=N; j++){ | |
x = i*sp; y = j*.866*sp; | |
if(j%2 != 0) | |
x += .5*sp; | |
tt = constrain(1.6*time - dist(x,y,0,0)/370.0,0,1); | |
td = max(0,1.4*tt - 0.4); | |
td = .5*td + 1.5*td*td - td*td*td; | |
tt = 3*tt*tt - 2*tt*tt*tt; | |
x += x*tt; | |
y += y*tt; | |
d1 = d; d2 = d*pow(td,2); | |
if(j%2 == 0 && (i+j/2)%2 == 0) | |
ellipse(x,y,d1,d1); | |
else | |
ellipse(x,y,d2,d2); | |
} | |
} | |
popMatrix(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment