Created
March 14, 2019 18:48
-
-
Save martoo6/e43b684b87d67be8f974ec2e2fe27036 to your computer and use it in GitHub Desktop.
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
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(); | |
} | |
} |
nicovillanueva
commented
Mar 15, 2019
•
int frames = 120;
void setup(){
size(500,500,P3D);
}
final color[] colors = {
#1B4A66,
#0894A1,
#47AB6C,
#F2B134,
#ED553B
};
void draw(){
background(15);
final int fc = frameCount;
final float t = map(fc, 0, frames, 0, 1) % 1;
println(t);
pushMatrix();
translate(width/2, height/2, -100);
pushMatrix();
rotateY(PI*2 * t);
drawBalls(t, 100, 2);
popMatrix();
pushMatrix();
rotateX((-PI*2) * t);
drawBalls(t, 150, 3);
popMatrix();
pushMatrix();
rotateY(PI*2 * t);
drawBalls(t, 200, 4);
popMatrix();
pushMatrix();
rotateX((PI*2) * t);
drawBalls(t, 250, 5);
popMatrix();
popMatrix();
}
void drawBalls(float t, float radius, int detail){
sphereDetail(detail);
noFill();
final int balls = round(radius*0.1);
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);
float offset = map(t, 0, 1, 0, colors.length);
for(int e=1;e<colors.length;e++){
final float ee = (e + offset) % colors.length;
stroke(colors[e], map(ee, 0, colors.length, 255, 0));
sphere(ee*6);
}
popMatrix();
}
}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment