Advertisement
xeromino

candyshells

Feb 5th, 2014
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.19 KB | None | 0 0
  1. int num = 7;
  2. PVector[] points = new PVector[num];
  3. float x, y, destx, desty, r;
  4. int i=0;
  5.  
  6. void setup() {
  7.   size(1000, 1000);
  8.   background(#202020);
  9.   rectMode(CENTER);
  10.   float radius = width/6;
  11.  
  12.   for (int i=0; i<num; i++) {
  13.     float a = TAU/num;
  14.     float px = width/2 + sin(i*a)*radius;  
  15.     float py = height/2 + cos(i*a)*radius;  
  16.     points[i] = new PVector(px, py);
  17.   }
  18.  
  19.   x = points[0].x;
  20.   y = points[0].y;
  21.  
  22.   destx = points[0].x;
  23.   desty = points[0].y;
  24. }
  25. void draw() {
  26.   stroke(255, 200);
  27.  
  28.   float sz = map(sin(r), -1, 1, width/10, width/5);
  29.   float v = 5;
  30.   //println(frameCount); 221
  31.  
  32.   x = lerp(x, destx, 0.1);
  33.   y = lerp(y, desty, 0.1);
  34.  
  35.   float d = dist(x, y, destx, desty);
  36.   if (d < 1) {
  37.     x = destx;
  38.     y = desty;
  39.     i++;
  40.     destx = points[i%num].x;
  41.     desty = points[i%num].y;
  42.   }
  43.  
  44.  
  45.   pushMatrix();
  46.   translate(x, y);
  47.   rotate(r);
  48.   if (random(1)>.7) {
  49.     fill(#DAD782, 100);
  50.   }
  51.   else {
  52.     fill(#BA3088, 150);
  53.   }
  54.   rect(10+random(-v, v), -20+random(-v, v), sz, sz, sz/10);  
  55.   popMatrix();
  56.  
  57.   r += 0.0523*2;
  58.  
  59.   //if (frameCount % 4 == 0) saveFrame("image-####.gif");
  60. }
  61.  
  62. void keyPressed() {
  63.   save(random(2323)+".png");
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement