Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
columns — tmblr.co/ZOLwww1PMMxOm
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 = 84;
float shutterAngle = .6;
boolean recording = false;
void setup_() {
size(500, 500, P3D);
rectMode(CENTER);
noStroke();
smooth(8);
ortho();
}
color c1 = color(10, 100, 225), c2 = color(230, 50, 40), c3 = color(255, 230, 60);
void column(float h) {
fill(c1);
pushMatrix();
translate(0, 0, h);
rect(0, 0, l, l);
popMatrix();
for (int i=0; i<4; i++) {
fill(c3);
if (i%2 == 0)
fill(c2);
pushMatrix();
rotateZ(HALF_PI*i);
translate(0, l/2, h/2);
rotateX(HALF_PI);
rect(0, 0, l, h);
popMatrix();
}
}
float l = 35;
int N = 12;
float dd, hh;
void draw_() {
pushMatrix();
translate(width/2, height/2);
rotateX(atan(sqrt(.5)));
rotateZ(QUARTER_PI);
for (int i=-N; i<=N; i++) {
for (int j=-N; j<=N; j++) {
dd = abs(i)+abs(j);
pushMatrix();
translate(i*l,j*l);
hh = map(sin(TWO_PI*t - QUARTER_PI*dd), -1, 1, 0, l*5*exp(-.125*dd));
column(hh);
popMatrix();
}
}
popMatrix();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment