Created
January 4, 2019 16:08
-
-
Save wonderburg7/45f73c1b6e703f07f2f78078be9c3ec7 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
/* | |
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