Advertisement
xeromino

p211

Jan 30th, 2014
288
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.35 KB | None | 0 0
  1. // based on code from:
  2. // P_2_1_1_01.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. int tileCount = 20;
  13. int actRandomSeed = 0;
  14. int actStrokeCap = ROUND;
  15. float sw0, sw1, theta;
  16.  
  17.  
  18. void setup() {
  19.   size(500, 500);
  20. }
  21.  
  22.  
  23. void draw() {
  24.  
  25.   background(255);
  26.   noFill();
  27.   strokeCap(PROJECT);
  28.  
  29.   randomSeed(actRandomSeed);
  30.  
  31.   sw0=map(sin(theta),-1,1,3,22);
  32.   sw1=sw0*2;
  33.  
  34.   for (int gridY=0; gridY<tileCount; gridY++) {
  35.     for (int gridX=0; gridX<tileCount; gridX++) {
  36.  
  37.       int posX = width/tileCount*gridX;
  38.       int posY = height/tileCount*gridY;
  39.  
  40.       int toggle = (int) random(0, 2);
  41.  
  42.       if (toggle == 0) {
  43.         strokeWeight(sw0);
  44.         stroke(0);
  45.         line(posX, posY, posX+width/tileCount, posY+height/tileCount);
  46.       }
  47.       if (toggle == 1) {
  48.         strokeWeight(sw1);
  49.         stroke(255);
  50.         //line(posX, posY+width/tileCount, posX+height/tileCount, posY);
  51.       }
  52.     }
  53.   }
  54.   theta += 0.0523;
  55.  
  56.   //if (frameCount % 2 == 0 && frameCount < 121) saveFrame("image-###.gif");
  57. }
  58.  
  59.  
  60. void mousePressed() {
  61.   actRandomSeed = (int) random(100000);
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement