Advertisement
xeromino

ex1_7

Jul 3rd, 2015
325
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.29 KB | None | 0 0
  1. import java.util.Random;
  2.  
  3. int num = 50;
  4. Walker[] w = new Walker[num];
  5. Random generator;
  6.  
  7. void setup() {
  8.   size(800, 600);
  9.   colorMode(HSB,360,100,100);
  10.   background(#000000);
  11.   for (int i=0; i<num; i++) {
  12.     w[i]= new Walker(i);
  13.   }
  14.   generator = new Random();
  15. }
  16.  
  17. void draw() {
  18.   for (int i=0; i<num; i++) {
  19.     w[i].step();
  20.     w[i].update();
  21.   }
  22. }
  23.  
  24. void keyPressed() {
  25.   save(random(12345)+".png");
  26. }
  27. class Walker {
  28.  
  29.   float x, y, tx, ty;
  30.   color col;
  31.   float rdmCol, tcol;
  32.   float sdC = 15;
  33.   float sz;
  34.   int i;
  35.  
  36.   Walker(int _i) {
  37.     i = _i;
  38.     tx = random(100);
  39.     ty = random(1000);
  40.     tcol = random(10000);
  41.     rdmCol = random(360);
  42.     sz = 5;
  43.     x = width/2;
  44.     y = height/2;
  45.   }
  46.  
  47.   void step() {
  48.     /*
  49.      x = map(noise(tx), 0, 1, 0, width);
  50.      y = map(noise(ty), 0, 1, 0, height);
  51.      
  52.      tx += 0.01;
  53.      ty += 0.01;
  54.      */
  55.     float s = 5;
  56.     float stepsizeX = map(noise(tx), 0, 1, -s, s);
  57.     float stepsizeY = map(noise(ty), 0, 1, -s, s);
  58.  
  59.     tx += 0.02;
  60.     ty += 0.01;
  61.  
  62.     x += stepsizeX;
  63.     y += stepsizeY;
  64.  
  65.     tcol += 0.02;
  66.   }
  67.  
  68.   void update() {
  69.     //col = color(noise(tcol)*rdmCol, 90, 90);  
  70.     //col = color(rdmCol, 90,90);
  71.     fill(#cccccc);
  72.     stroke(#000000,50);
  73.     ellipse(x, y, sz, sz);
  74.   }
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement