Skip to content

Instantly share code, notes, and snippets.

@wonderburg7
Created January 4, 2019 16:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wonderburg7/45f73c1b6e703f07f2f78078be9c3ec7 to your computer and use it in GitHub Desktop.
Save wonderburg7/45f73c1b6e703f07f2f78078be9c3ec7 to your computer and use it in GitHub Desktop.
/*
Date: Nov. 26th, 2017
Sketch Name: Rotating Cubes
Auther: Kokorin
*/
int len = 50; // possible to change less than 150
int cubes = 3; // numbers of cubes on a side
int step = len / (cubes - 1); // interval cubes
float angle = 0;
float center = - len / 2; // adjustment variable of the center of figure
void setup() {
size(600, 600, P3D);
noFill();
}
void draw() {
background(255);
translate(300, 300, 300);
// rotate around x, y axis
rotateX(angle);
rotateY(angle);
// draw cubes
translate(center, center, center);
for (int i = 0; i <= len; i += step) {
for (int j = 0; j <= len; j += step) {
for (int k = 0; k <= len; k += step) {
fill(255, 255, 255, 0);
pushMatrix();
translate(i, j, k);
box(step - 10); // space between cubes
popMatrix();
}
}
}
angle += 0.01;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment