Advertisement
xeromino

more

Oct 31st, 2013
238
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.26 KB | None | 0 0
  1. int howMany = 15;
  2. float step, edge, theta, x;
  3. ExLine [] Elem = new ExLine[howMany];
  4. ExLine [] Elem2 = new ExLine[howMany];
  5. ExLine [] Elem3 = new ExLine[howMany];
  6.  
  7. void setup() {
  8.   size(500, 400);
  9.   x = 0;
  10.   edge = width/10;
  11.   step = (width-2*edge)/howMany;
  12.    
  13.   theta = 0;
  14.   for (int i = 0; i < Elem.length; i++) {
  15.     x = i*step;
  16.     Elem[i]= new ExLine(x, 0+theta, edge,1,1);
  17.     Elem2[i]= new ExLine(x, PI/2+theta, edge,.9,.9);
  18.     Elem3[i]= new ExLine(x, PI+theta, edge,.8,.8);
  19.     theta += PI/howMany;
  20.   }
  21. }
  22.  
  23. void draw() {
  24.   background(#0D3F40);
  25.   for (int i = 0; i < Elem.length; i++) {
  26.     Elem[i].display();
  27.     Elem2[i].display();
  28.     Elem3[i].display();
  29.   }
  30.  
  31.   if (frameCount % 2 == 0 && frameCount < 121) saveFrame("image-####.gif");
  32. }
  33.  
  34. class ExLine {
  35.   float x, x2, y, y2, ymin, ymax;
  36.   float rad, theta, edge;
  37.  
  38.   ExLine(float _x, float _theta, float _edge, float _ymin, float _ymax) {
  39.     x = _x;
  40.     y = height*.6;
  41.     rad = 70;
  42.     theta = _theta;
  43.     edge = _edge;
  44.     ymin = -30*_ymin;
  45.     ymax = -120*_ymax;
  46.   }
  47.  
  48.   void display() {
  49.     fill(255,50);
  50.     stroke(255,100);
  51.     y2= map(sin(theta), -1, 1, ymin, ymax);
  52.     x2 = map(sin(theta), -1, 1, step*.4, step*.9);
  53.     rect(x+edge, y, x2, y2);
  54.     theta += .0523;
  55.   }
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement