Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ArrayList thingies = new ArrayList();
- int numElem = 250;
- void setup() {
- size(500, 500);
- background(0);
- noStroke();
- for (int i = 0; i < numElem; i++) {
- Thingie thingie = new Thingie();
- thingies.add(thingie);
- }
- }
- void draw() {
- //background(0);
- fill(0,50);
- noStroke();
- rect(0,0,width,height);
- for (int i=0; i<thingies.size();i++) {
- Thingie thing = (Thingie) thingies.get(i);
- thing.run();
- }
- displayMask();
- if (frameCount % 2 == 0 && frameCount<101) saveFrame("line-####.gif");
- }
- void displayMask() {
- float orgX = width/2;
- float orgY = height/2;
- PGraphics mask = createGraphics(width, height);
- mask.beginDraw();
- mask.background(255);
- mask.fill(0);
- mask.noStroke();
- for (int i=0; i<2; i++) {
- mask.ellipse(width/4+ width/2*i, height/4+40, width*.3, width*.3);
- }
- mask.ellipse(orgX, orgY+40, width*.5, width*.5);
- mask.endDraw();
- mask.filter(BLUR);
- blend(mask, 0, 0, width, height, 0, 0, width, height, LIGHTEST);
- }
- class Thingie {
- float x, y, sz, startY, a, theta;
- float speedX, speedY;
- int speed = 2;
- float div = 8;
- Thingie() {
- x = random(width);
- y = random(height);
- startY = y;
- sz = random(5, 10);
- speedX = random(speed, speed+2);
- speedY = random(-speed/div, speed/div);
- theta = random(TAU);
- }
- void run() {
- move();
- display();
- }
- void move() {
- x += speedX;
- y += speedY;
- if (x > width+sz/2 || y> height+sz/2 ||y < -sz/2 ) {
- x = 0;
- y = startY;
- }
- }
- void display() {
- for (int i=0; i<5; i++){
- fill(255,50*i);
- ellipse(x, y, sz-2*i, sz-2*i);
- }
- theta += .05;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement