module:Spline

Spline class
spline demo

Constructor

new module:Spline(positionDefinition, points, tensionopt, optionsopt)

Spline constructor

Parameters:
NameTypeAttributesDefaultDescription
positionDefinitionPositionDefinition

First point

pointsArray.<PositionDefinition> | PositionDefinition

Set of points to go through or a single target point

tensionNumber<optional>
Spline.defaultTension

Ratio of tension between points (0 means straight line, can take any value, but with weird results above 1)

optionsLineOptions<optional>

Drawing options

Extends

Members

(static) defaultTension :Number

Default ratio of tension

Type:
  • Number

tension :Number

Type:
  • Number

Methods

(static) from(definition) → {Spline}

Parameters:
NameTypeDescription
definitionObject

Spline definition

Returns:
Type: 
Spline

(static) splineThrough(path, points, tensionopt, _correctionopt)

Draw a spline through points using a tension (first point should be current position)

Parameters:
NameTypeAttributesDefaultDescription
pathPath2D | CanvasRenderingContext2D

Current drawing path

pointsArray.<PositionDefinition>

Points to use (need at least 2 points)

tensionNumber<optional>
Spline.defaultTension

Ratio of tension

_correctionPositionDefinition<optional>

Apply position correction to all points (used by the library)

trace(path) → {Spline}

Draw the spline

Parameters:
NameTypeDescription
pathPath2D

Current drawing path

Returns:

Itself

Type: 
Spline

(inner) getControlPoint(points, tensionopt) → {Array.<Position>}

Returns control points for a point in a spline (needs before and after, 3 points in total)

Parameters:
NameTypeAttributesDefaultDescription
pointsArray.<Position>

4 points to use (before, one, two, after)

tensionNumber<optional>
Spline.defaultTension

Ratio of tension

Returns:
Type: 
Array.<Position>