module:Spline

module:Spline

Spline class
spline demo

Constructor

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

Spline constructor

Parameters:
Name Type Attributes Default Description
positionDefinition PositionDefinition

First point

points Array.<PositionDefinition> | PositionDefinition

Set of points to go through or a single target point

tension Number <optional>
Spline.defaultTension

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

options LineOptions <optional>

Drawing options

Extends

Members

# (static) defaultTension :Number

Default ratio of tension

Type:
  • Number

# tension :Number

Type:
  • Number

Methods

# (static) from(definition) → {Spline}

Parameters:
Name Type Description
definition Object

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:
Name Type Attributes Default Description
path Path2D | CanvasRenderingContext2D

Current drawing path

points Array.<PositionDefinition>

Points to use (need at least 2 points)

tension Number <optional>
Spline.defaultTension

Ratio of tension

_correction PositionDefinition <optional>

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

# trace(path) → {Spline}

Draw the spline

Parameters:
Name Type Description
path Path2D

Current drawing path

Overrides:
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:
Name Type Attributes Default Description
points Array.<Position>

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

tension Number <optional>
Spline.defaultTension

Ratio of tension

Returns:
Type
Array.<Position>