Created
August 23, 2014 14:31
-
-
Save anonymous/3b8f9238f730fc8db589 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 dw @ bees & bombs | |
| 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 | | |
| int(result[i][0]*1.0/samplesPerFrame) << 16 | | |
| int(result[i][1]*1.0/samplesPerFrame) << 8 | | |
| int(result[i][2]*1.0/samplesPerFrame); | |
| updatePixels(); | |
| saveFrame("f###.gif"); | |
| if (frameCount==numFrames) | |
| exit(); | |
| } | |
| } | |
| ////////////////////////////////////////////////////////////////////////////// | |
| int samplesPerFrame = 8; | |
| int numFrames = 96; | |
| float shutterAngle = .6; | |
| boolean recording = true; | |
| void setup_() { | |
| size(500, 500, P2D); | |
| smooth(8); | |
| fill(32); | |
| noStroke(); | |
| } | |
| void leaf() { | |
| bezier(0, 0, 42, 0, 15, 27, 0, 50); | |
| bezier(0, 0, -42, 0, -15, 27, 0, 50); | |
| } | |
| float x, y, tt; | |
| int N = 5; | |
| float t1; | |
| float ss; | |
| void draw_() { | |
| ss = -15; | |
| background(250); | |
| pushMatrix(); | |
| translate(width/2, height/2); | |
| rotate(QUARTER_PI); | |
| for (int a=-15; a<=120; a++) { | |
| t1 = .16*(t+a/15.0); | |
| if (0<=t1 && t1<=1) { | |
| N = 2*int(4*pow(2, int(5*t1))); | |
| for (int i=0; i<N; i++) { | |
| tt = (5*t1)%1; | |
| tt = max(0, 1.7*tt-.7); | |
| tt = 3*tt*tt - 2*tt*tt*tt; | |
| pushMatrix(); | |
| rotate(TWO_PI/N); | |
| rotate(-PI*tt/N); | |
| rotate(2*TWO_PI*(i/2)/N); | |
| if (i%2 == 0) | |
| rotate(TWO_PI*tt/N); | |
| translate(0, -2+350*pow(t1,1)); | |
| scale(pow(4, -t1)); | |
| if(t1<=.12) | |
| scale(pow(sin(HALF_PI*t1/.12),.85)); | |
| scale(1,pow(1+.25*t1,.8)); | |
| fill(32); | |
| // leaf(); | |
| // fill(128); | |
| pushMatrix(); | |
| translate(0,-ss); | |
| scale(.8); | |
| if(a%15 != 0) | |
| scale(.175o); | |
| translate(0,ss); | |
| leaf(); | |
| popMatrix(); | |
| popMatrix(); | |
| } | |
| } | |
| } | |
| popMatrix(); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Beautiful work. Also: there's an extra "o" @ line 104