Advertisement
xeromino

breeze

Nov 3rd, 2013
247
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.05 KB | None | 0 0
  1. float inc = 0;
  2. ArrayList _grass = new ArrayList();
  3.  
  4. void setup() {
  5.   size(500, 300);
  6.   colorMode(HSB,360,100,100);
  7.  
  8.   for (int i=-30; i<width*1.2; i += random(2,15)) {
  9.     int b = int(random(40,80));
  10.     Grass grass = new Grass(i,b);
  11.     _grass.add(grass);
  12.   }
  13. }
  14.  
  15. void draw() {
  16.   background(255);
  17.   for (int i=0; i<_grass.size(); i++) {
  18.     Grass grass = (Grass) _grass.get(i);
  19.     grass.display();
  20.   }
  21.   //if (frameCount % 4 ==0 && frameCount < 241) saveFrame("image-####.gif");
  22.  
  23. }
  24.  
  25. class Grass {
  26.   float x, angle, inc, sw;
  27.   int units, bright;
  28.  
  29.   Grass(float _x, int _bright) {
  30.     x = _x;
  31.     bright = _bright;
  32.     units = int(random(10, 20));
  33.   }
  34.  
  35.   void display() {
  36.     stroke(117,74,bright);
  37.     inc += 0.0523/2;
  38.     //angle = sin(inc)/40 + sin(inc*1.1)/20;
  39.     angle = sin(inc)/20;
  40.     pushMatrix();
  41.     translate(x, height);
  42.     sw=units*2;
  43.     for (int i=units; i>0; i--) {
  44.       sw -=2;
  45.       strokeWeight(sw);
  46.       line(0, 0, 0, -8);
  47.       translate(0, -8);
  48.       rotate(angle);
  49.     }
  50.     popMatrix();
  51.   }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement