Advertisement
xeromino

excited

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