Advertisement
xeromino

Breeze

Oct 22nd, 2013
224
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.61 KB | None | 0 0
  1. ArrayList curtain;
  2. float theta;
  3.  
  4. void setup() {
  5.   size(400, 400);
  6.   background(#542437);
  7.  
  8.   curtain = new ArrayList();
  9.  
  10.   for (int x=-30; x < width; x +=8) {
  11.     Strull strull = new Strull(x, theta);
  12.     curtain.add(strull);
  13.     theta += random(.15, .2);
  14.   }
  15. }
  16.  
  17. void draw() {
  18.   background(#542437);
  19.   noStroke();
  20.   //println(mouseX + ", " + mouseY);
  21.   for (int i=0; i < curtain.size(); i++) {
  22.     Strull stru = (Strull) curtain.get(i);
  23.     stru.display();
  24.   }
  25. }
  26.  
  27. class Strull {
  28.   float x, marge, marge_y, t, theta;
  29.   float r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, r12;
  30.  
  31.   Strull(float _x, float _theta) {
  32.     x = _x;
  33.     marge = 20;
  34.     marge_y = 10;
  35.     //fill(#C02942, 150 + random(50));  
  36.     theta = _theta;
  37.     r1 = random(marge/2);
  38.     r2 = random(marge/2);
  39.     r3 = random(marge/2);
  40.     r4 = random(marge/2);
  41.     r5 = random(marge, marge*2);
  42.     r6 = random(marge, marge*2);
  43.     r7 = random(marge, marge*2);
  44.     r8 = random(marge, marge*2);
  45.     r9 = 100+random(marge_y);
  46.     r10 = 250+random(marge_y);
  47.     r11 = 200+random(marge_y);
  48.     r12 =80+random(marge_y) ;
  49.   }
  50.  
  51.   void display() {
  52.     noFill();
  53.     stroke(#C02942, 180);
  54.     t = map(sin(theta), -1, 1, -marge/2, marge);
  55.     beginShape();
  56.     curveVertex(x, 0);
  57.     curveVertex(x + r1, 0);
  58.     curveVertex(x + r2 +t, r9);
  59.     curveVertex(x + r3-t/2, r10);
  60.     curveVertex(x + r4+ t/2, height*.85);
  61.  
  62.     curveVertex(x + r5- t/2, height*.85);
  63.     curveVertex(x + r6-t/2, r11);
  64.     curveVertex(x + r7+t, r12);
  65.     curveVertex(x + r8, 0);
  66.     curveVertex(x + r8, 0);
  67.  
  68.     endShape(CLOSE);
  69.     theta -= .0523;
  70.   }
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement