Class: Path
PathBuilding.Path(points, pointPropsopt, layoutopt)
Sequence of points, based on layout, which defaults to [PathPoint.Property.X, PathPoint.Property.Y]
Constructor
new Path(points, pointPropsopt, layoutopt)
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
points | Array.<float> | Float32Array | ||
pointProps | PathBuilding.PathPointProperties | <optional> | Point configuration with static properties applicable for all path points | |
layout | Array.<PathBuilding.PathPoint.Property> | <optional> | [PathPoint.Property.X, PathPoint.Property.Y] | The layout of the input points |
Properties:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
points | Array.<float> | Float32Array | ||
buffer | ArrayBuffer|SharedArrayBuffer | Path buffer. This property provides setter - applicable only for ArrayBuffer. The only way to recover memory after transfering across workers. | ||
pointProps | PathBuilding.PathPointProperties | Point configuration with static properties applicable for all path points | ||
layout | Array.<PathBuilding.PathPoint.Property> | <optional> | [X, Y] | The layout of the input points |
stride | int | Layout length | ||
length | int | Count of path points | ||
bounds | Common.Rect | Ink path bounds | ||
encoding | Serialization.TypedArrayCodec.Encoding | Applicable for JSON serialization, configures points serialization type |
Since:
- version 3.0.5
Methods
clone() → PathBuilding.Path
Clone instance
Returns:
Cloned instance
Type
getChannelData(property) → {Float32Array|Uint8Array}
Extracts property values from path
Parameters:
Name | Type | Description |
---|---|---|
property | PathBuilding.PathPoint.Property |
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 |
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 |
Returns:
Property value
Type
float
Example
getPointX, getPointY, getPointSize, ...
setPoint(index, Replacement)
Parameters:
Name | Type | Description |
---|---|---|
index | int | Path point index |
Replacement | PathBuilding.PathPoint | point |
setPoint[PropertyName](index, value)
Set point property value based on underlying layout
Parameters:
Name | Type | Description |
---|---|---|
index | int | Point index |
value | float | Property value |
Example
setPointX, setPointY, setPointSize, ...
slice(fragment) → PathBuilding.Path
Extracts a section of the calling path and returns a new path
Parameters:
Name | Type | Description |
---|---|---|
fragment | PathBuilding.PathFragment | Path part descriptor |
Returns:
Sliced path
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 |
Returns:
Sliced data
Type
Array.<float>|Float32Array
toJSON() → {JSON}
Serialize to JSON
Returns:
Path data
Type
JSON
toSVGPath() → {string}
Converts path geometry to SVG path data
Returns:
SVG path
Type
string
transform(matrix) → {PathBuilding.Path|PathImpl}
Transform path points
Parameters:
Name | Type | Description |
---|---|---|
matrix | Common.Matrix | Transform matrix |
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 |
(static) createInstance(points, pointPropsopt, layoutopt) → PathBuilding.Path
Creates Path instance
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
points | Array.<float> | Float32Array | ||
pointProps | PathBuilding.PathPointProperties | <optional> | Point configuration with static properties applicable for all path points | |
layout | Array.<PathBuilding.PathPoint.Property> | <optional> | [PathPoint.Property.X, PathPoint.Property.Y] | The layout of the input points |
Returns:
Path instance
Type
(static) createSharedInstance(points, pointPropsopt, layoutopt) → PathBuilding.Path
Creates Path instance. Difference from createInstance is when points type is Array, it is converted to TypedArray.When SharedArrayBuffer is available for underlying context TypedArray is based on shared buffer.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
points | Array.<float> | Float32Array | ||
pointProps | PathBuilding.PathPointProperties | <optional> | Point configuration with static properties applicable for all path points | |
layout | Array.<PathBuilding.PathPoint.Property> | <optional> | [PathPoint.Property.X, PathPoint.Property.Y] | The layout of the input points |
Returns:
Path instance
Type
(static) fromJSON(data) → PathBuilding.Path
Deserialize from JSON
Parameters:
Name | Type | Description |
---|---|---|
data | JSON | Path data |
Returns:
Path instance
Type