Advertisement
xeromino

shell

Dec 13th, 2013
214
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. color bg = #ffffff;
  3. color s = #000000;
  4. Circle circles[] = new Circle[num];
  5.  
  6. void setup() {
  7.   size(500, 500);
  8.   background(bg);
  9.   stroke(s,150);
  10.   fill(s,50);
  11.   float maxw = 0;
  12.   float theta = 0;
  13.  
  14.   for (int i=0; i<num; i++) {
  15.     maxw += 20;
  16.  
  17.     circles[i] = new Circle(maxw, theta);
  18.     theta += TAU/num;
  19.   }
  20. }
  21.  
  22. void draw() {
  23.   background(bg);
  24.   for (int i=0; i<circles.length; i++) {
  25.     circles[i].run();
  26.   }
  27.  
  28.   //if (frameCount % 4 == 0 && frameCount < 121) saveFrame("image-####.gif");
  29.  
  30.  
  31. }
  32. class Circle {
  33.   float w, maxw, h, theta, str;
  34.  
  35.   Circle(float _maxw, float _theta) {
  36.     maxw = _maxw;
  37.     theta = _theta;
  38.   }
  39.  
  40.   void run() {
  41.     move();
  42.     display();
  43.   }
  44.  
  45.   void move() {
  46.     w = map(sin(theta), -1, 1, -maxw, maxw);
  47.     h = map(cos(theta), -1, 1, maxw/3, maxw);
  48.     theta += 0.0523;
  49.   }
  50.  
  51.   void display() {
  52.     ellipse(width/2, height/2, w, h);
  53.   }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement