Advertisement
xeromino

hug

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