Created
August 29, 2016 00:01
-
-
Save eqx/a511d3a6cd80d5d0993c12a29c571252 to your computer and use it in GitHub Desktop.
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 whyte https://dribbble.com/beesandbombs | |
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(); | |
loadPixels(); | |
for(int i=0; i<pixels.length; i++) | |
pixels[i] = lerpColor(color(245,244,215), color(149,31,43), red(pixels[i])/255.0); | |
updatePixels(); | |
saveFrame("f###.gif"); | |
if (frameCount==numFrames) | |
exit(); | |
} | |
} | |
////////////////////////////////////////////////////////////////////////////// | |
int samplesPerFrame = 4; | |
int numFrames = 72; | |
float shutterAngle = .8; | |
boolean recording = true; | |
int N = 12; | |
float d, y; | |
float maskD = 460; | |
PImage mask; | |
void setup_() { | |
size(800, 600); | |
smooth(8); | |
background(0); | |
fill(255); | |
noStroke(); | |
ellipse(width/2,height/2,maskD,maskD); | |
mask = get(); | |
strokeWeight(9); | |
fill(0); | |
stroke(255); | |
strokeWeight(12); | |
} | |
void draw_() { | |
background(0); | |
pushMatrix(); | |
translate(width/2, height/2); | |
for (int i=-2*N; i<5*N; i++) { | |
y = 280*(t+i/float(N)); | |
pushMatrix(); | |
rotate(-TWO_PI*i/N); | |
d = lerp(150, 500, i/float(N)+t); | |
ellipse(0, y, d, d); | |
popMatrix(); | |
} | |
popMatrix(); | |
blend(mask,0,0,width,height,0,0,width,height,MULTIPLY); | |
blend(mask,0,0,width,height,0,0,width,height,MULTIPLY); // seemingly need to do this twice, not sure why. | |
pushStyle(); | |
noFill(); | |
ellipse(width/2,height/2,maskD,maskD); | |
popStyle(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment