Created
September 6, 2013 20:52
-
-
Save reuk/6469888 to your computer and use it in GitHub Desktop.
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
void setup() { | |
size(500, 500, P3D); | |
blendMode(ADD); | |
noFill(); | |
strokeWeight(2); | |
frameRate(25); | |
} | |
void draw() { | |
background(0); | |
translate(width * 0.6, height / 2); | |
rotateY(PI * -0.3); | |
final int DIVISIONS = 101; | |
final float RAD = 150; | |
final float ANGLE = -(frameCount % 20) * 2 * PI * 0.05; | |
for (int i = 1; i != DIVISIONS - 1; ++i) { | |
pushMatrix(); | |
final float Z = ((i * RAD * 2) / (DIVISIONS - 1)) - RAD; | |
final float R = sqrt((RAD * RAD) - (Z * Z)); | |
final float ANGLE_OFFSET = ANGLE + cos(Z / RAD) * 2 * PI; | |
translate(0, 0, Z); | |
stroke(255, 255, 255, 32); | |
circle(0, 0, R); | |
curate(RAD, R, ANGLE_OFFSET); | |
translate(sin(ANGLE_OFFSET) * R, cos(ANGLE_OFFSET) * R, 0); | |
sphere(0.5); | |
popMatrix(); | |
} | |
saveFrame("###-curate.png"); | |
} | |
void circle(float x, float y, float rad) { | |
ellipse(x, y, rad * 2, rad * 2); | |
} | |
void curate(float A, float B, float ANGLE) { | |
beginShape(); | |
for (float j = ANGLE; j < 50; j += 0.1) { | |
final float X_ = (A * j) - (B * sin(j)); | |
final float Y_ = A - (B * cos(j)); | |
vertex(-X_ + ANGLE * A, A - Y_); | |
} | |
endShape(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment