Skip to content

Instantly share code, notes, and snippets.

Created May 22, 2016 21:57
Show Gist options
  • Save anonymous/f2f8c4977a19c6f9980ccdb00f07d218 to your computer and use it in GitHub Desktop.
Save anonymous/f2f8c4977a19c6f9980ccdb00f07d218 to your computer and use it in GitHub Desktop.
// by dave aka bees & bombs >:)
void setup() {
colorMode(HSB,1);
size(540, 540, P3D);
rectMode(CENTER);
fill(200);
noStroke();
frameRate(50);
smooth(8);
}
float t;
int N = 12;
float l = 84, w = 10, r = 150;
void four() {
for (int i=0; i<4; i++) {
pushMatrix();
rotateY(HALF_PI*i);
translate(.5*(l-w), 0, .5*(l-w));
box(w, l, w);
popMatrix();
}
}
void cube() {
pushMatrix();
rotateX(atan(sqrt(.5)));
rotateZ(QUARTER_PI);
four();
pushMatrix();
rotateX(HALF_PI);
four();
popMatrix();
pushMatrix();
rotateZ(HALF_PI);
four();
popMatrix();
popMatrix();
}
void draw() {
t = 0.01*frameCount;
lights();
background(0);
pushMatrix();
translate(width/2, height/2);
for (int i=0; i<N; i++) {
fill(((i+t)/float(N)%1),.8,1);
pushMatrix();
rotate(TWO_PI*(i+t)/N);
translate(r, 0, 0);
rotateY(-TWO_PI*t/3);
cube();
popMatrix();
}
popMatrix();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment