Created
July 20, 2014 10:29
-
-
Save anonymous/647bd1ff2b868af6e341 to your computer and use it in GitHub Desktop.
columns: http://tmblr.co/ZOLwww1L_k5xH
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
| 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(); | |
| saveFrame("f###.gif"); | |
| if (frameCount==numFrames) | |
| exit(); | |
| } | |
| } | |
| ////////////////////////////////////////////////////////////////////////////// | |
| int samplesPerFrame = 32; | |
| int numFrames = 120; | |
| float shutterAngle = .6; | |
| boolean recording = false; | |
| void setup_() { | |
| size(500, 500, P3D); | |
| ortho(); | |
| strokeWeight(1.25); | |
| smooth(8); | |
| fill(co); | |
| stroke(255); | |
| } | |
| float l = 26, sp = l; | |
| int N = 5; | |
| float tt, x, y; | |
| color co = color(32, 64, 230); | |
| float tw(float q) { | |
| q = (q+100) % 1; | |
| if (q <= .5) | |
| return 2*q; | |
| return 2-2*q; | |
| } | |
| void column(float h) { | |
| pushMatrix(); | |
| translate(0, -h/2, 0); | |
| box(l, h, l); | |
| popMatrix(); | |
| } | |
| void draw_() { | |
| background(co); | |
| ambientLight(192, 192, 192); | |
| directionalLight(100, 100, 100, 1, 2, -4); | |
| directionalLight(92, 92, 92, -1, 2, -6); | |
| pushMatrix(); | |
| translate(250, 290, -100); | |
| rotateX(PI*1.675); | |
| rotateY(PI/4-HALF_PI*t); | |
| for (int i=-N; i<=N; i++) { | |
| for (int j=-N; j<=N; j++) { | |
| x = i*sp; | |
| y = j*sp; | |
| pushMatrix(); | |
| translate(x, 0, y); | |
| tt = t - (abs(i)+abs(j))/22.0; | |
| column(lerp(0, 175, tw(tt))); | |
| popMatrix(); | |
| } | |
| } | |
| popMatrix(); | |
| noLights(); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment