Advertisement
xeromino

burst

Sep 21st, 2014
441
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.13 KB | None | 0 0
  1. int num=60, framesAmount=120;
  2. float t, dx;
  3. float[] r = new float[num];
  4. float[] x = new float[num];
  5. void setup() {
  6.   size(500, 500);
  7.   background(0);
  8.   for (int i=0; i<num; i++) {
  9.     x[i]=0;
  10.     r[i]=TWO_PI/num*i;
  11.     dx=1.0/framesAmount;
  12.   }
  13. }
  14.  
  15. void draw() {
  16.   fill(#322030, 30);
  17.   noStroke();
  18.   rect(0, 0, width, height);
  19.   stroke(#FCFDEB, 100);
  20.   strokeWeight(2);
  21.   t+=dx;
  22.   translate(width/2, height/2);
  23.   for (int i=0; i<num; i++) {
  24.     float offSet=TWO_PI/num*i;
  25.     pushMatrix();
  26.     rotate(offSet);
  27.     float sz = 100;
  28.     x[i] = ease(t, 1.0, 4.0)*(sqrt(sq(width/2)+sq(height/2)));
  29.     pushMatrix();
  30.     translate(x[i], 0);
  31.     rotate(r[i]);
  32.     line(0, sz/2, 0, -sz/2);
  33.     popMatrix();
  34.     popMatrix();
  35.     r[i] += 0.1;
  36.   }
  37.   //if (frameCount%2==0 && frameCount>240 && frameCount<361) saveFrame("image-##.gif");
  38.   if (frameCount%framesAmount==0) {
  39.     t=0;
  40.     for (int i=0; i<num; i++) x[i]=0;    //noLoop();
  41.   }
  42. }
  43.  
  44. float ease(float t, float e) {
  45.   return t<0.5? 0.5*pow(2*t, e) : 1 - 0.5*pow(2*(1 - t), e);
  46. }
  47. float ease(float t, float in, float out) {
  48.   return (1-t)*ease(t, in) + t*ease(t, out);
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement