Class pv.Constraint.bound
Extends
pv.Constraint.
Constrains particles to within fixed rectangular bounds. For example,
this constraint can be used to constrain particles in a physics simulation
within the bounds of an enclosing panel.
Note that the current implementation treats particles as points, with no
area. If the particles are rendered as dots, be sure to include some
additional padding to inset the bounds such that the edges of the dots do not
get clipped by the panel bounds. If the particles have different radii, this
constraint would need to be extended using a radius function, similar to
pv.Constraint.collision.
Defined in: BoundConstraint.js.
Constructor Attributes | Constructor Name and Description |
---|---|
Constructs a new bound constraint.
|
Method Attributes | Method Name and Description |
---|---|
apply(particles)
Applies this constraint to the specified particles.
|
|
x(min, max)
Sets or gets the bounds on the x-coordinate.
|
|
y(min, max)
Sets or gets the bounds on the y-coordinate.
|
Class Detail
pv.Constraint.bound()
Constructs a new bound constraint. Before the constraint can be used, the
#x and #y methods must be call to specify the bounds.
- See:
- pv.Layout.Force
Method Detail
apply(particles)
Applies this constraint to the specified particles.
- Parameters:
- {pv.Particle} particles
- particles to which to apply this constraint.
{pv.Constraint.bound}
x(min, max)
Sets or gets the bounds on the x-coordinate.
- Parameters:
- {number} min
- the minimum allowed x-coordinate.
- {number} max
- the maximum allowed x-coordinate.
- Returns:
- {pv.Constraint.bound} this.
{pv.Constraint.bound}
y(min, max)
Sets or gets the bounds on the y-coordinate.
- Parameters:
- {number} min
- the minimum allowed y-coordinate.
- {number} max
- the maximum allowed y-coordinate.
- Returns:
- {pv.Constraint.bound} this.