Advertisement
xeromino

shell

Mar 6th, 2014
265
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.07 KB | None | 0 0
  1. float angle, radius, lx, ly, sz = 5;
  2. int num = 50;
  3. PVector[] dots = new PVector[num];
  4. PVector[] endPos = new PVector[num];
  5.  
  6. void setup() {
  7.   size(400, 400);
  8.   background(20);
  9.   noFill();
  10.   stroke(#FFA41A);
  11.   strokeWeight(1);
  12.   strokeJoin(ROUND);
  13.   radius = width*.4;
  14.  
  15.   startingPoints();
  16.  
  17.   for (int i=0; i<num; i++) {
  18.     float px = width/2 + sin(angle)*radius;
  19.     float py = height/2 + cos(angle)*radius;
  20.     endPos[i]= new PVector(px, py);
  21.     angle+=TWO_PI/num;
  22.   }
  23. }
  24.  
  25. void draw() {
  26.   background(20);
  27.   beginShape(TRIANGLE_FAN);
  28.   for (int i=0; i<num; i++) {
  29.     dots[i].x = lerp(dots[i].x, endPos[i].x, 0.02);
  30.     dots[i].y = lerp(dots[i].y, endPos[i].y, 0.02);
  31.     if (i==0) vertex(dots[i].x, dots[i].y);
  32.     vertex(dots[i].x, dots[i].y);
  33.     if (i==num-1) vertex(dots[i].x, dots[i].y);
  34.   }
  35.   endShape(CLOSE);
  36.  
  37.   if (frameCount%241==0) startingPoints();
  38. }
  39.  
  40. void startingPoints() {
  41.   for (int i=0; i<num; i++) {
  42.     float x = random(width*.33, width*.66);
  43.     float y = random(height*.33, height*.66);
  44.     dots[i]= new PVector(x, y);
  45.   }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement