Created
September 6, 2014 10:45
-
-
Save anonymous/3a7a03a119921a969e94 to your computer and use it in GitHub Desktop.
orb spiral — http://tmblr.co/ZOLwww1Q8LqyP
This file contains 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 david whyte >:) | |
void setup() { | |
setup_(); | |
result = new int[width*height][3]; | |
result_ = new int[width*height][3]; | |
} | |
int[][] result, result_; | |
float time; | |
void draw_() { | |
if (aberrationAmount == 0.0) { | |
draw__(); | |
return; | |
} | |
for (int i=0; i<width*height; i++) | |
for (int a=0; a<3; a++) | |
result_[i][a] = 0; | |
for (int a=0; a<3; a++) { | |
pushMatrix(); | |
translate(width/2, height/2); | |
scale(1+0.008*a*aberrationAmount); | |
translate(-width/2, -height/2); | |
draw__(); | |
popMatrix(); | |
loadPixels(); | |
for (int i=0; i<pixels.length; i++) { | |
result_[i][a] = pixels[i] >> (8*(2-a)) & 0xff; | |
} | |
} | |
loadPixels(); | |
for (int i=0; i<pixels.length; i++) | |
pixels[i] = 0xff << 24 | result_[i][0] << 16 | | |
result_[i][1] << 8 | result_[i][2]; | |
updatePixels(); | |
} | |
void draw() { | |
if (shutterAngle == 0.0) { | |
time = map(frameCount-1, 0, numFrames, 0, 1) % 1; | |
draw_(); | |
return; | |
} | |
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); | |
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(); | |
} | |
//////////////////////////////////////////////////// | |
float aberrationAmount = .45; | |
int samplesPerFrame = 8; | |
int numFrames = 120; | |
float shutterAngle = .5; | |
void setup_() { | |
size(500,500); | |
fill(250); | |
noStroke(); | |
} | |
float x, y, tt; | |
int N = 66; | |
float t; | |
float r1 = 64, r2 = 240; | |
float r, th, dm = 44, d; | |
void draw__() { | |
t = time; | |
background(24,30,28); | |
pushMatrix(); | |
translate(width/2, height/2); | |
for(int i=0; i<N; i++){ | |
th = 4*TWO_PI*i/N; | |
tt = (.5*t + i*1.0/N) % 1; | |
r = lerp(r1,r2,tt); | |
d = map(cos(TWO_PI*tt),1,-1,0,1); | |
d = dm*(3*d*d - 2*d*d*d); | |
pushMatrix(); | |
rotate(th); | |
ellipse(r,0,d,d); | |
popMatrix(); | |
} | |
popMatrix(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment