|
|
@@ -0,0 +1,84 @@ |
|
|
int[][] result; |
|
|
float time; |
|
|
|
|
|
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); |
|
|
sample(); |
|
|
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##.png"); |
|
|
if (frameCount==numFrames) |
|
|
exit(); |
|
|
} |
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////// |
|
|
|
|
|
int samplesPerFrame = 32; |
|
|
int numFrames = 42; |
|
|
float shutterAngle = .75; |
|
|
|
|
|
void setup() { |
|
|
size(500, 500); |
|
|
result = new int[width*height][3]; |
|
|
noStroke(); |
|
|
colorMode(HSB, 1); |
|
|
} |
|
|
|
|
|
float x, y, th, t, tt, l = 50, w = 6; |
|
|
|
|
|
void sample() { |
|
|
t = time; |
|
|
background(0); |
|
|
pushMatrix(); |
|
|
translate(width/2, height/2); |
|
|
for (int i=-10; i<=10; i++) { |
|
|
for (int j=-15; j<=15; j++) { |
|
|
x = l*i; |
|
|
y = l*.866*j; |
|
|
if (j%2 != 0) |
|
|
x += .5*l; |
|
|
tt = t + 10.15 - 0.001*dist(x, y, 0, 0); |
|
|
tt %= 1; |
|
|
if (tt <= .5) { |
|
|
tt = 2*tt; |
|
|
tt = 3*tt*tt - 2*tt*tt*tt; |
|
|
tt = 3*tt*tt - 2*tt*tt*tt; |
|
|
tt = .5*tt + 1.5*tt*tt - tt*tt*tt; |
|
|
tt *= .5; |
|
|
} |
|
|
else { |
|
|
tt = 2*tt - 1; |
|
|
tt = 3*tt*tt - 2*tt*tt*tt; |
|
|
tt = 3*tt*tt - 2*tt*tt*tt; |
|
|
tt = .5*tt + 1.5*tt*tt - tt*tt*tt; |
|
|
tt = tt*.5 + .5; |
|
|
} |
|
|
fill(abs(tt-.5), 1, 1); |
|
|
for (int k=0; k<3; k++) { |
|
|
pushMatrix(); |
|
|
translate(x, y); |
|
|
rotate(k*TWO_PI/3 + tt*TWO_PI/3); |
|
|
rect(-w/2, 0, w, l*.575); |
|
|
popMatrix(); |
|
|
} |
|
|
} |
|
|
} |
|
|
popMatrix(); |
|
|
} |