Advertisement
xeromino

BubbleMickey

Oct 30th, 2013
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.42 KB | None | 0 0
  1. int frames = 60;
  2. int thingies = 800;
  3. Thingie[] th = new Thingie[thingies];
  4.  
  5. void setup() {
  6.   size(500, 500);
  7.   noStroke();
  8.  
  9.   for (int i = 0; i < thingies; i++) {
  10.     th[i] = new Thingie(random(width), random(height), random(1, 3), random(-0.1, 0.1), random(20,50));
  11.   }
  12. }
  13.  
  14. void draw() {
  15.   background(255,0,0);
  16.   float t = (frameCount % frames)/float(frames);
  17.   for (int i=0; i<frames;i++) {
  18.     th[i].draw(t);
  19.   }
  20.   displayMask();
  21.   saveFrame("image#####.gif");
  22.   if (frameCount == frames) noLoop();
  23. }
  24.  
  25. void displayMask() {
  26.   float orgX = width/2;
  27.   float orgY = height/2;
  28.   PGraphics mask = createGraphics(width, height);
  29.   mask.beginDraw();
  30.   mask.background(0);
  31.   mask.fill(255);
  32.   mask.noStroke();
  33.   for (int i=0; i<2; i++) {
  34.     mask.ellipse(width/4+ width/2*i, height/4+40, width*.3, width*.3);
  35.   }
  36.   mask.ellipse(orgX, orgY+40, width*.5, width*.5);
  37.   mask.endDraw();
  38.   mask.filter(BLUR);
  39.   blend(mask, 0, 0, width, height, 0, 0, width, height, DARKEST);
  40. }
  41. class Thingie {
  42.   float x, y, scale, rotation, sz;
  43.  
  44.   Thingie(float _x, float _y, float _scale, float _rotation, float _sz) {
  45.     x = _x;
  46.     y = _y;
  47.     scale = _scale;
  48.     rotation = _rotation;
  49.     sz = _sz;
  50.   }
  51.  
  52.   void draw(float time) {
  53.     resetMatrix();
  54.     scale(scale);
  55.     translate(x, y);
  56.     rotate(rotation);
  57.     fill(255,255,0,200);
  58.     ellipse(0,-time*height+height, sz, sz);
  59.     ellipse(0,-time*height, sz, sz);
  60.   }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement