Advertisement
xeromino

untitled

Jun 2nd, 2015
383
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.85 KB | None | 0 0
  1. int frames=240, num=50;
  2. float theta, rotAngle;
  3.  
  4. void setup() {
  5.   size(540, 540);
  6.   smooth(8);
  7.   noFill();
  8.   stroke(255, 150);
  9.   background(0);
  10. }
  11.  
  12. void draw() {
  13.   background(0);
  14.   float t = (frameCount%frames)/float(frames);
  15.   rotAngle = map(t, 0, 1, 0, TWO_PI)* ease(t, 2, 1);
  16.   float sc = map(sin(theta+rotAngle*2), -1, 1, 1, 4);
  17.   for (int i=0; i<num; i++) {
  18.     pushMatrix();
  19.     translate(width/2, height/2);
  20.     rotate(TWO_PI/num*i);
  21.   float x = map(sin(theta+rotAngle+TWO_PI/num*i*2), -1, 1, 30, 200);
  22.     ellipse(x, 0, 30, 30*sc);
  23.     popMatrix();
  24.   }
  25.   theta += TWO_PI/frames;
  26.   //if (frameCount<=frames) saveFrame("image-###.gif");
  27. }
  28.  
  29. float ease(float t, float e) {
  30.   return t < 0.5 ? 0.5 * pow(2*t, e) : 1 - 0.5 * pow(2*(1 - t), e);
  31. }
  32.  
  33. float ease(float t, float in, float out) {
  34.   return (1-t)*ease(t, in) + t*ease(t, out);
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement