Advertisement
xeromino

p211b

Jan 30th, 2014
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.40 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 = 10;
  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(#E2C1A9);
  26.   noFill();
  27.  
  28.  
  29.   randomSeed(actRandomSeed);
  30.  
  31.   sw0=map(sin(theta),-1,1,10,20);
  32.   sw1=sw0*4;
  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.         strokeCap(PROJECT);
  44.         strokeWeight(sw1);
  45.         stroke(#B88D86,150);
  46.         line(posX, posY, posX+width/tileCount, posY+height/tileCount);
  47.       }
  48.       if (toggle == 1) {
  49.         strokeCap(ROUND);
  50.         strokeWeight(sw0);
  51.         stroke(#47022B);
  52.         line(posX, posY+width/tileCount, posX+height/tileCount, posY);
  53.       }
  54.     }
  55.   }
  56.   theta += 0.0523*2;
  57.  
  58.   //if (frameCount % 2 == 0 && frameCount < 61) saveFrame("image-###.gif");
  59. }
  60.  
  61.  
  62. void mousePressed() {
  63.   actRandomSeed = (int) random(100000);
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement