Skip to main content

Class: Spline

PathBuilding.Spline(layout, points, pointPropsopt, tsopt, tfopt)

Defines piecewise by polynomials

Constructor

new Spline(layout, points, pointPropsopt, tsopt, tfopt)

Parameters:
NameTypeAttributesDefaultDescription
layoutArray.<PathBuilding.PathPoint.Property>The layout of the input points
pointsArray.<float>Float32Array
pointPropsPathBuilding.PathPointProperties<optional>Static values used when the layout does not include variable ones
tsfloat<optional>0Defines first stroke segment starting T
tffloat<optional>1Defines last stroke segment final T
Properties:
NameTypeDescription
tsfloatFirst stroke segment starting T
tffloatLast stroke segment final T
colorCommon.ColorDefault color used when color chanels do not varies
idstring.<GUID>Spline identifier, usually provided from stroke which owns spline instance
boundsCommon.RectInk path bounds

Since:

  • version 3.0

Extends

Methods

clone() → PathBuilding.Spline

Clone instance

Overrides:

Returns:

Cloned instance

Type

PathBuilding.Spline

getChannelData(property) → {Float32Array|Uint8Array}

Extracts property values from path

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

Overrides:

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

Overrides:

Returns:

Property value

Type

float

Example
getPointX, getPointY, getPointSize, ...

getSegment(index) → PathBuilding.Spline

Get new spline based on segment underlying points

Parameters:
NameTypeDescription
indexintIndex of segment
Returns:

Spline segment

Type

PathBuilding.Spline

setPoint(index, Replacement)

Parameters:
NameTypeDescription
indexintPath point index
ReplacementPathBuilding.PathPointpoint

Overrides:

setPoint[PropertyName](index, value)

Set point property value based on underlying layout

Parameters:
NameTypeDescription
indexintPoint index
valuefloatProperty value

Overrides:

Example
setPointX, setPointY, setPointSize, ...

slice(fragment) → PathBuilding.Spline

Extracts spline part

Parameters:
NameTypeDescription
fragmentPathBuilding.SplineFragmentPath part descriptor

Overrides:

Returns:

Spline slice

Type

PathBuilding.Spline

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

Extracts path fragment data

Parameters:
NameTypeDescription
pointIndexStartintStarting point index
pointIndexEndintFinal 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

PathBuilding.Path

toSVGPath() → {string}

Converts path geometry to SVG path data

Overrides:

Returns:

SVG path

Type

string

transform(matrix) → {PathBuilding.Path|PathImpl}

Transform path points

Parameters:
NameTypeDescription
matrixCommon.MatrixTransform matrix

Overrides:

Returns:

new path instance (type is inheritance dependent)

Type

PathBuilding.Path|PathImpl

transformSelf(matrix)

Self transform path points

Parameters:
NameTypeDescription
matrixCommon.MatrixTransform matrix

Overrides:

(static) fromJSON(data) → PathBuilding.Spline

Deserialize from JSON

Parameters:
NameTypeDescription
dataJSONSpline data
Returns:

Spline instance

Type

PathBuilding.Spline

Home