Created
August 11, 2014 18:53
-
-
Save anonymous/72d56637b43d11658e03 to your computer and use it in GitHub Desktop.
twisting circle — http://tmblr.co/ZOLwww1Nzw15M
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 | (result[i][0]/samplesPerFrame) << 16 | | |
(result[i][1]/samplesPerFrame) << 8 | (result[i][2]/samplesPerFrame); | |
updatePixels(); | |
saveFrame("g###.png"); | |
if (frameCount==numFrames) | |
exit(); | |
} | |
} | |
////////////////////////////////////////////////////////////////////////////// | |
int samplesPerFrame = 32; | |
int numFrames = 120; | |
float shutterAngle = .6; | |
boolean recording = false; | |
void setup_() { | |
size(500,500,P3D); | |
smooth(8); | |
noFill(); | |
strokeWeight(7); | |
perspective(PI/2.3,1,100,1000); | |
} | |
int N = 720; | |
float th, ph; | |
float x, y, z; | |
float xx, zz; | |
float r = 220; | |
float tw; | |
void draw_() { | |
tw = 0.5*(1-cos(TWO_PI*t)); | |
tw = .5*tw + 1.5*tw*tw - tw*tw*tw; | |
tw *= 3*PI; | |
colorMode(RGB,255); | |
background(32,30,30); | |
pushMatrix(); | |
translate(width/2, height/2); | |
beginShape(); | |
for(int i=0; i<N; i++){ | |
th = i*TWO_PI/N; | |
x = r*cos(th); | |
ph = cos(th)*tw; | |
y = r*sin(th)*cos(ph); | |
z = r*sin(th)*sin(ph); | |
xx = x*cos(PI*t) - z*sin(PI*t); | |
zz = -x*sin(PI*t) - z*cos(PI*t); | |
colorMode(HSB,1); | |
stroke(map(zz,-r,r,1,.4)%1,.9,1); | |
vertex(xx,y,zz); | |
} | |
endShape(CLOSE); | |
popMatrix(); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment