Advertisement
xeromino

cubes3D

Feb 14th, 2014
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.79 KB | None | 0 0
  1. int sz, z=0, num=120;
  2. float[] offSet = new float[num];
  3. float theta, scal, inc;
  4. color[] palette = {#69D2E7, #A7DBD8, #E0E4CC, #F38630, #FA6900};
  5.  
  6. void setup() {
  7.   size(1000, 800, P3D);
  8.   rectMode(CENTER);
  9.   theta = PI;
  10.   for (int i=0; i<num; i++) {
  11.     inc += (TWO_PI/num);
  12.     offSet[i] = inc;
  13.   }
  14. }
  15.  
  16. void draw() {
  17.   background(20);
  18.   sz = 500;
  19.  
  20.   for (int i=0; i<num; i++) {
  21.     pushMatrix();
  22.     translate(width/2, height/2,z);
  23.     rotateX(offSet[i]+theta*0.1);
  24.     rotateY(offSet[i]+theta*0.125);
  25.     rotateZ(offSet[i]+theta*0.05);
  26.     sz -= 3;
  27.     scal = map(sin(offSet[i]*3+theta),-1,1,0.2,.8);
  28.     fill(palette[i%5],150);
  29.     strokeWeight(2*scal);
  30.     box(sz*scal);
  31.     popMatrix();
  32.  
  33.   }
  34.   theta += 0.0523;
  35.  
  36. }
  37.  
  38. void keyPressed() {
  39.   save(random(2323)+".tif");
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement