Advertisement
xeromino

cubered

Feb 26th, 2016
268
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import peasy.*;
  2. int num = 10, frms = 120, fc;
  3. int w = 200, h = w, d = h;
  4. float theta, step = 20, scal;
  5. boolean animate = false, save=false;
  6.  
  7. PeasyCam cam;
  8.  
  9. void setup() {
  10.   size(750, 540, P3D);
  11.   cam = new PeasyCam(this, 0, 0, 0, 200);
  12.   cam.setMinimumDistance(50);
  13.   cam.setMaximumDistance(1000);
  14. }
  15.  
  16. void draw() {
  17.   background(0);
  18.   randomSeed(123);
  19.   rotateZ(theta/4);
  20.   rotateY(theta/4);
  21.   rotateX(theta/2);
  22.   for (int x=-w/2; x<w/2; x += step) {
  23.     for (int y=-h/2; y<h/2; y+= step) {
  24.       for (int z= -d/2; z<d/2; z += step) {
  25.         float offSet = map(y, -w/2, w/2, 0, PI);
  26.         pushMatrix();
  27.         scal = 1;
  28.         if (animate) scal = map(sin(theta), -1, 1, 1, 1.5);
  29.         translate(x*scal, y*scal, z*scal);
  30.         fill(255);
  31.         if (random(1)>0.8) fill(255,0,0,150);
  32.         box(step*.9);
  33.         popMatrix();
  34.       }
  35.     }
  36.   }
  37.   if (save && frameCount <= (fc + frms*4)) saveFrame("/Volumes/Anim/image-###.gif");
  38.   theta += TWO_PI/frms;
  39. }
  40.  
  41.  
  42. void keyPressed() {
  43.   if (key == 'a') animate = true;
  44.   if (key == 's') {
  45.     fc = frameCount;
  46.     save = true;
  47.   }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement