@baku89/pave / CubicBezier
CubicBezier
A collection of functions to handle a cubic bezier represented with SimpleSegment.
Functions
bounds()
bounds(
arg): [vec2,vec2]
Defined in: CubicBezier.ts:62
Calculates the rect of this Bezier curve.
Parameters
| Parameter | Type |
|---|---|
arg | SimpleSegmentC |
Returns
[vec2, vec2]
derivative()
derivative(
bezier,loc):vec2
Defined in: CubicBezier.ts:119
Calculates the curve tangent at the specified t value. Note that this yields a not-normalized vector.
Parameters
| Parameter | Type |
|---|---|
bezier | SimpleSegmentC |
loc | SegmentLocation |
Returns
vec2
divideAtTimes()
divideAtTimes(
segment,times):VertexC[]
Defined in: CubicBezier.ts:196
Parameters
| Parameter | Type |
|---|---|
segment | SimpleSegmentC |
times | Iterable<number> |
Returns
VertexC[]
fromQuadraticBezier()
fromQuadraticBezier(
start,control,point):SegmentC
Defined in: CubicBezier.ts:40
Parameters
| Parameter | Type |
|---|---|
start | vec2 |
control | vec2 |
point | vec2 |
Returns
isStraight()
isStraight(
bezier):boolean
Defined in: CubicBezier.ts:226
Parameters
| Parameter | Type |
|---|---|
bezier | SimpleSegmentC |
Returns
boolean
isZero()
isZero(
bezier):boolean
Defined in: CubicBezier.ts:213
Parameters
| Parameter | Type |
|---|---|
bezier | SimpleSegmentC |
Returns
boolean
length()
length(
arg):number
Defined in: CubicBezier.ts:54
Calculates the length of the Bezier curve. Length is calculated using numerical approximation, specifically the Legendre-Gauss quadrature algorithm.
Parameters
| Parameter | Type |
|---|---|
arg | SimpleSegmentC |
Returns
number
normal()
normal(
bezier,loc):vec2
Defined in: CubicBezier.ts:140
Calculates the curve normal at the specified t value. Note that this yields a normalized vector.
Parameters
| Parameter | Type |
|---|---|
bezier | SimpleSegmentC |
loc | SegmentLocation |
Returns
vec2
of()
of(
start,control1,control2,point):object
Defined in: CubicBezier.ts:21
Parameters
| Parameter | Type |
|---|---|
start | vec2 |
control1 | vec2 |
control2 | vec2 |
point | vec2 |
Returns
object
| Name | Type | Default value |
|---|---|---|
args | vec2[] | - |
command | string | ‘C’ |
point | vec2 | - |
start | vec2 | - |
offset()
offset(
bezier,distance):Path
Defined in: CubicBezier.ts:262
Parameters
| Parameter | Type |
|---|---|
bezier | SimpleSegmentC |
distance | number |
Returns
point()
point(
bezier,loc):vec2
Defined in: CubicBezier.ts:94
Calculates the point on the curve at the specified t value.
Parameters
| Parameter | Type |
|---|---|
bezier | SimpleSegmentC |
loc | SegmentLocation |
Returns
vec2
project()
project(
bezier,origin):object
Defined in: CubicBezier.ts:147
Finds the on-curve point closest to the specific off-curve point
Parameters
| Parameter | Type |
|---|---|
bezier | SimpleSegmentC |
origin | vec2 |
Returns
object
| Name | Type |
|---|---|
distance? | number |
position | vec2 |
t? | number |
tangent()
tangent(
bezier,loc):vec2
Defined in: CubicBezier.ts:133
Calculates the curve tangent at the specified t value. Unlike derivative, this yields a normalized vector.
Parameters
| Parameter | Type |
|---|---|
bezier | SimpleSegmentC |
loc | SegmentLocation |
Returns
vec2
toPaperBezier()
toPaperBezier(
arg):Curve
Defined in: CubicBezier.ts:25
Parameters
| Parameter | Type |
|---|---|
arg | SimpleSegmentC |
Returns
Curve
toTime()
toTime(
bezier,loc):number
Defined in: CubicBezier.ts:72
Parameters
| Parameter | Type |
|---|---|
bezier | SimpleSegmentC |
loc | SegmentLocation |
Returns
number
trim()
trim(
bezier,start,end):SegmentC
Defined in: CubicBezier.ts:156
Parameters
| Parameter | Type |
|---|---|
bezier | SimpleSegmentC |
start | SegmentLocation |
end | SegmentLocation |