/* Hard-coded version of Pond library for Processing by Designeer (http://designeer.net) Utilizes Traer physics library (http://www.cs.princeton.edu/%7Etraer/physics/) Mar. 06, 2008 */ import traer.physics.*; class Pond { ParticleSystem physics; Particle[][] particles; Spring[][] springsH; Spring[][] springsV; Particle[] anchors; Particle anchor; int width, height, step; float x, y; int gridNumX; int gridNumY; float springStrength = 5.0; float springDamping = 0.1; float physicsStep = 0.1; float bounce = 0.8; float xBoundsMin; float xBoundsMax; float yBoundsMin; float yBoundsMax; boolean guide; Pond(int _width, int _height, float _x, float _y, int _step){ width = _width; height = _height; x = _x; y = _y; step = _step; guide = false; initWater(); } void initWater(){ gridNumX = int(width/step); gridNumY = int(height/step); xBoundsMin = 10.0; xBoundsMax = width - 10.0; yBoundsMin = 10.0; yBoundsMax = height - 10.0; physics = new ParticleSystem(0, 0.005); particles = new Particle[gridNumY][gridNumX]; springsH = new Spring[gridNumY][gridNumX]; springsV = new Spring[gridNumY][gridNumX]; for (int i = 0; i < gridNumY; i++) { for (int j = 0; j < gridNumX; j++) { particles[i][j] = physics.makeParticle(0.1, j * step, i * step, 0.0); if (j > 0) { Particle p1 = particles[i][j - 1]; Particle p2 = particles[i][j]; springsV[i][j] = physics.makeSpring(p1, p2, springStrength, springDamping, step/4); } if (i > 0) { Particle p1 = particles[i - 1][j]; Particle p2 = particles[i][j]; springsH[i][j] = physics.makeSpring(p1, p2, springStrength, springDamping, step/4); } } } //fix border for(int j=0; j