Advertisement
xeromino

p213

Feb 10th, 2014
354
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.51 KB | None | 0 0
  1. // based upon:
  2. // P_2_1_3_03.pde
  3. //
  4. // Generative Gestaltung, ISBN: 978-3-87439-759-9
  5. // First Edition, Hermann Schmidt, Mainz, 2009
  6. // Hartmut Bohnacker, Benedikt Gross, Julia Laub, Claudius Lazzeroni
  7. // Copyright 2009 Hartmut Bohnacker, Benedikt Gross, Julia Laub, Claudius Lazzeroni
  8. //
  9. // http://www.generative-gestaltung.de
  10.  
  11.  
  12. float tileCountX = 3;
  13. float tileCountY = 3;
  14. int count = 0;
  15. float theta;
  16.  
  17. void setup() {
  18.   size(400, 400);
  19. }
  20.  
  21.  
  22. void draw() {
  23.   rectMode(CENTER);
  24.   stroke(0,200);
  25.   background(255);
  26.  
  27.  
  28.   count = (int) map(sin(theta), -1, 1, 10, 15);
  29.   float para = map(sin(theta), -1, 1, 0.1, 0.3);
  30.  
  31.   for (int gridY=0; gridY<= tileCountY; gridY++) {
  32.     for (int gridX=0; gridX<= tileCountX; gridX++) {
  33.       float tileWidth = width / tileCountX;
  34.       float tileHeight = height / tileCountY;
  35.       float posX = tileWidth*gridX + tileWidth/2;
  36.       float posY = tileHeight*gridY + tileHeight/2;
  37.      
  38.  
  39.       pushMatrix();
  40.       translate(posX, posY);
  41.  
  42.       for (float i=0; i<=count; i++) {
  43.        
  44.         line(para*tileWidth, para*tileHeight, tileWidth/2, (i/count-0.5)*tileHeight);
  45.         line(para*tileWidth, para*tileHeight, -tileWidth/2, (i/count-0.5)*tileHeight);
  46.         line(para*tileWidth, para*tileHeight, (i/count-0.5)*tileWidth, tileHeight/2);
  47.         line(para*tileWidth, para*tileHeight, (i/count-0.5)*tileWidth, -tileHeight/2);
  48.       }
  49.       popMatrix();
  50.     }
  51.   }
  52.     theta += 0.0523*2;
  53.  
  54.   if (frameCount%4==0 && frameCount<61) saveFrame("image-####.gif");
  55.  
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement