class Particle extends VerletParticle2D{ int radius; int age; int lifespan; boolean isDead; float decay; Vec2D vel; Vec2D acceleration; float mass; Particle(int x, int y){ this(x,y, randomVector().normalize()); } Particle(int x, int y, Vec2D v){ super(x,y); //this.radius = int(random(1,5)); //this.radius = int(cos(y*.01) + sin( x * .01) + 2); this.radius = int((sin(x+y) + MAXRADIUS)* 2); this.age = 0; this.lifespan = int(random(200,2000)); Vec2D offSet = randomVector().scale(random(1.0,3.0)); this.vel = new Vec2D(v).scale(.25).add(offSet); //this.vel = randomVector().normalize(); this.decay = random(.95,.99); acceleration = new Vec2D(); } void update(){ age++; if (age > lifespan){ isDead = true; return; } this.vel.addSelf(acceleration); this.vel = vel.scale(decay); float angle = noise(x*.005, y*.005,age * .1) * 15.0; Vec2D noiseVec = new Vec2D(cos(angle),sin(angle)); this.vel = vel.add(noiseVec.scale(.02 *(1.0 - age/lifespan))); this.x += vel.x; this.y += vel.y; acceleration.clear(); //interpolateTo(getVelocity()); float b = brightness(img.get(int(x/picScale),int(y/picScale)))/255.0; this.radius = int(MAXRADIUS * b); this.mass = radius * radius * .005; } void draw(){ //pushStyle(); //fill( brightness(img.get(int(x),int(y)))); //noStroke(); //fill(c); ellipse(x,y,radius, radius); //popStyle(); } }