Advertisement
xeromino

Breezy, upd

Oct 22nd, 2013
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.77 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.   if (frameCount % 6 == 0 && frameCount<121) saveFrame("image-####.gif");
  26. }
  27.  
  28. void mouseClicked() {
  29.   save(random(1234)+".jpg");
  30. }
  31. class Strull {
  32.   float x, h, marge, marge_y, t, theta;
  33.   float r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, r12;
  34.  
  35.   Strull(float _x, float _theta) {
  36.     x = _x;
  37.     marge = 20;
  38.     marge_y = 10;
  39.     //fill(#C02942, 150 + random(50));  
  40.     theta = _theta;
  41.     r1 = random(marge/2);
  42.     r2 = random(marge/2);
  43.     r3 = random(marge/2);
  44.     r4 = random(marge/2);
  45.     r5 = random(marge, marge*2);
  46.     r6 = random(marge, marge*2);
  47.     r7 = random(marge, marge*2);
  48.     r8 = random(marge, marge*2);
  49.     r9 = 100+random(marge_y);
  50.     r10 = 250+random(marge_y);
  51.     r11 = 200+random(marge_y);
  52.     r12 =80+random(marge_y) ;
  53.   }
  54.  
  55.   void display() {
  56.     noFill();
  57.     stroke(#C02942, 180);
  58.     t = map(sin(theta), -1, 1, -marge/2, marge);
  59.     h = map(cos(theta),-1,1,.85,.9);
  60.     beginShape();
  61.     curveVertex(x, 0);
  62.     curveVertex(x + r1, 0);
  63.     curveVertex(x + r2 +t, r9);
  64.     curveVertex(x + r3-t/2, r10);
  65.     curveVertex(x + t/2, height*h);
  66.  
  67.     curveVertex(x + r5- t/2, height*h);
  68.     curveVertex(x + r6-t/2, r11);
  69.     curveVertex(x + r7+t, r12);
  70.     curveVertex(x + r8, 0);
  71.     curveVertex(x + r8, 0);
  72.  
  73.     endShape(CLOSE);
  74.     theta -= .0523;
  75.   }
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement