CubicBezierTuple

A cubic bezier curve represented by four points: a start anchor, a first control point, a second control point, and an end anchor.

Constructor

new CubicBezierTuple(start_anchor, first_control, second_control, end_anchor)

Creates a new cubic bezier curve.

Parameters:
NameTypeDescription
start_anchorPoint2D

The start anchor of the cubic bezier.

first_controlPoint2D

The first control point of the cubic bezier.

second_controlPoint2D

The second control point of the cubic bezier.

end_anchorPoint2D

The end anchor of the cubic bezier.

Classes

CubicBezierTuple

Members

end_anchor

Returns the end anchor of the cubic bezier.

first_control

Returns the first control point of the cubic bezier.

second_control

Returns the second control point of the cubic bezier.

start_anchor

Returns the start anchor of the cubic bezier.

Methods

clone() → {CubicBezierTuple}

Clones the CubicBezierTuple object.

Returns:
Type: 
CubicBezierTuple

length(samplesopt, extra_lengthopt) → {number}

Returns an approximation of the length of the cubic bezier curve, based on sampling points along the curve and an optional extra length to add.

Parameters:
NameTypeAttributesDescription
samplesnumber | null<optional>

The number of samples to take along the curve.

extra_lengthnumber | null<optional>

An optional extra length to add to the approximation.

Returns:
Type: 
number

point_at(t) → {Point2D}

Returns the point on the cubic bezier curve at a given t value.

Parameters:
NameTypeDescription
tnumber

The t value to evaluate the polynomial at. A number between 0 and 1.

Returns:

The point on the cubic bezier curve when the polynomial is evaluated at the given t value.

Type: 
Point2D

(static) from_line(p1, p2) → {CubicBezierTuple}

Creates a new cubic bezier curve from a line.

Parameters:
NameTypeDescription
p1Point2D

The start point of the line.

p2Point2D

The end point of the line.

Returns:

The cubic bezier curve representing the line.

Type: 
CubicBezierTuple

(static) from_quadratic(p1, p2, p3) → {CubicBezierTuple}

Creates a new cubic bezier curve from a quadratic bezier.

Parameters:
NameTypeDescription
p1Point2D

The first anchor point of the quadratic bezier.

p2Point2D

The control point of the quadratic bezier.

p3Point2D

The second anchor point of the quadratic bezier.

Returns:

The cubic bezier curve representing the quadratic bezier.

Type: 
CubicBezierTuple