import traer.physics.*; Vector letters; Particle mouse; ParticleSystem ps; String message = "Coming Soon"; void setup() { size(500,300); framerate(30); ps = new ParticleSystem(0, 0.05); PFont font = loadFont("AbadiMT-CondensedExtraBold-48.vlw"); textFont(font); mouse = ps.makeParticle(); mouse.makeFixed(); int xPos = 20; letters = new Vector(); for (int i = 0; i < message.length(); i++) { letters.add(new Letter(message.charAt(i), xPos, height/2)); xPos += textWidth(message.charAt(i)); } } void draw() { background(0); mouse.moveTo(mouseX,mouseY,0); for (Iterator i = letters.iterator(); i.hasNext();) { Letter l = (Letter) i.next(); handleBoundaryCollisions(l.p); l.draw(); } ps.tick(); } class Letter { Particle p, idealPosition; char c; Letter(char c, int x, int y) { this.c = c; p = ps.makeParticle(1, random(width), random(height), 0); p.setVelocity(random(1),random(1),0); ps.makeAttraction(mouse,p,100,10); idealPosition = ps.makeParticle(1,x,y,0); idealPosition.makeFixed(); ps.makeAttraction(p,idealPosition,500,15); } void draw() { fill(200); text(c,p.position().x(),p.position().y()); } } void mousePressed() { mouse.setMass(10); } void mouseReleased() { mouse.setMass(1); } void handleBoundaryCollisions(Particle p) { if ( p.position().x() < 0 || p.position().x() > width ) p.setVelocity( -0.9*p.velocity().x(), p.velocity().y(), 0 ); if ( p.position().y() < 0 || p.position().y() > height ) p.setVelocity( p.velocity().x(), -0.9*p.velocity().y(), 0 ); p.moveTo( constrain( p.position().x(), 0, width ), constrain( p.position().y(), 0, height ), 0 ); }