Advertisement
xeromino

phyllo

Aug 17th, 2016
862
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ArrayList<Dot> dots = new ArrayList<Dot>();
  2. int n = 0, c=5, frms = 100;
  3. float theta;
  4.  
  5. void setup() {
  6.   size(540, 540);
  7.   while (n<500) {
  8.     float offSet = PI/500*n;
  9.     c = 2;
  10.     float a = n*137.5;
  11.     float r = c * sqrt(n);
  12.     float x = width/2 + cos(a)*r;
  13.     float y = height/2 + sin(a)*r;
  14.     PVector start = new PVector(x, y);
  15.     c = 8;
  16.     a = n*137.5;
  17.     r = c * sqrt(n);
  18.     x = width/2 + cos(a)*r;
  19.     y = height/2 + sin(a)*r;
  20.     PVector end = new PVector(x, y);
  21.     dots.add(new Dot(start, end, offSet));
  22.     n++;
  23.   }
  24. }
  25.  
  26. void draw() {
  27.   background(238);
  28.   for (Dot d: dots) {
  29.     d.update();
  30.     d.show();
  31.   }
  32.  
  33.   theta += TWO_PI/frms;
  34.   //if (frameCount<=frms) saveFrame("image-###.gif");
  35. }
  36.  
  37. class Dot {
  38.  
  39.   PVector start, end, v;
  40.   float sz = 20;
  41.   float x, y, lerpValue, offSet;
  42.  
  43.   Dot(PVector _start, PVector _end, float _offSet) {
  44.     start = _start;
  45.     end = _end;
  46.     offSet = _offSet;
  47.   }
  48.  
  49.   void show() {
  50.     stroke(238);
  51.     fill(34);
  52.     ellipse(v.x, v.y, sz, sz);
  53.   }
  54.  
  55.   void update() {
  56.     sz = map(sin(theta+offSet), -1, 1, 10, 30);
  57.     lerpValue = map(sin(theta+offSet), -1, 1, 0, 1);
  58.     v = PVector.lerp(start, end, lerpValue);
  59.   }
  60. }
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement