Advertisement
xeromino

mickey

Oct 28th, 2013
262
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.69 KB | None | 0 0
  1. ArrayList thingies = new ArrayList();
  2. int numElem = 250;
  3.  
  4. void setup() {
  5.   size(500, 500);
  6.   background(0);
  7.  
  8.   noStroke();
  9.  
  10.   for (int i = 0; i < numElem; i++) {
  11.     Thingie thingie = new Thingie();
  12.     thingies.add(thingie);
  13.   }
  14. }
  15.  
  16. void draw() {
  17.   //background(0);
  18.   fill(0,50);
  19.   noStroke();
  20.   rect(0,0,width,height);
  21.   for (int i=0; i<thingies.size();i++) {
  22.     Thingie thing = (Thingie) thingies.get(i);
  23.     thing.run();
  24.   }
  25.   displayMask();
  26.  
  27.   if (frameCount % 2 == 0 && frameCount<101) saveFrame("line-####.gif");
  28. }
  29.  
  30. void displayMask() {
  31.   float orgX = width/2;
  32.   float orgY = height/2;
  33.   PGraphics mask = createGraphics(width, height);
  34.   mask.beginDraw();
  35.   mask.background(255);
  36.   mask.fill(0);
  37.   mask.noStroke();
  38.   for (int i=0; i<2; i++) {
  39.       mask.ellipse(width/4+ width/2*i, height/4+40, width*.3, width*.3);
  40.   }
  41.   mask.ellipse(orgX, orgY+40, width*.5, width*.5);
  42.   mask.endDraw();
  43.   mask.filter(BLUR);
  44.   blend(mask, 0, 0, width, height, 0, 0, width, height, LIGHTEST);
  45.  
  46. }
  47. class Thingie {
  48.   float x, y, sz, startY, a, theta;
  49.   float speedX, speedY;
  50.   int speed = 2;
  51.   float div = 8;
  52.  
  53.   Thingie() {
  54.     x = random(width);
  55.     y = random(height);
  56.     startY = y;
  57.     sz = random(5, 10);
  58.     speedX = random(speed, speed+2);
  59.     speedY = random(-speed/div, speed/div);
  60.     theta = random(TAU);
  61.   }
  62.  
  63.   void run() {
  64.     move();
  65.     display();
  66.   }
  67.  
  68.   void move() {
  69.     x += speedX;
  70.     y += speedY;
  71.  
  72.     if (x > width+sz/2 || y> height+sz/2 ||y < -sz/2 ) {
  73.       x = 0;
  74.       y = startY;
  75.     }
  76.   }
  77.  
  78.   void display() {
  79.     for (int i=0; i<5; i++){
  80.     fill(255,50*i);
  81.     ellipse(x, y, sz-2*i, sz-2*i);
  82.     }
  83.     theta += .05;
  84.   }
  85. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement