Created
March 14, 2019 18:48
-
-
Save martoo6/e43b684b87d67be8f974ec2e2fe27036 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
final int frames = 30; | |
void setup(){ | |
size(500,500,P3D); | |
background(0); | |
} | |
void draw(){ | |
background(0); | |
final int fc = frameCount; | |
final float t = map(fc, 0, frames, 0, 1) % 1; | |
pushMatrix(); | |
translate(width/2, height/2, -100); | |
drawBalls(t); | |
pushMatrix(); | |
rotateY(PI/2); | |
drawBalls(t); | |
popMatrix(); | |
pushMatrix(); | |
rotateX(PI/2); | |
drawBalls(t); | |
popMatrix(); | |
popMatrix(); | |
} | |
void drawBalls(float t){ | |
noStroke(); | |
fill(255); | |
final int balls = 12; | |
final int radius = 200; | |
final float step = TWO_PI/balls; | |
for(int i=0;i<balls;i++){ | |
final float phi = map(t, 0, 1, 0, step) + step*i; | |
final float x = sin(phi)*radius; | |
final float y = cos(phi)*radius; | |
pushMatrix(); | |
translate(x, y, 0); | |
sphere(10); | |
popMatrix(); | |
} | |
} |
Author
martoo6
commented
Mar 18, 2019
•
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment