Advertisement
xeromino

breathe

Feb 22nd, 2016
416
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import peasy.*;
  2. int num = 10, frms = 75, 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(540, 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.   for (int x=-w/2; x<w/2; x += step) {
  19.     for (int y=-h/2; y<h/2; y+= step) {
  20.       for (int z= -d/2; z<d/2; z += step) {
  21.         float offSet = map(y, -w/2, w/2, 0, PI);
  22.         pushMatrix();
  23.         scal = 1;
  24.         if (animate) scal = map(sin(theta), -1, 1, 1, 1.5);
  25.         translate(x*scal, y*scal, z*scal);
  26.         box(step*.9);
  27.         popMatrix();
  28.       }
  29.     }
  30.   }
  31.   if (save && frameCount <= fc + frms) saveFrame("/Volumes/Anim/image-###.gif");
  32.   theta += TWO_PI/frms;
  33. }
  34.  
  35.  
  36. void keyPressed() {
  37.   if (key == 'a') animate = true;
  38.   if (key == 's') {
  39.     fc = frameCount;
  40.     save = true;
  41.   }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement