-
-
Save naikrovek/3b19d915e925458be70a 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
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 = 120; | |
float shutterAngle = .7; | |
boolean recording = true; | |
void setup_() { | |
size(800,500); | |
smooth(8); | |
noStroke(); | |
} | |
int N = 12, n = 8; | |
float dmax = 948, d; | |
float tt; | |
void draw_() { | |
tt = 3*t*t - 2*t*t*t; | |
tt = 3*tt*tt - 2*tt*tt*tt; | |
background(#ffffff); | |
pushMatrix(); | |
translate(width/2, height/2); | |
for(int i=0; i<N; i++){ | |
d = map(i,0,N,dmax,0); | |
fill(#c0deed); | |
ellipse(0,0,d-1.5,d-1.5); | |
fill(#ffffff); | |
for(int j=0; j<n; j++){ | |
arc(0,0,d,d,TWO_PI*(j+i*tt+.25)/n,TWO_PI*(j+i*tt+.75)/n); | |
} | |
} | |
popMatrix(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment