Advertisement
xeromino

arabesque

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