/** * Flade - Flash Dynamics Engine * Release 0.5 alpha * Rectangle class * Copyright 2004, 2005 Alec Cove * * This file is part of Flade. The Flash Dynamics Engine. * * Flade is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * Flade is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Flade; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * Flash is a registered trademark of Macromedia */ import org.cove.flade.Particle; import org.cove.flade.ParticleSystem; class org.cove.flade.Rectangle { public var p0:Particle; public var p1:Particle; public var p2:Particle; public var p3:Particle; public function Rectangle (pSystem:ParticleSystem, center, rWidth, rHeight) { // top left p0 = pSystem.addParticle(center.x - rWidth / 2, center.y - rHeight / 2); // top right p1 = pSystem.addParticle(center.x + rWidth / 2, center.y - rHeight / 2); // bottom right p2 = pSystem.addParticle(center.x + rWidth / 2, center.y + rHeight / 2); // bottom left p3 = pSystem.addParticle(center.x - rWidth / 2, center.y + rHeight / 2); // edges pSystem.addSpringConstraint(p0, p1); pSystem.addSpringConstraint(p1, p2); pSystem.addSpringConstraint(p2, p3); pSystem.addSpringConstraint(p3, p0); // crossing braces pSystem.addSpringConstraint(p0, p2); pSystem.addSpringConstraint(p1, p3); } }