Skip to main content

Interface: ISpline

Spline curve interface

Accessors​

aabb​

get aabb(): AABB2

Axis-aligned bounding box (minX, minY, maxX, maxY)

Returns​

AABB2

Defined in​

tools/src/types/ISpline.ts:32


closed​

get closed(): boolean

Flag that is set to true when the curve is already closed

set closed(closed): void

Set the curve as closed which connects the last to the first point

Parameters​

• closed: boolean

Returns​

boolean

Defined in​

tools/src/types/ISpline.ts:26


fixedResolution​

get fixedResolution(): boolean

Fixed resolution (eg: Linear Spline)

Returns​

boolean

Defined in​

tools/src/types/ISpline.ts:23


invalidated​

get invalidated(): boolean

Flag that is set to true when the spline needs to be updated. The update runs automaticaly when needed (eg: getPolylinePoints).

Returns​

boolean

Defined in​

tools/src/types/ISpline.ts:41


length​

get length(): number

Length of the spline curve in pixels

Returns​

number

Defined in​

tools/src/types/ISpline.ts:35


numControlPoints​

get numControlPoints(): number

Number of control points

Returns​

number

Defined in​

tools/src/types/ISpline.ts:14


resolution​

get resolution(): number

Resolution of the spline curve (greater than or equal to 0)

set resolution(resolution): void

Set the resolution of the spline curve

Parameters​

• resolution: number

Returns​

number

Defined in​

tools/src/types/ISpline.ts:17

Methods​

addControlPoint()​

addControlPoint(point): void

Add a control point to the end of the array

Parameters​

• point: Point2

Control point (2D)

Returns​

void

Defined in​

tools/src/types/ISpline.ts:53


addControlPointAtU()​

addControlPointAtU(u): ControlPointInfo

Add a control point specifying its u value in Parameter Space which is a number from 0 to N where N is the number of curve segments. The integer part is the curve segment index and the decimal part is the t value on that curve segment.

Parameters​

• u: number

u value in Parameter Space

Returns​

ControlPointInfo

Defined in​

tools/src/types/ISpline.ts:67


addControlPoints()​

addControlPoints(points): void

Add a list of control poits to the end of the array

Parameters​

• points: Point2[]

Control points to be added

Returns​

void

Defined in​

tools/src/types/ISpline.ts:59


clearControlPoints()​

clearControlPoints(): void

Remove all control points

Returns​

void

Defined in​

tools/src/types/ISpline.ts:79


containsPoint()​

containsPoint(point): boolean

Checks if a 2D point is inside the spline curve.

A point is inside a curve/polygon if the number of intersections between the horizontal ray emanating from the given point and to the right and the line segments is odd. https://www.eecs.umich.edu/courses/eecs380/HANDOUTS/PROJ2/InsidePoly.html

Parameters​

• point: Point2

2D Point

Returns​

boolean

True is the point is inside the spline curve or false otherwise

Defined in​

tools/src/types/ISpline.ts:166


deleteControlPointByIndex()​

deleteControlPointByIndex(index): boolean

Delete a control point given its index

Parameters​

• index: number

Control point index to be removed

Returns​

boolean

True if the control point is removed or false otherwise

Defined in​

tools/src/types/ISpline.ts:74


getClosestControlPoint()​

getClosestControlPoint(point): ClosestControlPoint

Finds the closest control point given a 2D point

Parameters​

• point: Point2

Reference point

Returns​

ClosestControlPoint

Closest control point

Defined in​

tools/src/types/ISpline.ts:106


getClosestControlPointWithinDistance()​

getClosestControlPointWithinDistance(point, range): ClosestControlPoint

Finds the closest control point given a 2D point and a maximum distance

Parameters​

• point: Point2

Reference 2D point

• range: number

Returns​

ClosestControlPoint

Closest control point that is within the given range or undefined otherwise

Defined in​

tools/src/types/ISpline.ts:114


getClosestPoint()​

getClosestPoint(point): ClosestSplinePoint

Finds the closest point on the spline curve given 2D point

Parameters​

• point: Point2

Reference 2D point

Returns​

ClosestSplinePoint

Closest point on the spline curve

Defined in​

tools/src/types/ISpline.ts:124


getClosestPointOnControlPointLines()​

getClosestPointOnControlPointLines(point): ClosestPoint

Finds the closest point on the straight line that connects all control points given a 2D point

Parameters​

• point: Point2

Reference point

Returns​

ClosestPoint

Closest point on the straight line that connects all control points

Defined in​

tools/src/types/ISpline.ts:131


getControlPoints()​

getControlPoints(): Point2[]

Get a list with all control points. The control points are cloned to prevent any caller from changing them resulting in unexpected behaviors

Returns​

Point2[]

  • List of all control points

Defined in​

tools/src/types/ISpline.ts:99


getPolylinePoints()​

getPolylinePoints(): Point2[]

Get all points necessary to draw a spline curve

Returns​

Point2[]

Array with all points necessary to draw a spline curve

Defined in​

tools/src/types/ISpline.ts:137


getPreviewPolylinePoints()​

getPreviewPolylinePoints(controlPointPreview, closeDistance): Point2[]

Get all points necessary to draw the preview curve for a new possible control point

Parameters​

• controlPointPreview: Point2

• closeDistance: number

Returns​

Point2[]

Array with all points necessary to draw the preview curve

Defined in​

tools/src/types/ISpline.ts:143


hasTangentPoints()​

hasTangentPoints(): boolean

Bézier curves have tangent points connected to control points

Returns​

boolean

True if the spline has tangent point or false otherwise

Defined in​

tools/src/types/ISpline.ts:47


isPointNearCurve()​

isPointNearCurve(point, maxDist): boolean

Checks if a point is near to the spline curve

Parameters​

• point: Point2

Reference point

• maxDist: number

Maximum allowed distance

Returns​

boolean

True if the point is close to the spline curve or false otherwise

Defined in​

tools/src/types/ISpline.ts:154


setControlPoints()​

setControlPoints(points): void

Replace all control points by some new ones

Parameters​

• points: Point2[]

Control points to be added to the array

Returns​

void

Defined in​

tools/src/types/ISpline.ts:85


updateControlPoint()​

updateControlPoint(index, newControlPoint): void

Update the coordinate of a control point given its index

Parameters​

• index: number

Control point index

• newControlPoint: Point2

New control point

Returns​

void

Defined in​

tools/src/types/ISpline.ts:92