class Body { Particle p; int w; int h; Body(Particle p, int w, int h) { this.p = p; this.w = w; this.h = h; } void draw() { pushMatrix(); translate(p.position().x(), p.position().y()); scaleByVelocity(); strokeWeight(10); fill(0); ellipse(0, 0, w, h); popMatrix(); } void scaleByVelocity() { PVector pv = new PVector(p.velocity().x(), p.velocity().y()); if(pv.x != 0 && pv.y != 0) { pv.normalize(); pv.x = constrain(pv.x, 0.75, 1); pv.y = constrain(pv.y, 0.75, 1); } scale(abs(pv.x), abs(pv.y)); } }