Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- float inc = 0;
- ArrayList _grass = new ArrayList();
- void setup() {
- size(500, 300);
- colorMode(HSB,360,100,100);
- for (int i=-30; i<width*1.2; i += random(2,15)) {
- int b = int(random(40,80));
- Grass grass = new Grass(i,b);
- _grass.add(grass);
- }
- }
- void draw() {
- background(255);
- for (int i=0; i<_grass.size(); i++) {
- Grass grass = (Grass) _grass.get(i);
- grass.display();
- }
- //if (frameCount % 4 ==0 && frameCount < 241) saveFrame("image-####.gif");
- }
- class Grass {
- float x, angle, inc, sw;
- int units, bright;
- Grass(float _x, int _bright) {
- x = _x;
- bright = _bright;
- units = int(random(10, 20));
- }
- void display() {
- stroke(117,74,bright);
- inc += 0.0523/2;
- //angle = sin(inc)/40 + sin(inc*1.1)/20;
- angle = sin(inc)/20;
- pushMatrix();
- translate(x, height);
- sw=units*2;
- for (int i=units; i>0; i--) {
- sw -=2;
- strokeWeight(sw);
- line(0, 0, 0, -8);
- translate(0, -8);
- rotate(angle);
- }
- popMatrix();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement