Created
January 9, 2014 00:27
-
-
Save anonymous/8327328 to your computer and use it in GitHub Desktop.
gif code!!!!!
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 samplesPerFrame = 32; | |
int numFrames = 42; | |
float shutterAngle = .8; | |
int[][] result; | |
float time; | |
float d1, d2, th, pp = .7, t, tt; | |
int N = 10, M = 9; | |
void setup() { | |
size(1000,1000); | |
stroke(255); | |
strokeWeight(8); | |
noFill(); | |
strokeCap(ROUND); | |
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); | |
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] = (result[i][0]/samplesPerFrame) << 16 | | |
(result[i][1]/samplesPerFrame) << 8 | (result[i][2]/samplesPerFrame); | |
updatePixels(); | |
/* saveFrame("f##.png"); | |
if (frameCount==numFrames) | |
exit(); */ | |
} | |
void sample() { | |
t = time; | |
tt = (2*t)%1; | |
tt = .5*tt + 1.5*tt*tt - tt*tt*tt; | |
tt *= .5; | |
if(t>.5) | |
tt += .5; | |
background(0); | |
for(int i=-2; i<N; i++){ | |
d1 = map(pow(i+2*t,pp),0,pow(N-1,pp),0,width*1.5); | |
d2 = map(pow(i+2*t+1,pp),0,pow(N-1,pp),0,width*1.5); | |
if(i+2*t <= 0) | |
d1 = 0; | |
if(i+2*t+1 <= 0) | |
d2 = 0; | |
if(d1 > 0) | |
ellipse(width/2,height/2,d1,d1); | |
for(int j=0; j<M; j++){ | |
pushMatrix(); | |
translate(width/2,height/2); | |
rotate((j + 1.5*(i+2*tt)*(((i+4)%2)*2-1))*TWO_PI/M); | |
line(0,d1/2 + 1,0,d2/2 - 1); | |
popMatrix(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment