Skip to content

Instantly share code, notes, and snippets.

Created March 13, 2014 21:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/9537919 to your computer and use it in GitHub Desktop.
Save anonymous/9537919 to your computer and use it in GitHub Desktop.
"technobox"
int[][] result;
float time;
void setup() {
theSetup();
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] = 0xff << 24 | (result[i][0]/samplesPerFrame) << 16 |
(result[i][1]/samplesPerFrame) << 8 | (result[i][2]/samplesPerFrame);
updatePixels();
fr = get();
filter(BLUR, 2);
blend(fr, 0, 0, 500, 500, 0, 0, 500, 500, ADD);
fr = get();
filter(BLUR, 5);
blend(fr, 0, 0, 500, 500, 0, 0, 500, 500, ADD);
saveFrame("f##.png");
if (frameCount==numFrames)
exit();
}
//////////////////////////////////////////////////////////////////////////////
int samplesPerFrame = 32;
int numFrames = 48;
float shutterAngle = .6;
float l = 42;
float l1, l2, w1, w2, h1, h2;
float t;
PImage fr;
float ease(float x) {
float xxx = 3*x*x - 2*x*x*x;
xxx = 3*xxx*xxx - 2*xxx*xxx*xxx;
return xxx;
}
void theSetup() {
size(500, 500, P3D);
smooth(4);
noFill();
}
void sample() {
t = time;
w1 = map(sin(TWO_PI*t), -1, 1, 0, 1);
w1 = ease(w1);
w1 = map(w1, 0, 1, l, 3*l);
w2 = map(-sin(TWO_PI*t), -1, 1, 0, 1);
w2 = ease(w2);
w2 = map(w2, 0, 1, l, 3*l);
h1 = map(cos(TWO_PI*t), -1, 1, 0, 1);
h1 = ease(h1);
h1 = map(h1, 0, 1, l, 3*l);
h2 = map(-cos(TWO_PI*t), -1, 1, 0, 1);
h2 = ease(h2);
h2 = map(h2, 0, 1, l, 3*l);
l1 = w1;
l2 = w2;
background(0);
pushMatrix();
translate(250, 250, 200);
rotateX(-0.1);
rotateY(HALF_PI*t + PI/3);
strokeWeight(4);
stroke(100);
box(w1, h1, l1);
box(w2, h2, l2);
for (int i=-1; i<2; i+=2)
for (int j=-1; j<2; j+=2)
for (int k=-1; k<2; k+=2)
line(i*w1/2, j*h1/2, k*l1/2,
i*w2/2, j*h2/2, k*l2/2);
popMatrix();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment