// renders a grid of particles by drawing solid color rectangles centered on each Particle's position class PSGRColorRects implements ParticleSpringGridRenderer { private ColorGrid cg; private float w, h; PSGRColorRects(ColorGrid cg, float w, float h) { this.cg = cg; this.w = w; this.h = h; } void draw(Particle p, int row, int col) { if ( !p.isDead() ) { color c = cg.get(row, col); fill(c); pushMatrix(); translate(0, 0, p.position().z()); rect(p.position().x(), p.position().y(), w, h); popMatrix(); } } }