@baku89/pave / CubicBezier
CubicBezier
A collection of functions to handle a cubic Bézier segment represented as BareSegmentC.
Functions
bounds()
bounds(
arg): [vec2,vec2]
Defined in: CubicBezier.ts:60
Calculates the rect of this Bezier curve.
Parameters
| Parameter | Type |
|---|---|
arg | BareSegmentC |
Returns
[vec2, vec2]
derivative()
derivative(
bezier,loc):vec2
Defined in: CubicBezier.ts:93
Calculates the curve tangent at the specified t value. Note that this yields a not-normalized vector.
Parameters
| Parameter | Type |
|---|---|
bezier | BareSegmentC |
loc | SegmentLocation |
Returns
vec2
divideAtTimes()
divideAtTimes(
segment,times):VertexC[]
Defined in: CubicBezier.ts:163
Parameters
| Parameter | Type |
|---|---|
segment | BareSegmentC |
times | Iterable<number> |
Returns
VertexC[]
fromQuadraticBezier()
fromQuadraticBezier(
start,control,point):SegmentC
Defined in: CubicBezier.ts:39
Parameters
| Parameter | Type |
|---|---|
start | vec2 |
control | vec2 |
point | vec2 |
Returns
isStraight()
isStraight(
bezier):boolean
Defined in: CubicBezier.ts:193
Parameters
| Parameter | Type |
|---|---|
bezier | BareSegmentC |
Returns
boolean
isZero()
isZero(
bezier):boolean
Defined in: CubicBezier.ts:180
Parameters
| Parameter | Type |
|---|---|
bezier | BareSegmentC |
Returns
boolean
length()
length(
arg):number
Defined in: CubicBezier.ts:53
Calculates the length of the Bezier curve. Length is calculated using numerical approximation, specifically the Legendre-Gauss quadrature algorithm.
Parameters
| Parameter | Type |
|---|---|
arg | BareSegmentC |
Returns
number
normal()
normal(
bezier,loc):vec2
Defined in: CubicBezier.ts:108
Calculates the curve normal at the specified t value. Note that this yields a normalized vector.
Parameters
| Parameter | Type |
|---|---|
bezier | BareSegmentC |
loc | SegmentLocation |
Returns
vec2
of()
of(
start,control1,control2,point):SegmentC
Defined in: CubicBezier.ts:30
Parameters
| Parameter | Type |
|---|---|
start | vec2 |
control1 | vec2 |
control2 | vec2 |
point | vec2 |
Returns
offset()
offset(
bezier,distance):Path
Defined in: CubicBezier.ts:229
Parameters
| Parameter | Type |
|---|---|
bezier | BareSegmentC |
distance | number |
Returns
point()
point(
bezier,loc):vec2
Defined in: CubicBezier.ts:85
Calculates the point on the curve at the specified t value.
Parameters
| Parameter | Type |
|---|---|
bezier | BareSegmentC |
loc | SegmentLocation |
Returns
vec2
project()
project(
bezier,origin):object
Defined in: CubicBezier.ts:115
Finds the on-curve point closest to the specific off-curve point
Parameters
| Parameter | Type |
|---|---|
bezier | BareSegmentC |
origin | vec2 |
Returns
object
| Name | Type |
|---|---|
distance? | number |
position | vec2 |
t? | number |
tangent()
tangent(
bezier,loc):vec2
Defined in: CubicBezier.ts:101
Calculates the curve tangent at the specified t value. Unlike derivative, this yields a normalized vector.
Parameters
| Parameter | Type |
|---|---|
bezier | BareSegmentC |
loc | SegmentLocation |
Returns
vec2
toTime()
toTime(
bezier,loc):number
Defined in: CubicBezier.ts:64
Parameters
| Parameter | Type |
|---|---|
bezier | BareSegmentC |
loc | SegmentLocation |
Returns
number
trim()
trim(
bezier,start,end):SegmentC
Defined in: CubicBezier.ts:123
Parameters
| Parameter | Type |
|---|---|
bezier | BareSegmentC |
start | SegmentLocation |
end | SegmentLocation |