toosoon-utils 4.0.6 → 4.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +716 -88
- package/lib/constants.d.ts +2 -0
- package/lib/constants.js +5 -3
- package/lib/extras/_wip/pool.d.ts +56 -0
- package/lib/extras/_wip/pool.js +67 -0
- package/lib/{classes/color-scale.d.ts → extras/color-scale/ColorScale.d.ts} +1 -1
- package/lib/{classes/color-scale.js → extras/color-scale/ColorScale.js} +2 -2
- package/lib/extras/curves/ArcCurve.d.ts +19 -0
- package/lib/extras/curves/ArcCurve.js +21 -0
- package/lib/extras/curves/CatmulRomCurve.d.ts +62 -0
- package/lib/extras/curves/CatmulRomCurve.js +75 -0
- package/lib/extras/curves/CubicBezierCurve.d.ts +62 -0
- package/lib/extras/curves/CubicBezierCurve.js +75 -0
- package/lib/extras/curves/Curve.d.ts +95 -0
- package/lib/extras/curves/Curve.js +174 -0
- package/lib/extras/curves/EllipseCurve.d.ts +63 -0
- package/lib/extras/curves/EllipseCurve.js +76 -0
- package/lib/extras/curves/LineCurve.d.ts +51 -0
- package/lib/extras/curves/LineCurve.js +71 -0
- package/lib/extras/curves/Path.d.ts +164 -0
- package/lib/extras/curves/Path.js +367 -0
- package/lib/extras/curves/PathCurve.d.ts +69 -0
- package/lib/extras/curves/PathCurve.js +148 -0
- package/lib/extras/curves/PathSVG.d.ts +41 -0
- package/lib/extras/curves/PathSVG.js +135 -0
- package/lib/extras/curves/PolylineCurve.d.ts +27 -0
- package/lib/extras/curves/PolylineCurve.js +39 -0
- package/lib/extras/curves/QuadraticBezierCurve.d.ts +52 -0
- package/lib/extras/curves/QuadraticBezierCurve.js +63 -0
- package/lib/extras/curves/SplineCurve.d.ts +24 -0
- package/lib/extras/curves/SplineCurve.js +38 -0
- package/lib/extras/curves/index.d.ts +12 -0
- package/lib/extras/curves/index.js +12 -0
- package/lib/{classes/frame-rate.js → extras/frame-rate/FrameRate.js} +1 -1
- package/lib/geometry.d.ts +87 -68
- package/lib/geometry.js +144 -140
- package/lib/prng.js +2 -1
- package/lib/random.d.ts +13 -13
- package/lib/random.js +14 -14
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/types.d.ts +3 -10
- package/package.json +4 -3
- /package/lib/{classes/_pool.d.ts → extras/_/pool.d.ts} +0 -0
- /package/lib/{classes/_pool.js → extras/_/pool.js} +0 -0
- /package/lib/{classes/frame-rate.d.ts → extras/frame-rate/FrameRate.d.ts} +0 -0
package/README.md
CHANGED
|
@@ -378,8 +378,8 @@ angle(x1: number, y1: number, x2: number, y2: number): number;
|
|
|
378
378
|
|
|
379
379
|
Find the closest angle between to angles.
|
|
380
380
|
|
|
381
|
-
- `source`: Source angle in radians.
|
|
382
|
-
- `target`: Target angle in radians.
|
|
381
|
+
- `source`: Source angle (in radians).
|
|
382
|
+
- `target`: Target angle (in radians).
|
|
383
383
|
|
|
384
384
|
```ts
|
|
385
385
|
closestAngle(source: number, target: number): number;
|
|
@@ -419,172 +419,192 @@ Convert radians to a 3D point on the surface of a unit sphere.
|
|
|
419
419
|
- `[target]`: Target vector.
|
|
420
420
|
|
|
421
421
|
```ts
|
|
422
|
-
radToSphere(radius: number, phi: number, theta: number, target?:
|
|
422
|
+
radToSphere(radius: number, phi: number, theta: number, target?: [number, number, number]): [number, number, number];
|
|
423
423
|
```
|
|
424
424
|
|
|
425
425
|
#### Curves
|
|
426
426
|
|
|
427
|
-
#####
|
|
427
|
+
##### line(t, x1, y1, x2, y2)
|
|
428
428
|
|
|
429
|
-
Interpolate a point on
|
|
429
|
+
Interpolate a point on line.
|
|
430
430
|
|
|
431
431
|
- `t`: Normalized time value to interpolate.
|
|
432
432
|
- `x1`: X-axis coordinate of the start point.
|
|
433
433
|
- `y1`: Y-axis coordinate of the start point.
|
|
434
|
-
- `cpx1`: X-axis coordinate of the first control point.
|
|
435
|
-
- `cpy1`: Y-axis coordinate of the first control point.
|
|
436
|
-
- `cpx2`: X-axis coordinate of the second control point.
|
|
437
|
-
- `cpy2`: Y-axis coordinate of the second control point.
|
|
438
434
|
- `x2`: X-axis coordinate of the end point.
|
|
439
435
|
- `y2`: Y-axis coordinate of the end point.
|
|
440
436
|
|
|
441
437
|
```ts
|
|
442
|
-
|
|
438
|
+
line(
|
|
443
439
|
t: number,
|
|
444
440
|
x1: number,
|
|
445
441
|
y1: number,
|
|
446
|
-
cpx1: number,
|
|
447
|
-
cpy1: number,
|
|
448
|
-
cpx2: number,
|
|
449
|
-
cpy2: number,
|
|
450
442
|
x2: number,
|
|
451
443
|
y2: number
|
|
452
444
|
): [number, number];
|
|
453
445
|
```
|
|
454
446
|
|
|
455
|
-
#####
|
|
447
|
+
##### quadraticBezier(t, x1, y1, cpx, cpy, x2, y2)
|
|
456
448
|
|
|
457
|
-
|
|
449
|
+
Interpolate a point on Quadratic Bézier curve.
|
|
458
450
|
|
|
451
|
+
- `t`: Normalized time value to interpolate.
|
|
459
452
|
- `x1`: X-axis coordinate of the start point.
|
|
460
453
|
- `y1`: Y-axis coordinate of the start point.
|
|
461
|
-
- `
|
|
462
|
-
- `
|
|
463
|
-
- `cpx2`: X-axis coordinate of the second control point.
|
|
464
|
-
- `cpy2`: Y-axis coordinate of the second control point.
|
|
454
|
+
- `cpx`: X-axis coordinate of the control point.
|
|
455
|
+
- `cpy`: Y-axis coordinate of the control point.
|
|
465
456
|
- `x2`: X-axis coordinate of the end point.
|
|
466
457
|
- `y2`: Y-axis coordinate of the end point.
|
|
467
458
|
|
|
468
459
|
```ts
|
|
469
|
-
|
|
460
|
+
quadraticBezier(
|
|
461
|
+
t: number,
|
|
470
462
|
x1: number,
|
|
471
463
|
y1: number,
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
cpx2: number,
|
|
475
|
-
cpy2: number,
|
|
464
|
+
cpx: number,
|
|
465
|
+
cpy: number,
|
|
476
466
|
x2: number,
|
|
477
467
|
y2: number
|
|
478
|
-
): number;
|
|
468
|
+
): [number, number];
|
|
479
469
|
```
|
|
480
470
|
|
|
481
|
-
#####
|
|
471
|
+
##### cubicBezier(t, x1, y1, cp1x, cp1y, cp2x, cp2y, x2, y2)
|
|
482
472
|
|
|
483
|
-
Interpolate a point on
|
|
473
|
+
Interpolate a point on Cubic Bézier curve.
|
|
484
474
|
|
|
485
475
|
- `t`: Normalized time value to interpolate.
|
|
486
476
|
- `x1`: X-axis coordinate of the start point.
|
|
487
477
|
- `y1`: Y-axis coordinate of the start point.
|
|
488
|
-
- `
|
|
489
|
-
- `
|
|
478
|
+
- `cp1x`: X-axis coordinate of the first control point.
|
|
479
|
+
- `cp1y`: Y-axis coordinate of the first control point.
|
|
480
|
+
- `cp2x`: X-axis coordinate of the second control point.
|
|
481
|
+
- `cp2y`: Y-axis coordinate of the second control point.
|
|
490
482
|
- `x2`: X-axis coordinate of the end point.
|
|
491
483
|
- `y2`: Y-axis coordinate of the end point.
|
|
492
484
|
|
|
493
485
|
```ts
|
|
494
|
-
|
|
486
|
+
cubicBezier(
|
|
495
487
|
t: number,
|
|
496
488
|
x1: number,
|
|
497
489
|
y1: number,
|
|
498
|
-
|
|
499
|
-
|
|
490
|
+
cp1x: number,
|
|
491
|
+
cp1y: number,
|
|
492
|
+
cp2x: number,
|
|
493
|
+
cp2y: number,
|
|
500
494
|
x2: number,
|
|
501
495
|
y2: number
|
|
502
496
|
): [number, number];
|
|
503
497
|
```
|
|
504
498
|
|
|
505
|
-
#####
|
|
499
|
+
##### catmullRom(t, x1, y1, cp1x, cpy1, cp2x, cp2y, x2, y2)
|
|
506
500
|
|
|
507
|
-
|
|
501
|
+
Interpolate a point on a Catmull-Rom spline.
|
|
508
502
|
|
|
503
|
+
- `t`: Normalized time value to interpolate.
|
|
509
504
|
- `x1`: X-axis coordinate of the start point.
|
|
510
505
|
- `y1`: Y-axis coordinate of the start point.
|
|
511
|
-
- `
|
|
512
|
-
- `
|
|
506
|
+
- `cp1x`: X-axis coordinate of the first control point.
|
|
507
|
+
- `cp1y`: Y-axis coordinate of the first control point.
|
|
508
|
+
- `cp2x`: X-axis coordinate of the second control point.
|
|
509
|
+
- `cp2y`: Y-axis coordinate of the second control point.
|
|
513
510
|
- `x2`: X-axis coordinate of the end point.
|
|
514
511
|
- `y2`: Y-axis coordinate of the end point.
|
|
515
512
|
|
|
516
513
|
```ts
|
|
517
|
-
|
|
514
|
+
catmullRom(
|
|
515
|
+
t: number,
|
|
518
516
|
x1: number,
|
|
519
517
|
y1: number,
|
|
520
|
-
|
|
521
|
-
|
|
518
|
+
cp1x: number,
|
|
519
|
+
cp1y: number,
|
|
520
|
+
cp2x: number,
|
|
521
|
+
cp2y: number,
|
|
522
522
|
x2: number,
|
|
523
523
|
y2: number
|
|
524
|
-
): number;
|
|
524
|
+
): [number, number];
|
|
525
525
|
```
|
|
526
526
|
|
|
527
|
-
#####
|
|
527
|
+
##### ellipse(t, cx, cy, rx, ry, rotation, startAngle, endAngle, counterclockwise)
|
|
528
528
|
|
|
529
529
|
Interpolate a point on an elliptical arc.
|
|
530
530
|
|
|
531
531
|
- `t`: Normalized time value to interpolate.
|
|
532
|
-
- `
|
|
533
|
-
- `
|
|
534
|
-
- `x2`: X-axis coordinate of the ending point of the arc.
|
|
535
|
-
- `y2`: Y-axis coordinate of the ending point of the arc.
|
|
532
|
+
- `cx`: X-axis coordinate of the center of the ellipse.
|
|
533
|
+
- `cy`: Y-axis coordinate of the center of the ellipse.
|
|
536
534
|
- `rx`: X-radius of the ellipse.
|
|
537
535
|
- `ry`: Y-radius of the ellipse.
|
|
538
|
-
- `
|
|
539
|
-
- `[
|
|
540
|
-
- `[
|
|
536
|
+
- `[rotation=0]`: Rotation angle of the ellipse (in radians), counterclockwise from the positive X-axis.
|
|
537
|
+
- `[startAngle=0]`: Start angle of the arc (in radians).
|
|
538
|
+
- `[endAngle=TWO_PI]`: Rotation angle of the arc (in radians).
|
|
539
|
+
- `[counterclockwise=false]`: Flag indicating the direction of the arc.
|
|
541
540
|
|
|
542
541
|
```ts
|
|
543
|
-
|
|
542
|
+
ellipse(
|
|
544
543
|
t: number,
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
x2: number,
|
|
548
|
-
y2: number,
|
|
544
|
+
cx: number,
|
|
545
|
+
cy: number,
|
|
549
546
|
rx: number,
|
|
550
547
|
ry: number,
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
548
|
+
rotation?: number,
|
|
549
|
+
startAngle?: number,
|
|
550
|
+
endAngle?: number,
|
|
551
|
+
counterclockwise?: boolean
|
|
554
552
|
): [number, number];
|
|
555
553
|
```
|
|
556
554
|
|
|
557
|
-
#####
|
|
555
|
+
##### arc(t, cx, cy, radius, startAngle, endAngle, counterclockwise)
|
|
558
556
|
|
|
559
|
-
|
|
557
|
+
Interpolate a point on a circular arc.
|
|
560
558
|
|
|
561
|
-
- `
|
|
562
|
-
- `
|
|
563
|
-
- `
|
|
564
|
-
- `
|
|
565
|
-
- `
|
|
566
|
-
- `
|
|
567
|
-
- `
|
|
568
|
-
- `[largeArc]`: Flag indicating whether to draw the larger of the two possible arcs.
|
|
569
|
-
- `[clockwise]`: Flag indicating the direction of the arc.
|
|
559
|
+
- `t`: Normalized time value to interpolate.
|
|
560
|
+
- `cx`: X-axis coordinate of the center of the circle.
|
|
561
|
+
- `cy`: Y-axis coordinate of the center of the circle.
|
|
562
|
+
- `radius`: Radius of the circle.
|
|
563
|
+
- `[startAngle]`: Start angle of the arc (in radians).
|
|
564
|
+
- `[endAngle]`: End angle of the arc (in radians).
|
|
565
|
+
- `[counterclockwise=false]`: Flag indicating the direction of the arc.
|
|
570
566
|
|
|
571
567
|
```ts
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
clockwise?: boolean
|
|
582
|
-
): number;
|
|
568
|
+
arc(
|
|
569
|
+
t: number,
|
|
570
|
+
cx: number,
|
|
571
|
+
cy: number,
|
|
572
|
+
radius: number,
|
|
573
|
+
startAngle?: number,
|
|
574
|
+
endAngle?: number,
|
|
575
|
+
counterclockwise?: boolean
|
|
576
|
+
): [number, number];
|
|
583
577
|
```
|
|
584
578
|
|
|
585
|
-
|
|
579
|
+
##### isCoincident(x1, y1, x2, y2)
|
|
580
|
+
|
|
581
|
+
Check if two points are coincident.
|
|
582
|
+
|
|
583
|
+
- `x1`: X-axis coordinate of the first point.
|
|
584
|
+
- `y1`: Y-axis coordinate of the first point.
|
|
585
|
+
- `x2`: X-axis coordinate of the second point.
|
|
586
|
+
- `y2`: Y-axis coordinate of the second point.
|
|
587
|
+
|
|
588
|
+
```ts
|
|
589
|
+
isCoincident(x1: number, y1: number, x2: number, y2: number): boolean;
|
|
590
|
+
```
|
|
591
|
+
|
|
592
|
+
##### isCollinear(x1, y1, x2, y2, x3, y3)
|
|
586
593
|
|
|
587
|
-
|
|
594
|
+
Check if 3 points are collinear.
|
|
595
|
+
|
|
596
|
+
- `x1`: X-axis coordinate of the first point.
|
|
597
|
+
- `y1`: Y-axis coordinate of the first point.
|
|
598
|
+
- `x2`: X-axis coordinate of the second point.
|
|
599
|
+
- `y2`: Y-axis coordinate of the second point.
|
|
600
|
+
- `x3`: Y-axis coordinate of the third point.
|
|
601
|
+
- `y3`: Y-axis coordinate of the third point.
|
|
602
|
+
|
|
603
|
+
```ts
|
|
604
|
+
isCollinear(x1: number, y1: number, x2: number, y2: number, x3: number, y3: number): boolean;
|
|
605
|
+
```
|
|
606
|
+
|
|
607
|
+
#### Fit
|
|
588
608
|
|
|
589
609
|
```ts
|
|
590
610
|
type FitInput = {
|
|
@@ -944,7 +964,7 @@ Produce a random 2D point around the perimiter of a unit circle.
|
|
|
944
964
|
- `[target]`: Target vector.
|
|
945
965
|
|
|
946
966
|
```ts
|
|
947
|
-
onCircle(radius?: number, target?:
|
|
967
|
+
onCircle(radius?: number, target?: [number, number]): [number, number];
|
|
948
968
|
```
|
|
949
969
|
|
|
950
970
|
##### insideCircle(radius)
|
|
@@ -955,7 +975,7 @@ Produce a random 2D point inside a unit circle.
|
|
|
955
975
|
- `[target]` Target vector.
|
|
956
976
|
|
|
957
977
|
```ts
|
|
958
|
-
insideCircle(radius?: number, target?:
|
|
978
|
+
insideCircle(radius?: number, target?: [number, number]): [number, number];
|
|
959
979
|
```
|
|
960
980
|
|
|
961
981
|
##### onSphere(radius)
|
|
@@ -966,7 +986,7 @@ Produce a random 3D point on the surface of a unit sphere.
|
|
|
966
986
|
- `[target]`: Target vector.
|
|
967
987
|
|
|
968
988
|
```ts
|
|
969
|
-
onSphere(radius?: number, target?:
|
|
989
|
+
onSphere(radius?: number, target?: [number, number, number]): [number, number, number];
|
|
970
990
|
```
|
|
971
991
|
|
|
972
992
|
##### insideSphere(radius)
|
|
@@ -977,7 +997,7 @@ Produce a random 3D point inside a unit sphere.
|
|
|
977
997
|
- `[target]`: Target vector.
|
|
978
998
|
|
|
979
999
|
```ts
|
|
980
|
-
insideSphere(radius?: number, target?:
|
|
1000
|
+
insideSphere(radius?: number, target?: [number, number, number]): [number, number, number];
|
|
981
1001
|
```
|
|
982
1002
|
|
|
983
1003
|
### Pseudo-Random Number Generator (PRNG)
|
|
@@ -1299,6 +1319,605 @@ removeTrailingSlash(path: string): string;
|
|
|
1299
1319
|
|
|
1300
1320
|
## Utility classes
|
|
1301
1321
|
|
|
1322
|
+
Utility classes for manipulating curves.
|
|
1323
|
+
|
|
1324
|
+
### Curve <a id="curve"></a>
|
|
1325
|
+
|
|
1326
|
+
Utility abstract class for manipulating curves.
|
|
1327
|
+
|
|
1328
|
+
- [new Curve()](#curve)
|
|
1329
|
+
- [.arcLengthDivisions](#curve-arc-length-divisions): `number`
|
|
1330
|
+
- [.needsUpdate](#curve-needs-update): `boolean`
|
|
1331
|
+
- [.getPoint(t)](#curve-get-point-method): `[number, number]`
|
|
1332
|
+
- [.getPointAt(u)](#curve-get-point-at-method): `[number, number]`
|
|
1333
|
+
- [.getPoints(divisions)](#curve-get-points-method): `Array<[number, number]>`
|
|
1334
|
+
- [.getSpacedPoints(divisions)](#curve-get-spaced-points-method): `Array<[number, number]>`
|
|
1335
|
+
- [.getLengths()](#curve-get-length-method): `number`
|
|
1336
|
+
- [.getLengths()](#curve-get-lengths-method): `number[]`
|
|
1337
|
+
- [.updateArcLengths()](#curve-update-arc-lengths-method): `void`
|
|
1338
|
+
- [.getUtoTmapping(t, targetArcLength)](#curve-get-u-to-t-mapping-method): `number`
|
|
1339
|
+
- [.getTangent(t)](#curve-get-tangent-method): `[number, number]`
|
|
1340
|
+
- [.getTangentAt(u)](#curve-get-tangent-at-method): `[number, number]`
|
|
1341
|
+
- `static` [.isClosed(points)](#curve-static-is-closed-method): `boolean`
|
|
1342
|
+
|
|
1343
|
+
#### Properties
|
|
1344
|
+
|
|
1345
|
+
##### arcLengthDivisions <a id="curve-arc-length-divisions"></a>
|
|
1346
|
+
|
|
1347
|
+
Amount of divisions when calculating the cumulative segment lengths of a curve.
|
|
1348
|
+
|
|
1349
|
+
```ts
|
|
1350
|
+
Curve.arcLengthDivisions: number;
|
|
1351
|
+
```
|
|
1352
|
+
|
|
1353
|
+
##### needsUpdate <a id="curve-needs-update"></a>
|
|
1354
|
+
|
|
1355
|
+
Must be set to `true` if the curve parameters have changed.
|
|
1356
|
+
|
|
1357
|
+
```ts
|
|
1358
|
+
Curve.needsUpdate: boolean;
|
|
1359
|
+
```
|
|
1360
|
+
|
|
1361
|
+
#### Methods
|
|
1362
|
+
|
|
1363
|
+
##### getPoint(t) <a id="curve-get-point-method"></a>
|
|
1364
|
+
|
|
1365
|
+
Interpolate a point on the curve.
|
|
1366
|
+
|
|
1367
|
+
- `u`: Normalized time value to interpolate.
|
|
1368
|
+
|
|
1369
|
+
```ts
|
|
1370
|
+
Curve.getPoint(t: number): [number, number];
|
|
1371
|
+
```
|
|
1372
|
+
|
|
1373
|
+
##### getPointAt(u) <a id="curve-get-point-at-method"></a>
|
|
1374
|
+
|
|
1375
|
+
Interpolate a point on the curve.
|
|
1376
|
+
|
|
1377
|
+
- `u`: Normalized position value to interpolate.
|
|
1378
|
+
|
|
1379
|
+
```ts
|
|
1380
|
+
Curve.getPointAt(u: number): [number, number];
|
|
1381
|
+
```
|
|
1382
|
+
|
|
1383
|
+
##### getPoints(divisions) <a id="curve-get-points-method"></a>
|
|
1384
|
+
|
|
1385
|
+
Compute the curve shape into an array of points.
|
|
1386
|
+
|
|
1387
|
+
- `[divisions=5]`: Number of divisions.
|
|
1388
|
+
|
|
1389
|
+
```ts
|
|
1390
|
+
Curve.getPoints(divisions?: number): Array<[number, number]>;
|
|
1391
|
+
```
|
|
1392
|
+
|
|
1393
|
+
##### getSpacedPoints(divisions) <a id="curve-get-spaced-points-method"></a>
|
|
1394
|
+
|
|
1395
|
+
Compute the curve shape into an array of equi-spaced points across the entire curve.
|
|
1396
|
+
|
|
1397
|
+
- `[divisions=5]`: Number of divisions.
|
|
1398
|
+
|
|
1399
|
+
```ts
|
|
1400
|
+
Curve.getSpacedPoints(divisions?: number): Array<[number, number]>;
|
|
1401
|
+
```
|
|
1402
|
+
|
|
1403
|
+
##### getLength() <a id="curve-get-lengt-methodh"></a>
|
|
1404
|
+
|
|
1405
|
+
Compute the total arc length of the curve.
|
|
1406
|
+
|
|
1407
|
+
```ts
|
|
1408
|
+
Curve.getLength(): number;
|
|
1409
|
+
```
|
|
1410
|
+
|
|
1411
|
+
##### getLengths() <a id="curve-get-lengths-method"></a>
|
|
1412
|
+
|
|
1413
|
+
Compute the cumulative segment lengths of the curve.
|
|
1414
|
+
|
|
1415
|
+
- `[divisions]`: Number of divisions.
|
|
1416
|
+
|
|
1417
|
+
```ts
|
|
1418
|
+
Curve.getLengths(divisions?: number): number[];
|
|
1419
|
+
```
|
|
1420
|
+
|
|
1421
|
+
##### updateArcLengths() <a id="curve-get-point-method"></a>
|
|
1422
|
+
|
|
1423
|
+
Update the cached cumulative segment lengths.
|
|
1424
|
+
|
|
1425
|
+
```ts
|
|
1426
|
+
Curve.updateArcLengths(): void;
|
|
1427
|
+
```
|
|
1428
|
+
|
|
1429
|
+
##### getUtoTmapping(t, targetArcLength) <a id="curve-get-u-to-t)mapping-method"></a>
|
|
1430
|
+
|
|
1431
|
+
Re-map a normalized position value into normalized time.
|
|
1432
|
+
|
|
1433
|
+
- `u`: Normalized position value to interpolate.
|
|
1434
|
+
- `[targetArcLength]`: Distance on the curve.
|
|
1435
|
+
|
|
1436
|
+
```ts
|
|
1437
|
+
Curve.getUtoTmapping(u: number, targetArcLength?: number): number;
|
|
1438
|
+
```
|
|
1439
|
+
|
|
1440
|
+
##### getTangent(t) <a id="curve-get-tangent-method"></a>
|
|
1441
|
+
|
|
1442
|
+
Compute an unit vector tangent for the given normalized time value.
|
|
1443
|
+
|
|
1444
|
+
- `t`: Normalized time value.
|
|
1445
|
+
|
|
1446
|
+
```ts
|
|
1447
|
+
Curve.getTangent(t: number): [number, number];
|
|
1448
|
+
```
|
|
1449
|
+
|
|
1450
|
+
##### getTangentAt(u) <a id="curve-get-tangent-at-method"></a>
|
|
1451
|
+
|
|
1452
|
+
Compute an unit vector tangent for the given normalized position value.
|
|
1453
|
+
|
|
1454
|
+
- `u`: Normalized position value.
|
|
1455
|
+
|
|
1456
|
+
```ts
|
|
1457
|
+
Curve.getTangentAt(u: number): [number, number];
|
|
1458
|
+
```
|
|
1459
|
+
|
|
1460
|
+
##### `static` isClosed(points) <a id="curve-static-is-closed-method"></a>
|
|
1461
|
+
|
|
1462
|
+
Static method to check if given points are defining a closed curve.
|
|
1463
|
+
|
|
1464
|
+
- `points`: Points to check.
|
|
1465
|
+
|
|
1466
|
+
```ts
|
|
1467
|
+
static Curve.isClosed(points: Array<[number, number]>): boolean;
|
|
1468
|
+
```
|
|
1469
|
+
|
|
1470
|
+
### LineCurve <a id="line-curve"></a>
|
|
1471
|
+
|
|
1472
|
+
Utility class for manipulating lines.
|
|
1473
|
+
|
|
1474
|
+
[Extends Curve](#curve)
|
|
1475
|
+
|
|
1476
|
+
- [new LineCurve(x1, y1, x2, y2)](#line-curve)
|
|
1477
|
+
|
|
1478
|
+
| Parameter | Type | Default | Description |
|
|
1479
|
+
| --------- | -------- | ------- | ------------------------------------- |
|
|
1480
|
+
| x1 | `number` | | X-axis coordinate of the start point. |
|
|
1481
|
+
| y1 | `number` | | Y-axis coordinate of the start point. |
|
|
1482
|
+
| x2 | `number` | | X-axis coordinate of the end point. |
|
|
1483
|
+
| y2 | `number` | | Y-axis coordinate of the end point. |
|
|
1484
|
+
|
|
1485
|
+
### PolylineCurve <a id="polyline-curve"></a>
|
|
1486
|
+
|
|
1487
|
+
Utility class for manipulating Polyline curves.
|
|
1488
|
+
|
|
1489
|
+
[Extends Curve](#curve)
|
|
1490
|
+
|
|
1491
|
+
- [new PolylineCurve(points)](#polyline-curve)
|
|
1492
|
+
|
|
1493
|
+
| Parameter | Type | Default | Description |
|
|
1494
|
+
| --------- | ------------------------- | ------- | ----------------------------------- |
|
|
1495
|
+
| [points] | `Array<[number, number]>` | `[]` | Array of points defining the curve. |
|
|
1496
|
+
|
|
1497
|
+
### QuadraticBezierCurve <a id="quadratic-bezier-curve"></a>
|
|
1498
|
+
|
|
1499
|
+
Utility class for manipulating Quadratic Bézier curves.
|
|
1500
|
+
|
|
1501
|
+
[Extends Curve](#curve)
|
|
1502
|
+
|
|
1503
|
+
- [new QuadraticBezierCurve(x1, y1, cpx, cpy, x2, y2)](#quadratic-bezier-curve)
|
|
1504
|
+
|
|
1505
|
+
| Parameter | Type | Default | Description |
|
|
1506
|
+
| --------- | -------- | ------- | --------------------------------------- |
|
|
1507
|
+
| x1 | `number` | | X-axis coordinate of the start point. |
|
|
1508
|
+
| y1 | `number` | | Y-axis coordinate of the start point. |
|
|
1509
|
+
| cpx | `number` | | X-axis coordinate of the control point. |
|
|
1510
|
+
| cpy | `number` | | Y-axis coordinate of the control point. |
|
|
1511
|
+
| x2 | `number` | | X-axis coordinate of the end point. |
|
|
1512
|
+
| y2 | `number` | | Y-axis coordinate of the end point. |
|
|
1513
|
+
|
|
1514
|
+
### CubicBezierCurve <a id="cubic-bezier-curve"></a>
|
|
1515
|
+
|
|
1516
|
+
Utility class for manipulating Cubic Bézier curves.
|
|
1517
|
+
|
|
1518
|
+
[Extends Curve](#curve)
|
|
1519
|
+
|
|
1520
|
+
- [new CubicBezierCurve(x1, y1, cp1x, cp1y, cp2x, cp2y x2, y2)](#cubic-bezier-curve)
|
|
1521
|
+
|
|
1522
|
+
| Parameter | Type | Default | Description |
|
|
1523
|
+
| --------- | -------- | ------- | ---------------------------------------------- |
|
|
1524
|
+
| x1 | `number` | | X-axis coordinate of the start point. |
|
|
1525
|
+
| y1 | `number` | | Y-axis coordinate of the start point. |
|
|
1526
|
+
| cp1x | `number` | | X-axis coordinate of the first control point. |
|
|
1527
|
+
| cp1y | `number` | | Y-axis coordinate of the first control point. |
|
|
1528
|
+
| cp2x | `number` | | X-axis coordinate of the second control point. |
|
|
1529
|
+
| cp2y | `number` | | Y-axis coordinate of the second control point. |
|
|
1530
|
+
| x2 | `number` | | X-axis coordinate of the end point. |
|
|
1531
|
+
| y2 | `number` | | Y-axis coordinate of the end point. |
|
|
1532
|
+
|
|
1533
|
+
### CatmulRomCurve <a id="catmul-rom-curve"></a>
|
|
1534
|
+
|
|
1535
|
+
Utility class for manipulating Catmull-Rom curves.
|
|
1536
|
+
|
|
1537
|
+
[Extends Curve](#curve)
|
|
1538
|
+
|
|
1539
|
+
- [new CatmulRomCurve(x1, y1, cp1x, cp1y, cp2x, cp2y x2, y2)](#catmul-rom-bezier-curve)
|
|
1540
|
+
|
|
1541
|
+
| Parameter | Type | Default | Description |
|
|
1542
|
+
| --------- | -------- | ------- | ---------------------------------------------- |
|
|
1543
|
+
| x1 | `number` | | X-axis coordinate of the start point. |
|
|
1544
|
+
| y1 | `number` | | Y-axis coordinate of the start point. |
|
|
1545
|
+
| cp1x | `number` | | X-axis coordinate of the first control point. |
|
|
1546
|
+
| cp1y | `number` | | Y-axis coordinate of the first control point. |
|
|
1547
|
+
| cp2x | `number` | | X-axis coordinate of the second control point. |
|
|
1548
|
+
| cp2y | `number` | | Y-axis coordinate of the second control point. |
|
|
1549
|
+
| x2 | `number` | | X-axis coordinate of the end point. |
|
|
1550
|
+
| y2 | `number` | | Y-axis coordinate of the end point. |
|
|
1551
|
+
|
|
1552
|
+
### SplineCurve <a id="spline-curve"></a>
|
|
1553
|
+
|
|
1554
|
+
Utility class for manipulating Spline curves.
|
|
1555
|
+
|
|
1556
|
+
[Extends Curve](#curve)
|
|
1557
|
+
|
|
1558
|
+
- [new SplineCurve(points)](#spline-curve)
|
|
1559
|
+
|
|
1560
|
+
| Parameter | Type | Default | Description |
|
|
1561
|
+
| --------- | ------------------------- | ------- | ----------------------------------- |
|
|
1562
|
+
| [points] | `Array<[number, number]>` | `[]` | Array of points defining the curve. |
|
|
1563
|
+
|
|
1564
|
+
### EllipseCurve <a id="ellipse-curve"></a>
|
|
1565
|
+
|
|
1566
|
+
Utility class for manipulating Ellipse curves.
|
|
1567
|
+
|
|
1568
|
+
[Extends Curve](#curve)
|
|
1569
|
+
|
|
1570
|
+
- [new EllipseCurve(cx, cy, rx, ry, rotation, startAngle, endAngle, counterclockwise)](#ellipse-curve)
|
|
1571
|
+
|
|
1572
|
+
| Parameter | Type | Default | Description |
|
|
1573
|
+
| ------------------ | --------- | ------- | -------------------------------------------------------------------------------------- |
|
|
1574
|
+
| cx | `number` | | X-axis coordinate of the center of the ellipse. |
|
|
1575
|
+
| cy | `number` | | Y-axis coordinate of the center of the ellipse. |
|
|
1576
|
+
| rx | `number` | | X-radius of the ellipse. |
|
|
1577
|
+
| ry | `number` | | Y-radius of the ellipse. |
|
|
1578
|
+
| [rotation] | `number` | | Rotation angle of the ellipse (in radians), counterclockwise from the positive X-axis. |
|
|
1579
|
+
| [startAngle] | `number` | | Rotation angle of the arc (in radians). |
|
|
1580
|
+
| [endAngle] | `number` | | Rotation angle of the arc (in radians). |
|
|
1581
|
+
| [counterclockwise] | `boolean` | | Flag indicating the direction of the arc. |
|
|
1582
|
+
|
|
1583
|
+
### ArcCurve <a id="arc-curve"></a>
|
|
1584
|
+
|
|
1585
|
+
Utility class for manipulating Arc curves.
|
|
1586
|
+
|
|
1587
|
+
[Extends Curve](#curve)
|
|
1588
|
+
|
|
1589
|
+
- [new ArcCurve(cx, cy, radius, startAngle, endAngle, counterclockwise)](#arc-curve)
|
|
1590
|
+
|
|
1591
|
+
| Parameter | Type | Default | Description |
|
|
1592
|
+
| ------------------ | --------- | ------- | ---------------------------------------------- |
|
|
1593
|
+
| cx | `number` | | X-axis coordinate of the center of the circle. |
|
|
1594
|
+
| cy | `number` | | Y-axis coordinate of the center of the circle. |
|
|
1595
|
+
| radius | `number` | | X-radius of the circle. |
|
|
1596
|
+
| [startAngle] | `number` | | Rotation angle of the arc (in radians). |
|
|
1597
|
+
| [endAngle] | `number` | | Rotation angle of the arc (in radians). |
|
|
1598
|
+
| [counterclockwise] | `boolean` | | Flag indicating the direction of the arc. |
|
|
1599
|
+
|
|
1600
|
+
### PathCurve <a id="path-curve"></a>
|
|
1601
|
+
|
|
1602
|
+
Utility class for manipulating connected curves.
|
|
1603
|
+
|
|
1604
|
+
[Extends Curve](#curve)
|
|
1605
|
+
|
|
1606
|
+
- [new PathCurve()](#path-curve)
|
|
1607
|
+
- [.curves](#path-curve-curves): `Curve[]`
|
|
1608
|
+
- [.points](#path-curve-points): `Array<number, number>`
|
|
1609
|
+
- [.autoClose](#path-curve-auto-close): `boolean`
|
|
1610
|
+
- [.add()](#path-curve-add-method): `void`
|
|
1611
|
+
- [.getCurveLengths()](#path-curve-get-curve-lengths-method): `number[]`
|
|
1612
|
+
- [.closePath()](#path-curve-close-path-method): `void`
|
|
1613
|
+
|
|
1614
|
+
#### Properties
|
|
1615
|
+
|
|
1616
|
+
##### curves <a id="path-curve-curves"></a>
|
|
1617
|
+
|
|
1618
|
+
Array of curves composing the path.
|
|
1619
|
+
|
|
1620
|
+
```ts
|
|
1621
|
+
PathCurve.curves: Curve[];
|
|
1622
|
+
```
|
|
1623
|
+
|
|
1624
|
+
##### points <a id="path-curve-points"></a>
|
|
1625
|
+
|
|
1626
|
+
Array of points composing the path.
|
|
1627
|
+
|
|
1628
|
+
```ts
|
|
1629
|
+
PathCurve.points: Array<[number, number]>;
|
|
1630
|
+
```
|
|
1631
|
+
|
|
1632
|
+
##### autoClose <a id="path-curve-auto-close"></a>
|
|
1633
|
+
|
|
1634
|
+
```ts
|
|
1635
|
+
PathCurve.autoClose: boolean;
|
|
1636
|
+
```
|
|
1637
|
+
|
|
1638
|
+
#### Methods
|
|
1639
|
+
|
|
1640
|
+
##### add <a id="path-curve-add-method"></a>
|
|
1641
|
+
|
|
1642
|
+
Add a curve to this curve path.
|
|
1643
|
+
|
|
1644
|
+
- `curve`: Curve to add.
|
|
1645
|
+
|
|
1646
|
+
```ts
|
|
1647
|
+
PathCurve.add(curve: Curve): void;
|
|
1648
|
+
```
|
|
1649
|
+
|
|
1650
|
+
##### getCurveLengths <a id="path-curve-get-curve-lengths-method"></a>
|
|
1651
|
+
|
|
1652
|
+
Compute the cumulative curve lengths of the curve path.
|
|
1653
|
+
|
|
1654
|
+
```ts
|
|
1655
|
+
PathCurve.getCurveLengths(): number[];
|
|
1656
|
+
```
|
|
1657
|
+
|
|
1658
|
+
##### closePath <a id="path-curve-close-path-method"></a>
|
|
1659
|
+
|
|
1660
|
+
Add a line curve to close the curve path.
|
|
1661
|
+
|
|
1662
|
+
```ts
|
|
1663
|
+
PathCurve.closePath(): void;
|
|
1664
|
+
```
|
|
1665
|
+
|
|
1666
|
+
### Path <a id="path"></a>
|
|
1667
|
+
|
|
1668
|
+
Utility class for manipulating paths.
|
|
1669
|
+
It works by serializing 2D Canvas API to SVG path data.
|
|
1670
|
+
|
|
1671
|
+
[Extends PathCurve](#path-curve)
|
|
1672
|
+
|
|
1673
|
+
- [new Path()](#path)
|
|
1674
|
+
- [.currentPosition](#path-current-position): `[number, number]`
|
|
1675
|
+
- [.setFromPoints(points)](#path-set-from-points-method): `this`
|
|
1676
|
+
- [.moveTo(x, y)](#path-move-to-method): `this`
|
|
1677
|
+
- [.lineTo(x, y)](#path-line-to-method): `this`
|
|
1678
|
+
- [.polylineTo(points)](#path-polyline-to-method): `this`
|
|
1679
|
+
- [.arcTo(x1, y1, x2, y2, radius)](#path-arc-to-method): `this`
|
|
1680
|
+
- [.quadraticCurveTo(cpx, cpy, x2, y2)](#path-quadratic-curve-to-method): `this`
|
|
1681
|
+
- [.bezierCurveTo(cp1x, cp1y, cp2x, cp2y, x2, y2)](#path-bezier-curve-to-method): `this`
|
|
1682
|
+
- [.catmulRomCurveTo(cp1x, cp1y, cp2x, cp2y, x2, y2)](#path-catmul-rom-to-method): `this`
|
|
1683
|
+
- [.splineTo(points)](#path-spline-to-method): `this`
|
|
1684
|
+
- [.ellipse(cx, cy, rx, ry, rotation, startAngle, endAngle, counterclockwise)](#path-ellipse-method): `this`
|
|
1685
|
+
- [.arc(cx, cy, radius, startAngle, endAngle, counterclockwise)](#path-arc-method): `this`
|
|
1686
|
+
- [.rect(x, y, width, height)](#path-rect-method): `this`
|
|
1687
|
+
- [.roundRect(x, y, width, height, radius)](#path-round-rect-method): `this`
|
|
1688
|
+
- [.closePath()](#path-close-path-method): `this`
|
|
1689
|
+
|
|
1690
|
+
#### Properties
|
|
1691
|
+
|
|
1692
|
+
##### currentPosition <a id="path-current-position"></a>
|
|
1693
|
+
|
|
1694
|
+
Path current offset position.
|
|
1695
|
+
|
|
1696
|
+
```ts
|
|
1697
|
+
Path.currentPosition: [number, number];
|
|
1698
|
+
```
|
|
1699
|
+
|
|
1700
|
+
#### Methods
|
|
1701
|
+
|
|
1702
|
+
##### setFromPoints(points) <a id="path-set-from-points-method"></a>
|
|
1703
|
+
|
|
1704
|
+
Create a path from the given list of points.
|
|
1705
|
+
|
|
1706
|
+
- `points`: Array of points defining the path.
|
|
1707
|
+
- `[type]`: Type of curve used for creating the path.
|
|
1708
|
+
|
|
1709
|
+
```ts
|
|
1710
|
+
Path.setFromPoints(points: Array<[number, number]>, type?: 'lines' | 'polyline' | 'spline'): this;
|
|
1711
|
+
```
|
|
1712
|
+
|
|
1713
|
+
##### moveTo(x, y) <a id="path-move-to-method"></a>
|
|
1714
|
+
|
|
1715
|
+
Move `currentPosition` to the coordinates specified by `x` and `y`.
|
|
1716
|
+
|
|
1717
|
+
- `x`: X-axis coordinate of the point.
|
|
1718
|
+
- `y`: Y-axis coordinate of the point.
|
|
1719
|
+
|
|
1720
|
+
```ts
|
|
1721
|
+
Path.moveTo(x: number, y: number): this;
|
|
1722
|
+
```
|
|
1723
|
+
|
|
1724
|
+
##### lineTo(x, y) <a id="path-line-to-method"></a>
|
|
1725
|
+
|
|
1726
|
+
Draw a line from the current position to the position specified by `x` and `y`.
|
|
1727
|
+
Add an instance of [LineCurve](#line-curve) to the path.
|
|
1728
|
+
|
|
1729
|
+
- `x`: X-axis coordinate of the point.
|
|
1730
|
+
- `y`: Y-axis coordinate of the point.
|
|
1731
|
+
|
|
1732
|
+
```ts
|
|
1733
|
+
Path.lineTo(x: number, y: number): this;
|
|
1734
|
+
```
|
|
1735
|
+
|
|
1736
|
+
##### polylineTo(points) <a id="path-polyline-to-method"></a>
|
|
1737
|
+
|
|
1738
|
+
Draw a Polyline curve from the current position through the given points.
|
|
1739
|
+
Add an instance of [PolylineCurve](#polyline-curve) to the path.
|
|
1740
|
+
|
|
1741
|
+
- `points`: Array of points defining the curve.
|
|
1742
|
+
|
|
1743
|
+
```ts
|
|
1744
|
+
Path.polylineTo(points: Array<[number, number]>): this;
|
|
1745
|
+
```
|
|
1746
|
+
|
|
1747
|
+
##### arcTo(x1, y1, x2, y2, radius) <a id="path-arc-to-method"></a>
|
|
1748
|
+
|
|
1749
|
+
Draw an Arc curve from the current position, tangential to the 2 segments created by both control points
|
|
1750
|
+
Add an instance of [ArcCurve](#arc-curve) to the path.
|
|
1751
|
+
|
|
1752
|
+
- `x1`: X-axis coordinate of the first control point.
|
|
1753
|
+
- `y1`: Y-axis coordinate of the first control point.
|
|
1754
|
+
- `x2`: X-axis coordinate of the second control point.
|
|
1755
|
+
- `y2`: Y-axis coordinate of the second control point.
|
|
1756
|
+
- `radius`: Arc radius (Must be non-negative).
|
|
1757
|
+
|
|
1758
|
+
```ts
|
|
1759
|
+
Path.arcTo(x1: number, y1: number, x2: number, y2: number, radius: number): this;
|
|
1760
|
+
```
|
|
1761
|
+
|
|
1762
|
+
##### quadraticCurveTo(cpx, cpy, x2, y2) <a id="path-quadratic-curve-to-method"></a>
|
|
1763
|
+
|
|
1764
|
+
Draw a Quadratic Bézier curve from the current position to the end point specified by `x` and `y`, using the control point specified by `cpx` and `cpy`.
|
|
1765
|
+
Add an instance of [QuadraticBezierCurve](#quadratic-bezier-curve) to the path.
|
|
1766
|
+
|
|
1767
|
+
- `cpx`: X-axis coordinate of the control point.
|
|
1768
|
+
- `cpy`: Y-axis coordinate of the control point.
|
|
1769
|
+
- `x2`: X-axis coordinate of the end point.
|
|
1770
|
+
- `y2`: Y-axis coordinate of the end point.
|
|
1771
|
+
|
|
1772
|
+
```ts
|
|
1773
|
+
Path.quadraticCurveTo(cpx: number, cpy: number, x2: number, y2: number): this;
|
|
1774
|
+
```
|
|
1775
|
+
|
|
1776
|
+
##### bezierCurveTo(cp1x, cp1y, cp2x, cp2y, x2, y2) <a id="path-bezier-curve-to-method"></a>
|
|
1777
|
+
|
|
1778
|
+
Draw a Cubic Bézier curve from the current position to the end point specified by `x` and `y`, using the control point specified by (`cp1x`, `cp1y`) and (`cp2x`, `cp2y`).
|
|
1779
|
+
Add an instance of [CubicBezierCurve](#cubic-bezier-curve) to the path.
|
|
1780
|
+
|
|
1781
|
+
- `cp1x`: X-axis coordinate of the first control point.
|
|
1782
|
+
- `cp1y`: Y-axis coordinate of the first control point.
|
|
1783
|
+
- `cp2x`: X-axis coordinate of the second control point.
|
|
1784
|
+
- `cp2y`: Y-axis coordinate of the second control point.
|
|
1785
|
+
- `x2`: X-axis coordinate of the end point.
|
|
1786
|
+
- `y2`: Y-axis coordinate of the end point.
|
|
1787
|
+
|
|
1788
|
+
```ts
|
|
1789
|
+
Path.bezierCurveTo(cp1x: number, cp1y: number, cp2x: number, cp2y: number, x2: number, y2: number): this;
|
|
1790
|
+
```
|
|
1791
|
+
|
|
1792
|
+
##### catmulRomCurveTo(cp1x, cp1y, cp2x, cp2y, x2, y2) <a id="path-catmul-rom-curve-to-method"></a>
|
|
1793
|
+
|
|
1794
|
+
Draw a Catmul-Rom curve from the current position to the end point specified by `x` and `y`, using the control points specified by (`cp1x`, `cp1y`) and (`cp2x`, `cp2y`).
|
|
1795
|
+
Add an instance of [CatmullRomCurve](#catmul-rom-curve) to the path.
|
|
1796
|
+
|
|
1797
|
+
- `cp1x`: X-axis coordinate of the first control point.
|
|
1798
|
+
- `cp1y`: Y-axis coordinate of the first control point.
|
|
1799
|
+
- `cp2x`: X-axis coordinate of the second control point.
|
|
1800
|
+
- `cp2y`: Y-axis coordinate of the second control point.
|
|
1801
|
+
- `x2`: X-axis coordinate of the end point.
|
|
1802
|
+
- `y2`: Y-axis coordinate of the end point.
|
|
1803
|
+
|
|
1804
|
+
```ts
|
|
1805
|
+
Path.catmulRomCurveTo(cp1x: number, cp1y: number, cp2x: number, cp2y: number, x2: number, y2: number): this;
|
|
1806
|
+
```
|
|
1807
|
+
|
|
1808
|
+
##### splineTo(points) <a id="path-spline-to-method"></a>
|
|
1809
|
+
|
|
1810
|
+
Draw a Spline curve from the current position through the given points.
|
|
1811
|
+
Add an instance of [SplineCurve](#spline-curve) to the path.
|
|
1812
|
+
|
|
1813
|
+
- `points`: Array of points defining the curve.
|
|
1814
|
+
|
|
1815
|
+
```ts
|
|
1816
|
+
Path.splineTo(points: Array<[number, number]>): this;
|
|
1817
|
+
```
|
|
1818
|
+
|
|
1819
|
+
##### ellipse(cx, cy, rx, ry, rotation, startAngle, endAngle, counterclockwise) <a id="path-ellipse-method"></a>
|
|
1820
|
+
|
|
1821
|
+
Draw an Ellispe curve which is centered at (`cx`, `cy`) position.
|
|
1822
|
+
Add an instance of [EllipseCurve](#ellipse-curve) to the path.
|
|
1823
|
+
|
|
1824
|
+
- `cx`: X-axis coordinate of the center of the ellipse.
|
|
1825
|
+
- `cy`: Y-axis coordinate of the center of the ellipse.
|
|
1826
|
+
- `rx`: X-radius of the ellipse.
|
|
1827
|
+
- `ry`: Y-radius of the ellipse.
|
|
1828
|
+
- `[rotation]`: Rotation angle of the ellipse (in radians), counterclockwise from the positive X-axis.
|
|
1829
|
+
- `[startAngle]`: Start angle of the arc (in radians).
|
|
1830
|
+
- `[endAngle]`: End angle of the arc (in radians).
|
|
1831
|
+
- `[counterclockwise]`: Flag indicating the direction of the arc.
|
|
1832
|
+
|
|
1833
|
+
```ts
|
|
1834
|
+
Path.ellipse(cx: number, cy: number, rx: number, ry: number, rotation?: number, startAngle?: number, endAngle?: number, counterclockwise?: boolean): this;
|
|
1835
|
+
```
|
|
1836
|
+
|
|
1837
|
+
##### arc(cx, cy, radius, startAngle, endAngle, counterclockwise) <a id="path-arc-method"></a>
|
|
1838
|
+
|
|
1839
|
+
Draw an Arc curve which is centered at (`cx`, `cy`) position.
|
|
1840
|
+
Add an instance of [ArcCurve](#arc-curve) to the path.
|
|
1841
|
+
|
|
1842
|
+
- `cx`: X-axis coordinate of the center of the circle.
|
|
1843
|
+
- `cy`: Y-axis coordinate of the center of the circle.
|
|
1844
|
+
- `radius`: Radius of the circle.
|
|
1845
|
+
- `[startAngle]`: Start angle of the arc (in radians).
|
|
1846
|
+
- `[endAngle]`: End angle of the arc (in radians).
|
|
1847
|
+
- `[counterclockwise]`: Flag indicating the direction of the arc.
|
|
1848
|
+
|
|
1849
|
+
```ts
|
|
1850
|
+
Path.arc(cx: number, cy: number, radius: number, startAngle?: number, endAngle?: number, counterclockwise?: boolean): this;
|
|
1851
|
+
```
|
|
1852
|
+
|
|
1853
|
+
##### rect(x, y, width, height) <a id="path-rect-method"></a>
|
|
1854
|
+
|
|
1855
|
+
Draw a rectangular path from the start position specified by `x` and `y` to the end position using `width` and `height`.
|
|
1856
|
+
Add an instance of [PolylineCurve](#polyline-curve) to the path.
|
|
1857
|
+
|
|
1858
|
+
- `x`: X-axis coordinate of the rectangle starting point.
|
|
1859
|
+
- `y`: Y-axis coordinate of the rectangle starting point.
|
|
1860
|
+
- `width`: Rectangle width (Positive values are to the right and negative to the left).
|
|
1861
|
+
- `height`: Rectangle height (Positive values are down, and negative are up).
|
|
1862
|
+
|
|
1863
|
+
```ts
|
|
1864
|
+
Path.rect(x: number, y: number, width: number, height: number): this;
|
|
1865
|
+
```
|
|
1866
|
+
|
|
1867
|
+
##### roundRect(x, y, width, height, radius) <a id="path-round-rect-method"></a>
|
|
1868
|
+
|
|
1869
|
+
Draw a rounded rectangular path from the start position specified by `x` and `y` to the end position using `width` and `height`.
|
|
1870
|
+
|
|
1871
|
+
- `x`: X-axis coordinate of the rectangle starting point.
|
|
1872
|
+
- `y`: Y-axis coordinate of the rectangle starting point.
|
|
1873
|
+
- `width`: Rectangle width (Positive values are to the right and negative to the left).
|
|
1874
|
+
- `height`: Rectangle height (Positive values are down, and negative are up).
|
|
1875
|
+
- `radius`: Radius of the circular arc to be used for the corners of the rectangle.
|
|
1876
|
+
|
|
1877
|
+
```ts
|
|
1878
|
+
Path.roundRect(x: number, y: number, width: number, height: number, radius: number | number[]): this;
|
|
1879
|
+
```
|
|
1880
|
+
|
|
1881
|
+
##### closePath() <a id="path-close-path-method"></a>
|
|
1882
|
+
|
|
1883
|
+
Add a line curve to close the curve path.
|
|
1884
|
+
Add an instance of [LineCurve](#line-curve) to the path.
|
|
1885
|
+
|
|
1886
|
+
```ts
|
|
1887
|
+
Path.closePath(): this;
|
|
1888
|
+
```
|
|
1889
|
+
|
|
1890
|
+
### PathSVG <a id="path-svg"></a>
|
|
1891
|
+
|
|
1892
|
+
Utility class for manipulating paths and generating SVG path.
|
|
1893
|
+
It works by serializing 2D Canvas API to SVG path data.
|
|
1894
|
+
|
|
1895
|
+
[Extends Path](#path)
|
|
1896
|
+
|
|
1897
|
+
- [new PathSVG()](#path-svg-constructor)
|
|
1898
|
+
- [.curveResolution](#path-svg-curve-resolution): `number`
|
|
1899
|
+
- [.toString()](#path-svg-to-string-method): `string`
|
|
1900
|
+
|
|
1901
|
+
#### Properties
|
|
1902
|
+
|
|
1903
|
+
##### curveResolution <a id="path-svg-curve-resolution"></a>
|
|
1904
|
+
|
|
1905
|
+
Resolution used for Catmul-Rom curve and Spline curve approximations.
|
|
1906
|
+
|
|
1907
|
+
```ts
|
|
1908
|
+
PathSVG.curveResolution: number;
|
|
1909
|
+
```
|
|
1910
|
+
|
|
1911
|
+
#### Methods
|
|
1912
|
+
|
|
1913
|
+
##### toString() <a id="path-svg-to-string-method"></a>
|
|
1914
|
+
|
|
1915
|
+
Return SVG path data string.
|
|
1916
|
+
|
|
1917
|
+
```ts
|
|
1918
|
+
PathSVG.toString(): string;
|
|
1919
|
+
```
|
|
1920
|
+
|
|
1302
1921
|
### Color scale
|
|
1303
1922
|
|
|
1304
1923
|
Utility class for generating color scales and interpolating between colors.
|
|
@@ -1314,8 +1933,8 @@ Utility class for generating color scales and interpolating between colors.
|
|
|
1314
1933
|
| --------------------- | ---------------------------------- | ----------------------- | ------------------------------------------- |
|
|
1315
1934
|
| input | `ColorRepresentation` | | Input color representation. |
|
|
1316
1935
|
| target | `ColorRepresentation` | | Target color representation. |
|
|
1317
|
-
| length
|
|
1318
|
-
| settings
|
|
1936
|
+
| [length] | `number` | `5` | Amount of colors composing the color scale. |
|
|
1937
|
+
| [settings] | `ColorScaleSettings` | `{ colorSpace: 'rgb' }` | Color scale generation settings. |
|
|
1319
1938
|
| [settings.colorSpace] | `'rgb' \| 'hsl' \| 'hsb' \| 'hcl'` | `'rgb'` | Color scale color space. |
|
|
1320
1939
|
|
|
1321
1940
|
##### HSL color scales
|
|
@@ -1413,7 +2032,7 @@ Utility class for controlling FPS calls.
|
|
|
1413
2032
|
|
|
1414
2033
|
| Parameter | Type | Default | Description |
|
|
1415
2034
|
| --------- | -------- | ------- | ----------------------- |
|
|
1416
|
-
| fps
|
|
2035
|
+
| [fps] | `number` | `30` | Frame per second limit. |
|
|
1417
2036
|
|
|
1418
2037
|
#### Properties
|
|
1419
2038
|
|
|
@@ -1437,16 +2056,25 @@ FrameRate.update(): boolean;
|
|
|
1437
2056
|
|
|
1438
2057
|
## Constants
|
|
1439
2058
|
|
|
2059
|
+
### Maths
|
|
2060
|
+
|
|
1440
2061
|
`EPSILON`
|
|
1441
2062
|
|
|
2063
|
+
### Geomery
|
|
2064
|
+
|
|
1442
2065
|
`PI`
|
|
1443
2066
|
|
|
1444
2067
|
`TWO_PI`
|
|
2068
|
+
`TAU`
|
|
1445
2069
|
|
|
1446
2070
|
`HALF_PI`
|
|
1447
2071
|
|
|
1448
2072
|
`QUARTER_PI`
|
|
1449
2073
|
|
|
2074
|
+
`TAU_EPSILON`
|
|
2075
|
+
|
|
2076
|
+
### Colors
|
|
2077
|
+
|
|
1450
2078
|
`W3CX11`
|
|
1451
2079
|
|
|
1452
2080
|
## License
|