Advertisement
xeromino

broken

Nov 29th, 2013
234
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.33 KB | None | 0 0
  1. ArrayList thingies = new ArrayList();
  2. float limit, r1, r2, org_x, org_y;
  3. float sw = 70;
  4. float diam = 350;
  5. color bg = #3C3658;
  6. color s = #F7E0AE;
  7.  
  8. void setup() {
  9.  
  10.   size(500, 500);
  11.   background(bg);
  12.   strokeCap(SQUARE);
  13.   noFill();
  14.  
  15.   org_x = width/2;
  16.   org_y = height/2;
  17.  
  18.   float theta = 0;
  19.   float start = 0;
  20.   float end = 0;
  21.  
  22.   while (end < 360) {
  23.     r1 = random(1, 3);
  24.     r2 = random(10, 20);
  25.     theta = random(TAU);
  26.     start = end + r1;
  27.     end = start + r2;
  28.     Thingie thingie = new Thingie(theta, start, end);
  29.     thingies.add(thingie);
  30.   }
  31. }
  32.  
  33. void draw() {
  34.   background(bg);
  35.   for (int i=0; i<thingies.size();i++) {
  36.     Thingie thing = (Thingie) thingies.get(i);
  37.     thing.run();
  38.   }
  39.  
  40.   //if (frameCount % 4 == 0 && frameCount <220) saveFrame("image-###.gif");
  41. }
  42.  
  43. class Thingie {
  44.   float theta, t, start, end;
  45.  
  46.   Thingie(float _theta, float _start, float _end) {
  47.     theta= _theta;
  48.     start = radians(_start);
  49.     end = radians(_end);
  50.   }
  51.  
  52.   void run() {
  53.     move();
  54.     display();
  55.  
  56.   }
  57.  
  58.   void move() {
  59.     t = map(sin(theta),-1, 1, 0.0523, 0.0523/4);
  60.     theta += t;
  61.    
  62.     start += t;
  63.     end += t;
  64.    
  65.   }
  66.  
  67.   void display() {
  68.     //stroke(s,50);
  69.     strokeWeight(sw);
  70.     fill(s,50);
  71.     noFill();
  72.     stroke(s,150);
  73.     arc(org_x,org_y,diam,diam,start,end);
  74.   }
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement