Constructor
new module:Spline(positionDefinition, points, tensionopt, optionsopt)
Spline constructor
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
positionDefinition | PositionDefinition | First point | ||
points | Array.<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 |
- Source
Extends
Members
(static) defaultTension :Number
Default ratio of tension
Type:
- Number
- Source
tension :Number
Type:
- Number
- Source
Methods
(static) from(definition) → {Spline}
Parameters:
Name | Type | Description |
---|---|---|
definition | Object | Spline definition |
- Source
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 | | 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) |
- Source
trace(path) → {Spline}
Draw the spline
Parameters:
Name | Type | Description |
---|---|---|
path | Path2D | Current drawing path |
- Overrides
- Source
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 |
- Source
Returns:
- Type:
- Array.<Position>