Class: Spline
PathBuilding.Spline(layout, points, pointPropsopt, tsopt, tfopt)
Defines piecewise by polynomials
Constructor
new Spline(layout, points, pointPropsopt, tsopt, tfopt)
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
layout | Array.<PathBuilding.PathPoint.Property> | The layout of the input points | ||
points | Array.<float> | Float32Array | ||
pointProps | PathBuilding.PathPointProperties | <optional> | Static values used when the layout does not include variable ones | |
ts | float | <optional> | 0 | Defines first stroke segment starting T |
tf | float | <optional> | 1 | Defines last stroke segment final T |
Properties:
Name | Type | Description |
---|---|---|
ts | float | First stroke segment starting T |
tf | float | Last stroke segment final T |
color | Common.Color | Default color used when color chanels do not varies |
id | string.<GUID> | Spline identifier, usually provided from stroke which owns spline instance |
bounds | Common.Rect | Ink path bounds |
Since:
- version 3.0
Extends
Methods
clone() → PathBuilding.Spline
Clone instance
Overrides:
Returns:
Cloned instance
Type
getChannelData(property) → {Float32Array|Uint8Array}
Extracts property values from path
Parameters:
Name | Type | Description |
---|---|---|
property | PathBuilding.PathPoint.Property |
Overrides:
Returns:
channel data, where Uint8Array is applicable for color channels
Type
Float32Array|Uint8Array
getPoint(index, pointPropsopt) → PathBuilding.PathPoint
Get point from current path
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
index | int | Index of point data sequence | ||
pointProps | PathBuilding.PathPointProperties | <optional> | this.pointProps | Point configuration with static properties applicable for all path points |
Overrides:
Returns:
Path point for given index with pre-filled pointProps
Type
getPoint[PropertyName](index) → {float}
Extracts point property value based on underlying layout
Parameters:
Name | Type | Description |
---|---|---|
index | int | Point index |
Overrides:
Returns:
Property value
Type
float
Example
getPointX, getPointY, getPointSize, ...
getSegment(index) → PathBuilding.Spline
Get new spline based on segment underlying points
Parameters:
Name | Type | Description |
---|---|---|
index | int | Index of segment |
Returns:
Spline segment
Type
setPoint(index, Replacement)
Parameters:
Name | Type | Description |
---|---|---|
index | int | Path point index |
Replacement | PathBuilding.PathPoint | point |
Overrides:
setPoint[PropertyName](index, value)
Set point property value based on underlying layout
Parameters:
Name | Type | Description |
---|---|---|
index | int | Point index |
value | float | Property value |
Overrides:
Example
setPointX, setPointY, setPointSize, ...
slice(fragment) → PathBuilding.Spline
Extracts spline part
Parameters:
Name | Type | Description |
---|---|---|
fragment | PathBuilding.SplineFragment | Path part descriptor |
Overrides:
Returns:
Spline slice
Type
slicePoints(pointIndexStart, pointIndexEnd) → {Array.<float>|Float32Array}
Extracts path fragment data
Parameters:
Name | Type | Description |
---|---|---|
pointIndexStart | int | Starting point index |
pointIndexEnd | int | Final point index |
Overrides:
Returns:
Sliced data
Type
Array.<float>|Float32Array
toJSON() → {JSON}
Serialize to JSON
Overrides:
Returns:
Spline data
Type
JSON
toPlainPath() → PathBuilding.Path
Extracts x-s and y-s from spline
Returns:
sequence of X and Y values
Type
toSVGPath() → {string}
Converts path geometry to SVG path data
Overrides:
Returns:
SVG path
Type
string
transform(matrix) → {PathBuilding.Path|PathImpl}
Transform path points
Parameters:
Name | Type | Description |
---|---|---|
matrix | Common.Matrix | Transform matrix |
Overrides:
Returns:
new path instance (type is inheritance dependent)
Type
PathBuilding.Path|PathImpl
transformSelf(matrix)
Self transform path points
Parameters:
Name | Type | Description |
---|---|---|
matrix | Common.Matrix | Transform matrix |
Overrides:
(static) fromJSON(data) → PathBuilding.Spline
Deserialize from JSON
Parameters:
Name | Type | Description |
---|---|---|
data | JSON | Spline data |
Returns:
Spline instance
Type