Forked from anonymous/gist:c2152f475b828dd26d83
Last active
January 25, 2016 19:09
-
-
Save naikrovek/32def1da2d3eebf60702 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 @ 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 | | |
| 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 = 16; | |
| int numFrames = 300; | |
| float shutterAngle = .67; | |
| boolean recording = false; | |
| void setup_() { | |
| size(500, 500, P3D); | |
| smooth(8); | |
| perspective(0.45, 1, 100, 1000); | |
| fill(32); | |
| noStroke(); | |
| } | |
| float r = 80; | |
| float x, y, z; | |
| float d; | |
| float th; | |
| float ph; | |
| int N = 750; | |
| void draw_() { | |
| background(250); | |
| pushMatrix(); | |
| translate(width/2, height/2, -100); | |
| for (int i=0; i<N; i++) { | |
| th = TWO_PI*(5*t-i*.8/N) - .5; | |
| ph = map(cos(TWO_PI*(t-i*.5/N)), 1, -1, 0, 1); | |
| for (int _=0; _<3; _++) | |
| ph = 3*ph*ph - 2*ph*ph*ph; | |
| ph *= HALF_PI; | |
| x = -r*cos(th)*1.1; | |
| y = -r*sin(2*th)*.6; | |
| z = -r*cos(2*th)*.6; | |
| d = map(exp(-0.008*i), 1, exp(-0.008*N), 9, 0); | |
| pushMatrix(); | |
| translate(x*cos(ph) + z*sin(ph), y, z*cos(ph) - x*sin(ph)); | |
| ellipse(0, 0, d, d); | |
| popMatrix(); | |
| } | |
| popMatrix(); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment