Skip to main content

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:
NameTypeAttributesDefaultDescription
pointsArray.<float>Float32Array
pointPropsPathBuilding.PathPointProperties<optional>Point configuration with static properties applicable for all path points
layoutArray.<PathBuilding.PathPoint.Property><optional>[PathPoint.Property.X, PathPoint.Property.Y]The layout of the input points
Properties:
NameTypeAttributesDefaultDescription
pointsArray.<float>Float32Array
bufferArrayBuffer|SharedArrayBufferPath buffer. This property provides setter - applicable only for ArrayBuffer. The only way to recover memory after transfering across workers.
pointPropsPathBuilding.PathPointPropertiesPoint configuration with static properties applicable for all path points
layoutArray.<PathBuilding.PathPoint.Property><optional>[X, Y]The layout of the input points
strideintLayout length
lengthintCount of path points
boundsCommon.RectInk path bounds
encodingSerialization.TypedArrayCodec.EncodingApplicable for JSON serialization, configures points serialization type

Since:

  • version 3.0.5

Methods

clone() → PathBuilding.Path

Clone instance

Returns:

Cloned instance

Type

PathBuilding.Path

getChannelData(property) → {Float32Array|Uint8Array}

Extracts property values from path

Parameters:
NameTypeDescription
propertyPathBuilding.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:
NameTypeAttributesDefaultDescription
indexintIndex of point data sequence
pointPropsPathBuilding.PathPointProperties<optional>this.pointPropsPoint configuration with static properties applicable for all path points
Returns:

Path point for given index with pre-filled pointProps

Type

PathBuilding.PathPoint

getPoint[PropertyName](index) → {float}

Extracts point property value based on underlying layout

Parameters:
NameTypeDescription
indexintPoint index
Returns:

Property value

Type

float

Example
getPointX, getPointY, getPointSize, ...

setPoint(index, Replacement)

Parameters:
NameTypeDescription
indexintPath point index
ReplacementPathBuilding.PathPointpoint

setPoint[PropertyName](index, value)

Set point property value based on underlying layout

Parameters:
NameTypeDescription
indexintPoint index
valuefloatProperty value
Example
setPointX, setPointY, setPointSize, ...

slice(fragment) → PathBuilding.Path

Extracts a section of the calling path and returns a new path

Parameters:
NameTypeDescription
fragmentPathBuilding.PathFragmentPath part descriptor
Returns:

Sliced path

Type

PathBuilding.Path

slicePoints(pointIndexStart, pointIndexEnd) → {Array.<float>|Float32Array}

Extracts path fragment data

Parameters:
NameTypeDescription
pointIndexStartintStarting point index
pointIndexEndintFinal 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:
NameTypeDescription
matrixCommon.MatrixTransform matrix
Returns:

new path instance (type is inheritance dependent)

Type

PathBuilding.Path|PathImpl

transformSelf(matrix)

Self transform path points

Parameters:
NameTypeDescription
matrixCommon.MatrixTransform matrix

(static) createInstance(points, pointPropsopt, layoutopt) → PathBuilding.Path

Creates Path instance

Parameters:
NameTypeAttributesDefaultDescription
pointsArray.<float>Float32Array
pointPropsPathBuilding.PathPointProperties<optional>Point configuration with static properties applicable for all path points
layoutArray.<PathBuilding.PathPoint.Property><optional>[PathPoint.Property.X, PathPoint.Property.Y]The layout of the input points
Returns:

Path instance

Type

PathBuilding.Path

(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:
NameTypeAttributesDefaultDescription
pointsArray.<float>Float32Array
pointPropsPathBuilding.PathPointProperties<optional>Point configuration with static properties applicable for all path points
layoutArray.<PathBuilding.PathPoint.Property><optional>[PathPoint.Property.X, PathPoint.Property.Y]The layout of the input points
Returns:

Path instance

Type

PathBuilding.Path

(static) fromJSON(data) → PathBuilding.Path

Deserialize from JSON

Parameters:
NameTypeDescription
dataJSONPath data
Returns:

Path instance

Type

PathBuilding.Path

Home