Advertisement
xeromino

hourglass

Nov 23rd, 2013
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.92 KB | None | 0 0
  1. int num = 20;
  2. float offset, step;
  3. Linn[] lines = new Linn[num-2];
  4. color bg = #35263D;
  5. color q = #ABB785;
  6.  
  7. void setup() {
  8.   size(500, 500);
  9.   background(bg);
  10.  
  11.   float y = 50;
  12.   float theta = 0;
  13.   step = (height-2*y)/num;
  14.   println(step);
  15.  
  16.   for (int i=0; i<num-2; i++) {
  17.     lines[i]= new Linn(int(y+step), theta);
  18.     y += step;
  19.     theta += TAU/num ;
  20.   }
  21. }
  22.  
  23. void draw() {
  24.   background(bg);
  25.  
  26.   for (int i=0; i<lines.length; i++) {
  27.     lines[i].display();
  28.   }
  29.  
  30.   if (frameCount % 1 == 0 && frameCount<121) saveFrame("image-####.gif");
  31.  
  32. }
  33.  
  34.  
  35. class Linn {
  36.   float offset, theta, y;
  37.  
  38.   Linn(float _y, float _theta) {
  39.     y = _y;
  40.     theta = _theta;
  41.   }
  42.  
  43.   void display() {
  44.     offset = map(sin(theta), -1, 1, 30, width/3);
  45.     fill(q);
  46.     stroke(q);
  47.     strokeWeight(2);
  48.     quad(width/2, y, width/2+offset, y, width/2, y+step, 50+(width/2-50)-offset, y+step);
  49.     theta += 0.0523;
  50.   }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement