Advertisement
xeromino

candy

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