Class: BezierPathInteractionHelper

BezierPathInteractionHelper(pb, paths, maxDetectDistance)

new BezierPathInteractionHelper(pb, paths, maxDetectDistance)

Pre: all paths must have been added to the PlotBoilerplate's drawable buffer (use the add(Drawable) function). The move callback accepts four params: * The point on the closest curve (Vertex) * The mouse or touch position (Vertex) * The curve position (float t) * The curve index on the array (integer)
Parameters:
Name Type Description
pb PlotBoilerplate
paths Array:.<BezierPath:>
options.autoAdjustPaths boolean If true then inner path points will be auto-adjusted to keep the curve smooth.
options.allowPathRemoval boolean If true then full paths can be removed (by removing selected vertices).
maxDetectDistance number The max detection distance. No events will be fired if the mouse/touch pointer is outside this range (default is Number.MAX_VALUE).
options.onPointerMoved function (pathIndex,pathPoint,pointer,t)
options.onVertexInserted function (pathIndex,insertIndex,newPath,oldPath)
options.onVerticesDeleted function (pathIndex,removedVertexIndices,newPath,oldPath)
options.onPathRemoved function (pathIndex,oldPath)
Source:

Methods

(static) addPathVertexDragListeners(path, vertexDragListener)

A helper function to add drag listeners to all vertices of the given path.
Parameters:
Name Type Description
path BezierPath The Bézier path to add vertex listeners to.
vertexDragListener function The drag listeners to add to each path vertex.
Source:
Returns:
void

(static) removePathVertexDragListeners(path, vertexDragListener)

A helper function to remove drag listeners to all vertices of the given path.
Parameters:
Name Type Description
path BezierPath The Bézier path to remove vertex listeners from.
vertexDragListener function The drag listeners to remove from each path vertex.
Source:
Returns:
void

addPath(path) → {boolean}

Manually add a path to this helper. Note that if `autoAdjustPaths==true` then listeners will be installed to the path's vertices to keep the path smooth at all times.
Parameters:
Name Type Description
path BezierPath The path to add.
Source:
Returns:
Duplicate path instances cannot be added; function will return false if path already exists.
Type
boolean

removePath(path) → {boolean}

Manually remove a path from this helper. Note that this method ignores the `allowPathRemoval` option.
Parameters:
Name Type Description
path BezierPath The path to remove.
Source:
Returns:
Returns false if the path could not be found.
Type
boolean

removePathAt(pathIndex) → {void}

Remove the path at the given index.
Parameters:
Name Type Description
pathIndex number The index of the path (must be inside bounds, see `this.paths` array).
Source:
Returns:
Type
void

update() → {void}

Update the inner status by running the distance calculation again with the current settings. Call this if any of the properties changed (like maxDetecDistance).
Source:
Returns:
Type
void