Global

Methods

curve(ctx, points, tension, numOfSeg, close) → {Float32Array}

Draws a cardinal spline through given point array. Points must be arranged
as: [x1, y1, x2, y2, ..., xn, yn]. It adds the points to the current path.

There must be a minimum of two points in the input array but the function
is only useful where there are three points or more.

The method continues previous path of the context. If you don't want that
then you need to use moveTo() with the first point from the input array.

The points for the cardinal spline are returned as a new array.

Parameters:
Name Type Argument Default Description
ctx CanvasRenderingContext2D

context to use

points Array

point array

tension Number <optional>
0.5

tension. Typically between [0.0, 1.0] but can be exceeded

numOfSeg Number <optional>
25

number of segments between two points (line resolution)

close Boolean <optional>
false

Close the ends making the line continuous

Returns:

New array with the calculated points that was added to the path

Type
Float32Array

getCurvePoints(points, tension, numOfSeg, close) → {Float32Array}

Calculates an array containing points representing a cardinal spline through given point array.
Points must be arranged as: [x1, y1, x2, y2, ..., xn, yn].

There must be a minimum of two points in the input array but the function
is only useful where there are three points or more.

The points for the cardinal spline are returned as a new array.

Parameters:
Name Type Argument Default Description
points Array

point array

tension Number <optional>
0.5

tension. Typically between [0.0, 1.0] but can be exceeded

numOfSeg Number <optional>
25

number of segments between two points (line resolution)

close Boolean <optional>
false

Close the ends making the line continuous

Returns:

New array with the calculated points that was added to the path

Type
Float32Array