Advertisement
xeromino

circles

Nov 21st, 2013
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.13 KB | None | 0 0
  1. ArrayList thingies = new ArrayList();
  2. float limit, r, org_x, org_y;
  3. float sw = 3;
  4. color bg = #2E2633;
  5. color s = #DCE9BE;
  6.  
  7. void setup() {
  8.  
  9.   size(500, 500);
  10.   background(bg);
  11.  
  12.   org_x = width/2;
  13.   org_y = height/2;
  14.  
  15.   float theta = 0;
  16.  
  17.   while (theta < 360) {
  18.     r = random(2, 4);
  19.     theta += r;
  20.     Thingie thingie = new Thingie(theta);
  21.     thingies.add(thingie);
  22.   }
  23. }
  24.  
  25. void draw() {
  26.  
  27.   background(bg);
  28.  
  29.   for (int i=0; i<thingies.size();i++) {
  30.     Thingie thing = (Thingie) thingies.get(i);
  31.     thing.run();
  32.   }
  33.  
  34.   if (frameCount % 4 == 0 && frameCount <241) saveFrame("image-###.gif");
  35. }
  36. class Thingie {
  37.   float theta, t, x, y;
  38.  
  39.   Thingie(float _theta) {
  40.     theta= _theta;
  41.   }
  42.  
  43.   void run() {
  44.     move();
  45.     display();
  46.  
  47.   }
  48.  
  49.   void move() {
  50.     x = org_x + sin(theta)*150;
  51.     y = org_y + cos(theta)*150;
  52.     t = map(cos(theta), -1, 1, 0.0523, 0.0523/4);
  53.     //t = 0.0523/4;
  54.     sw = map(sin(theta),-1,1,20,50);
  55.     theta += t;
  56.   }
  57.  
  58.   void display() {
  59.     //stroke(s,50);
  60.     strokeWeight(.5);
  61.     fill(s,50);
  62.     stroke(s);
  63.     //noStroke();
  64.     ellipse(x, y, sw, sw);
  65.   }
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement