ConstraintRenderer

ConstraintRenderer is a simple renderer for Constraints in a Solver. Constraints are represented with simple lines. This renderer only provides a simple and quick way to visualize constraints in a HTMLCanvas element.

Constructor

new ConstraintRenderer(solver, context)

Parameters:
NameTypeDescription
solverSolver
contextcontext

the HTMLCanvas context

Methods

draw(c)

Draws a single constraint

Parameters:
NameTypeDescription
cConstraint

renderFrame()

Renders the constraints per frame

(static) calculateStressColor(c, maxForce, min, sensitivity) → {string}

Parameters:
NameTypeDefaultDescription
cConstraint
maxForceNumber

maximum force magnitude

minNumber0

minimum force magnitude

sensitivityNumber2

colour change sensitivity

Returns:

a string in the HTML RGB color format

Type: 
string