toosoon-utils 4.0.6 → 4.1.1

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.
Files changed (45) hide show
  1. package/README.md +716 -88
  2. package/lib/constants.d.ts +2 -0
  3. package/lib/constants.js +5 -3
  4. package/lib/extras/_wip/pool.d.ts +56 -0
  5. package/lib/extras/_wip/pool.js +67 -0
  6. package/lib/{classes/color-scale.d.ts → extras/color-scale/ColorScale.d.ts} +1 -1
  7. package/lib/{classes/color-scale.js → extras/color-scale/ColorScale.js} +2 -2
  8. package/lib/extras/curves/ArcCurve.d.ts +19 -0
  9. package/lib/extras/curves/ArcCurve.js +21 -0
  10. package/lib/extras/curves/CatmulRomCurve.d.ts +62 -0
  11. package/lib/extras/curves/CatmulRomCurve.js +75 -0
  12. package/lib/extras/curves/CubicBezierCurve.d.ts +62 -0
  13. package/lib/extras/curves/CubicBezierCurve.js +75 -0
  14. package/lib/extras/curves/Curve.d.ts +95 -0
  15. package/lib/extras/curves/Curve.js +174 -0
  16. package/lib/extras/curves/EllipseCurve.d.ts +63 -0
  17. package/lib/extras/curves/EllipseCurve.js +76 -0
  18. package/lib/extras/curves/LineCurve.d.ts +51 -0
  19. package/lib/extras/curves/LineCurve.js +71 -0
  20. package/lib/extras/curves/Path.d.ts +164 -0
  21. package/lib/extras/curves/Path.js +367 -0
  22. package/lib/extras/curves/PathCurve.d.ts +69 -0
  23. package/lib/extras/curves/PathCurve.js +148 -0
  24. package/lib/extras/curves/PathSVG.d.ts +41 -0
  25. package/lib/extras/curves/PathSVG.js +135 -0
  26. package/lib/extras/curves/PolylineCurve.d.ts +27 -0
  27. package/lib/extras/curves/PolylineCurve.js +39 -0
  28. package/lib/extras/curves/QuadraticBezierCurve.d.ts +52 -0
  29. package/lib/extras/curves/QuadraticBezierCurve.js +63 -0
  30. package/lib/extras/curves/SplineCurve.d.ts +24 -0
  31. package/lib/extras/curves/SplineCurve.js +38 -0
  32. package/lib/extras/curves/index.d.ts +12 -0
  33. package/lib/extras/curves/index.js +12 -0
  34. package/lib/{classes/frame-rate.js → extras/frame-rate/FrameRate.js} +1 -1
  35. package/lib/geometry.d.ts +87 -68
  36. package/lib/geometry.js +144 -140
  37. package/lib/prng.js +2 -1
  38. package/lib/random.d.ts +13 -13
  39. package/lib/random.js +14 -14
  40. package/lib/tsconfig.tsbuildinfo +1 -1
  41. package/lib/types.d.ts +3 -10
  42. package/package.json +4 -3
  43. /package/lib/{classes/_pool.d.ts → extras/_/pool.d.ts} +0 -0
  44. /package/lib/{classes/_pool.js → extras/_/pool.js} +0 -0
  45. /package/lib/{classes/frame-rate.d.ts → extras/frame-rate/FrameRate.d.ts} +0 -0
@@ -0,0 +1,135 @@
1
+ import { EPSILON, PI, TWO_PI, TAU_EPSILON } from '../../../src/constants';
2
+ import { toDegrees } from '../../../src/geometry';
3
+ import PolylineCurve from './PolylineCurve';
4
+ import CatmullRomCurve from './CatmulRomCurve';
5
+ import SplineCurve from './SplineCurve';
6
+ import EllipseCurve from './EllipseCurve';
7
+ import ArcCurve from './ArcCurve';
8
+ import Path from './Path';
9
+ /**
10
+ * Utility class for manipulating connected curves and generating SVG path
11
+ *
12
+ * It works by serializing 2D Canvas API to SVG path data
13
+ *
14
+ * @exports
15
+ * @class PathSVG
16
+ * @extends Path
17
+ */
18
+ export default class PathSVG extends Path {
19
+ /**
20
+ * Resolution used for Catmul-Rom curve and Spline curve approximations
21
+ */
22
+ curveResolution;
23
+ constructor({ curveResolution = 10 }) {
24
+ super();
25
+ this.curveResolution = curveResolution;
26
+ }
27
+ _commands = ``;
28
+ moveTo(x, y) {
29
+ super.moveTo(x, y);
30
+ this._write(`M${x},${y}`);
31
+ return this;
32
+ }
33
+ lineTo(x, y) {
34
+ super.lineTo(x, y);
35
+ this._writeLineTo(x, y);
36
+ return this;
37
+ }
38
+ polylineTo(points) {
39
+ super.polylineTo(points);
40
+ points.forEach(([x, y]) => this._writeLineTo(x, y));
41
+ return this;
42
+ }
43
+ // public arcTo(x1: number, y1: number, x2: number, y2: number, radius: number): this {
44
+ // super.arcTo(x1, y1, x2, y2, radius);
45
+ // return this;
46
+ // }
47
+ quadraticCurveTo(cpx, cpy, x2, y2) {
48
+ super.quadraticCurveTo(cpx, cpy, x2, y2);
49
+ this._write(`Q${cpx},${cpy},${x2},${y2}`);
50
+ return this;
51
+ }
52
+ bezierCurveTo(cp1x, cp1y, cp2x, cp2y, x2, y2) {
53
+ super.bezierCurveTo(cp1x, cp1y, cp2x, cp2y, x2, y2);
54
+ this._write(`C${cp1x},${cp1y},${cp2x},${cp2y},${x2},${y2}`);
55
+ return this;
56
+ }
57
+ catmulRomCurveTo(cp1x, cp1y, cp2x, cp2y, x2, y2) {
58
+ super.catmulRomCurveTo(cp1x, cp1y, cp2x, cp2y, x2, y2);
59
+ const curve = this.curves[this.curves.length - 1];
60
+ if (curve instanceof CatmullRomCurve) {
61
+ curve.getSpacedPoints(curve.getLength() * this.curveResolution).forEach(([x, y]) => this._writeLineTo(x, y));
62
+ }
63
+ return this;
64
+ }
65
+ splineTo(points) {
66
+ super.splineTo(points);
67
+ const curve = this.curves[this.curves.length - 1];
68
+ if (curve instanceof SplineCurve) {
69
+ curve.getSpacedPoints(curve.getLength() * this.curveResolution).forEach(([x, y]) => this._writeLineTo(x, y));
70
+ }
71
+ return this;
72
+ }
73
+ ellipse(cx, cy, rx, ry, rotation = 0, startAngle = 0, endAngle = TWO_PI, counterclockwise) {
74
+ super.ellipse(cx, cy, rx, ry, rotation, startAngle, endAngle, counterclockwise);
75
+ const curve = this.curves[this.curves.length - 1];
76
+ if (curve instanceof EllipseCurve) {
77
+ this._writeArc(cx, cy, rx, ry, rotation, startAngle, endAngle, counterclockwise);
78
+ }
79
+ return this;
80
+ }
81
+ arc(cx, cy, radius, startAngle, endAngle, counterclockwise) {
82
+ super.arc(cx, cy, radius, startAngle, endAngle, counterclockwise);
83
+ const curve = this.curves[this.curves.length - 1];
84
+ if (curve instanceof ArcCurve) {
85
+ this._writeArc(cx, cy, radius, radius, 0, startAngle, endAngle, counterclockwise);
86
+ }
87
+ return this;
88
+ }
89
+ rect(x, y, width, height) {
90
+ super.rect(x, y, width, height);
91
+ const curve = this.curves[this.curves.length - 1];
92
+ if (curve instanceof PolylineCurve) {
93
+ curve.points?.forEach(([x, y]) => this._writeLineTo(x, y));
94
+ }
95
+ return this;
96
+ }
97
+ closePath() {
98
+ super.closePath();
99
+ this._write(`Z`);
100
+ return this;
101
+ }
102
+ _writeLineTo(x, y) {
103
+ this._write(`L${x},${y}`);
104
+ }
105
+ _writeArc(cx, cy, rx, ry, rotation = 0, startAngle = 0, endAngle = TWO_PI, counterclockwise) {
106
+ let deltaAngle = counterclockwise ? startAngle - endAngle : endAngle - startAngle;
107
+ if (deltaAngle < 0)
108
+ deltaAngle = (deltaAngle % TWO_PI) + TWO_PI;
109
+ const xAxisRotation = toDegrees(rotation);
110
+ const largeArcFlag = deltaAngle >= PI ? 1 : 0;
111
+ const sweepFlag = counterclockwise ? 0 : 1;
112
+ if (deltaAngle > TAU_EPSILON) {
113
+ const dx = Math.cos(startAngle) * rx;
114
+ const dy = Math.sin(startAngle) * ry;
115
+ this._write(`A${rx},${ry},${xAxisRotation},1,${sweepFlag},${cx - dx},${cy - dy}`);
116
+ this._write(`A${rx},${ry},${xAxisRotation},1,${sweepFlag},${cx + dx},${cy + dy}`);
117
+ }
118
+ else if (deltaAngle > EPSILON) {
119
+ const dx = Math.cos(endAngle) * rx;
120
+ const dy = Math.sin(endAngle) * ry;
121
+ this._write(`A${rx},${ry},${xAxisRotation},${largeArcFlag},${sweepFlag},${cx + dx},${cy + dy}`);
122
+ }
123
+ }
124
+ _write(command) {
125
+ this._commands += `${command}`;
126
+ }
127
+ /**
128
+ * Return SVG path data string
129
+ *
130
+ * @returns {string}
131
+ */
132
+ toString() {
133
+ return this._commands;
134
+ }
135
+ }
@@ -0,0 +1,27 @@
1
+ import type { Point } from '../../../src/types';
2
+ import Curve from './Curve';
3
+ /**
4
+ * Utility class for manipulating Polyline curves
5
+ *
6
+ * @exports
7
+ * @class PolylineCurve
8
+ * @extends Curve
9
+ */
10
+ export default class PolylineCurve extends Curve {
11
+ readonly type: string;
12
+ /**
13
+ * Array of points defining the curve
14
+ */
15
+ points: Point[];
16
+ /**
17
+ * @param {Point[]} [points] Array of points defining the curve
18
+ */
19
+ constructor(points?: Point[]);
20
+ /**
21
+ * Interpolate a point on the Spline curve
22
+ *
23
+ * @param {number} t Normalized time value to interpolate
24
+ * @returns {Point} Interpolated coordinates on the curve
25
+ */
26
+ getPoint(t: number): Point;
27
+ }
@@ -0,0 +1,39 @@
1
+ import { line } from '../../../src/geometry';
2
+ import Curve from './Curve';
3
+ /**
4
+ * Utility class for manipulating Polyline curves
5
+ *
6
+ * @exports
7
+ * @class PolylineCurve
8
+ * @extends Curve
9
+ */
10
+ export default class PolylineCurve extends Curve {
11
+ type = 'PolylineCurve';
12
+ /**
13
+ * Array of points defining the curve
14
+ */
15
+ points = [];
16
+ /**
17
+ * @param {Point[]} [points] Array of points defining the curve
18
+ */
19
+ constructor(points = []) {
20
+ super();
21
+ this.points = points;
22
+ }
23
+ /**
24
+ * Interpolate a point on the Spline curve
25
+ *
26
+ * @param {number} t Normalized time value to interpolate
27
+ * @returns {Point} Interpolated coordinates on the curve
28
+ */
29
+ getPoint(t) {
30
+ const points = this.points;
31
+ const p = (points.length - 1) * t;
32
+ const index = Math.floor(p);
33
+ const weight = p - index;
34
+ const p1 = points[index === 0 ? index : index - 1];
35
+ const p2 = points[index];
36
+ const point = line(weight, ...p1, ...p2);
37
+ return point;
38
+ }
39
+ }
@@ -0,0 +1,52 @@
1
+ import type { Point } from '../../../src/types';
2
+ import Curve from './Curve';
3
+ /**
4
+ * Utility class for manipulating Quadratic Bézier curves
5
+ *
6
+ * @exports
7
+ * @class QuadraticBezierCurve
8
+ * @extends Curve
9
+ */
10
+ export default class QuadraticBezierCurve extends Curve {
11
+ readonly type: string;
12
+ /**
13
+ * X-axis coordinate of the start point
14
+ */
15
+ x1: number;
16
+ /**
17
+ * Y-axis coordinate of the start point
18
+ */
19
+ y1: number;
20
+ /**
21
+ * X-axis coordinate of the control point
22
+ */
23
+ cpx: number;
24
+ /**
25
+ * Y-axis coordinate of the control point
26
+ */
27
+ cpy: number;
28
+ /**
29
+ * X-axis coordinate of the end point
30
+ */
31
+ x2: number;
32
+ /**
33
+ * Y-axis coordinate of the end point
34
+ */
35
+ y2: number;
36
+ /**
37
+ * @param {number} x1 X-axis coordinate of the start point
38
+ * @param {number} y1 Y-axis coordinate of the start point
39
+ * @param {number} cpx X-axis coordinate of the control point
40
+ * @param {number} cpy Y-axis coordinate of the control point
41
+ * @param {number} x2 X-axis coordinate of the end point
42
+ * @param {number} y2 Y-axis coordinate of the end point
43
+ */
44
+ constructor(x1: number, y1: number, cpx: number, cpy: number, x2: number, y2: number);
45
+ /**
46
+ * Interpolate a point on the Quadratic Bézier curve
47
+ *
48
+ * @param {number} t Normalized time value to interpolate
49
+ * @returns {Point} Interpolated coordinates on the curve
50
+ */
51
+ getPoint(t: number): Point;
52
+ }
@@ -0,0 +1,63 @@
1
+ import { quadraticBezier } from '../../../src/geometry';
2
+ import Curve from './Curve';
3
+ /**
4
+ * Utility class for manipulating Quadratic Bézier curves
5
+ *
6
+ * @exports
7
+ * @class QuadraticBezierCurve
8
+ * @extends Curve
9
+ */
10
+ export default class QuadraticBezierCurve extends Curve {
11
+ type = 'QuadraticBezierCurve';
12
+ /**
13
+ * X-axis coordinate of the start point
14
+ */
15
+ x1;
16
+ /**
17
+ * Y-axis coordinate of the start point
18
+ */
19
+ y1;
20
+ /**
21
+ * X-axis coordinate of the control point
22
+ */
23
+ cpx;
24
+ /**
25
+ * Y-axis coordinate of the control point
26
+ */
27
+ cpy;
28
+ /**
29
+ * X-axis coordinate of the end point
30
+ */
31
+ x2;
32
+ /**
33
+ * Y-axis coordinate of the end point
34
+ */
35
+ y2;
36
+ /**
37
+ * @param {number} x1 X-axis coordinate of the start point
38
+ * @param {number} y1 Y-axis coordinate of the start point
39
+ * @param {number} cpx X-axis coordinate of the control point
40
+ * @param {number} cpy Y-axis coordinate of the control point
41
+ * @param {number} x2 X-axis coordinate of the end point
42
+ * @param {number} y2 Y-axis coordinate of the end point
43
+ */
44
+ constructor(x1, y1, cpx, cpy, x2, y2) {
45
+ super();
46
+ this.x1 = x1;
47
+ this.y1 = y1;
48
+ this.cpx = cpx;
49
+ this.cpy = cpy;
50
+ this.x2 = x2;
51
+ this.y2 = y2;
52
+ }
53
+ /**
54
+ * Interpolate a point on the Quadratic Bézier curve
55
+ *
56
+ * @param {number} t Normalized time value to interpolate
57
+ * @returns {Point} Interpolated coordinates on the curve
58
+ */
59
+ getPoint(t) {
60
+ const point = quadraticBezier(t, this.x1, this.y1, this.cpx, this.cpy, this.x2, this.y2);
61
+ return point;
62
+ }
63
+ }
@@ -0,0 +1,24 @@
1
+ import type { Point } from '../../../src/types';
2
+ import Curve from './Curve';
3
+ /**
4
+ * Utility class for manipulating Spline curves
5
+ *
6
+ * @exports
7
+ * @class SplineCurve
8
+ * @extends Curve
9
+ */
10
+ export default class SplineCurve extends Curve {
11
+ readonly type: string;
12
+ points: Point[];
13
+ /**
14
+ * @param {Point[]} [points] Array of points defining the curve
15
+ */
16
+ constructor(points?: Point[]);
17
+ /**
18
+ * Interpolate a point on the Spline curve
19
+ *
20
+ * @param {number} t Normalized time value to interpolate
21
+ * @returns {Point} Interpolated coordinates on the curve
22
+ */
23
+ getPoint(t: number): Point;
24
+ }
@@ -0,0 +1,38 @@
1
+ import { catmullRom } from '../../../src/geometry';
2
+ import Curve from './Curve';
3
+ /**
4
+ * Utility class for manipulating Spline curves
5
+ *
6
+ * @exports
7
+ * @class SplineCurve
8
+ * @extends Curve
9
+ */
10
+ export default class SplineCurve extends Curve {
11
+ type = 'SplineCurve';
12
+ points = [];
13
+ /**
14
+ * @param {Point[]} [points] Array of points defining the curve
15
+ */
16
+ constructor(points = []) {
17
+ super();
18
+ this.points = points;
19
+ }
20
+ /**
21
+ * Interpolate a point on the Spline curve
22
+ *
23
+ * @param {number} t Normalized time value to interpolate
24
+ * @returns {Point} Interpolated coordinates on the curve
25
+ */
26
+ getPoint(t) {
27
+ const points = this.points;
28
+ const p = (points.length - 1) * t;
29
+ const index = Math.floor(p);
30
+ const weight = p - index;
31
+ const p1 = points[index === 0 ? index : index - 1];
32
+ const cp1 = points[index];
33
+ const cp2 = points[index > points.length - 2 ? points.length - 1 : index + 1];
34
+ const p2 = points[index > points.length - 3 ? points.length - 1 : index + 2];
35
+ const point = catmullRom(weight, ...p1, ...cp1, ...cp2, ...p2);
36
+ return point;
37
+ }
38
+ }
@@ -0,0 +1,12 @@
1
+ export { default as Curve } from './Curve';
2
+ export { default as LineCurve } from './LineCurve';
3
+ export { default as PolylineCurve } from './PolylineCurve';
4
+ export { default as QuadraticBezierCurve } from './QuadraticBezierCurve';
5
+ export { default as CubicBezierCurve } from './CubicBezierCurve';
6
+ export { default as CatmulRomCurve } from './CatmulRomCurve';
7
+ export { default as SplineCurve } from './SplineCurve';
8
+ export { default as EllipseCurve } from './EllipseCurve';
9
+ export { default as ArcCurve } from './ArcCurve';
10
+ export { default as PathCurve } from './PathCurve';
11
+ export { default as Path } from './Path';
12
+ export { default as PathSVG } from './PathSVG';
@@ -0,0 +1,12 @@
1
+ export { default as Curve } from './Curve';
2
+ export { default as LineCurve } from './LineCurve';
3
+ export { default as PolylineCurve } from './PolylineCurve';
4
+ export { default as QuadraticBezierCurve } from './QuadraticBezierCurve';
5
+ export { default as CubicBezierCurve } from './CubicBezierCurve';
6
+ export { default as CatmulRomCurve } from './CatmulRomCurve';
7
+ export { default as SplineCurve } from './SplineCurve';
8
+ export { default as EllipseCurve } from './EllipseCurve';
9
+ export { default as ArcCurve } from './ArcCurve';
10
+ export { default as PathCurve } from './PathCurve';
11
+ export { default as Path } from './Path';
12
+ export { default as PathSVG } from './PathSVG';
@@ -1,4 +1,4 @@
1
- import { now } from '../functions';
1
+ import { now } from '../../functions';
2
2
  /**
3
3
  * Utility class for controlling FPS calls
4
4
  *
package/lib/geometry.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { Vector3 } from './types';
1
+ import type { Point, Point3 } from './types';
2
2
  /**
3
3
  * Convert a radians value into degrees
4
4
  *
@@ -26,8 +26,8 @@ export declare function angle(x1: number, y1: number, x2: number, y2: number): n
26
26
  /**
27
27
  * Find the closest angle between to angles
28
28
  *
29
- * @param {number} source Source angle in radians
30
- * @param {number} target Target angle in radians
29
+ * @param {number} source Source angle (in radians)
30
+ * @param {number} target Target angle (in radians)
31
31
  * @returns {number} Closest angle
32
32
  */
33
33
  export declare function closestAngle(source: number, target: number): number;
@@ -55,41 +55,23 @@ export declare function diagonal(width: number, height: number): number;
55
55
  * @param {number} radius Radius of the sphere
56
56
  * @param {number} phi Polar angle from the y (up) axis : [0, PI]
57
57
  * @param {number} theta Equator angle around the y (up) axis : [0, 2*PI]
58
- * @param {Vector3} target Target vector
59
- * @returns {Vector3}
58
+ * @param {Point3} target Target 3D point
59
+ * @returns {Point3}
60
60
  */
61
- export declare function radToSphere(radius: number, phi: number, theta: number, target?: Vector3): Vector3;
61
+ export declare function radToSphere(radius: number, phi: number, theta: number, target?: Point3): Point3;
62
62
  /**
63
- * Interpolate a point on an elliptical arc Cubic Bézier curve
63
+ * Interpolate a point on a line
64
64
  *
65
- * @param {number} t Normalized time value to interpolate
66
- * @param {number} x1 X-axis coordinate of the start point
67
- * @param {number} y1 Y-axis coordinate of the start point
68
- * @param {number} cpx1 X-axis coordinate of the first control point
69
- * @param {number} cpy1 Y-axis coordinate of the first control point
70
- * @param {number} cpx2 X-axis coordinate of the second control point
71
- * @param {number} cpy2 Y-axis coordinate of the second control point
72
- * @param {number} x2 X-axis coordinate of the end point
73
- * @param {number} y2 Y-axis coordinate of the end point
74
- * @returns {[number, number]} Interpolated coordinates on the curve
75
- */
76
- export declare function cubicBezier(t: number, x1: number, y1: number, cpx1: number, cpy1: number, cpx2: number, cpy2: number, x2: number, y2: number): [number, number];
77
- /**
78
- * Compute the curvature of a Cubic Bézier curve
79
- *
80
- * @param {number} x1 X-axis coordinate of the start point
81
- * @param {number} y1 Y-axis coordinate of the start point
82
- * @param {number} cpx1 X-axis coordinate of the first control point
83
- * @param {number} cpy1 Y-axis coordinate of the first control point
84
- * @param {number} cpx2 X-axis coordinate of the second control point
85
- * @param {number} cpy2 Y-axis coordinate of the second control point
86
- * @param {number} x2 X-axis coordinate of the end point
87
- * @param {number} y2 Y-axis coordinate of the end point
88
- * @returns {number} Computed curvature
65
+ * @param {number} t Normalized time value to interpolate
66
+ * @param {number} x1 X-axis coordinate of the start point
67
+ * @param {number} y1 Y-axis coordinate of the start point
68
+ * @param {number} x2 X-axis coordinate of the end point
69
+ * @param {number} y2 Y-axis coordinate of the end point
70
+ * @returns {Point} Interpolated coordinates on the line
89
71
  */
90
- export declare function computeCubicBezierCurvature(x1: number, y1: number, cpx1: number, cpy1: number, cpx2: number, cpy2: number, x2: number, y2: number): number;
72
+ export declare function line(t: number, x1: number, y1: number, x2: number, y2: number): Point;
91
73
  /**
92
- * Interpolate a point on an elliptical arc Quadratic Bézier curve
74
+ * Interpolate a point on a Quadratic Bézier curve
93
75
  *
94
76
  * @param {number} t Normalized time value to interpolate
95
77
  * @param {number} x1 X-axis coordinate of the start point
@@ -98,52 +80,89 @@ export declare function computeCubicBezierCurvature(x1: number, y1: number, cpx1
98
80
  * @param {number} cpy Y-axis coordinate of the control point
99
81
  * @param {number} x2 X-axis coordinate of the end point
100
82
  * @param {number} y2 Y-axis coordinate of the end point
101
- * @returns {[number, number]} Interpolated coordinates on the curve
83
+ * @returns {Point} Interpolated coordinates on the curve
102
84
  */
103
- export declare function quadraticBezier(t: number, x1: number, y1: number, cpx: number, cpy: number, x2: number, y2: number): [number, number];
85
+ export declare function quadraticBezier(t: number, x1: number, y1: number, cpx: number, cpy: number, x2: number, y2: number): Point;
104
86
  /**
105
- * Compute the curvature of a Quadratic Bézier curve
87
+ * Interpolate a point on a Cubic Bézier curve
106
88
  *
89
+ * @param {number} t Normalized time value to interpolate
90
+ * @param {number} x1 X-axis coordinate of the start point
91
+ * @param {number} y1 Y-axis coordinate of the start point
92
+ * @param {number} cp1x X-axis coordinate of the first control point
93
+ * @param {number} cp1y Y-axis coordinate of the first control point
94
+ * @param {number} cp2x X-axis coordinate of the second control point
95
+ * @param {number} cp2y Y-axis coordinate of the second control point
96
+ * @param {number} x2 X-axis coordinate of the end point
97
+ * @param {number} y2 Y-axis coordinate of the end point
98
+ * @returns {Point} Interpolated coordinates on the curve
99
+ */
100
+ export declare function cubicBezier(t: number, x1: number, y1: number, cp1x: number, cp1y: number, cp2x: number, cp2y: number, x2: number, y2: number): Point;
101
+ /**
102
+ * Interpolate a point on a Catmull-Rom spline
103
+ *
104
+ * @param {number} t Normalized time value to interpolate
107
105
  * @param {number} x1 X-axis coordinate of the start point
108
106
  * @param {number} y1 Y-axis coordinate of the start point
109
- * @param {number} cpx X-axis coordinate of the control point
110
- * @param {number} cpy Y-axis coordinate of the control point
107
+ * @param {number} cp1x X-axis coordinate of the first control point
108
+ * @param {number} cp1y Y-axis coordinate of the first control point
109
+ * @param {number} cp2x X-axis coordinate of the second control point
110
+ * @param {number} cp2y Y-axis coordinate of the second control point
111
111
  * @param {number} x2 X-axis coordinate of the end point
112
112
  * @param {number} y2 Y-axis coordinate of the end point
113
- * @returns {number} Computed curvature
113
+ * @returns {Point} Interpolated coordinates on the spline
114
114
  */
115
- export declare function computeQuadraticBezierCurvature(x1: number, y1: number, cpx: number, cpy: number, x2: number, y2: number): number;
115
+ export declare function catmullRom(t: number, x1: number, y1: number, cp1x: number, cp1y: number, cp2x: number, cp2y: number, x2: number, y2: number): Point;
116
116
  /**
117
117
  * Interpolate a point on an elliptical arc
118
118
  *
119
- * @param {number} t Normalized time value to interpolate
120
- * @param {number} x1 X-axis coordinate of the starting point of the arc
121
- * @param {number} y1 Y-axis coordinate of the starting point of the arc
122
- * @param {number} x2 X-axis coordinate of the ending point of the arc
123
- * @param {number} y2 Y-axis coordinate of the ending point of the arc
124
- * @param {number} rx X-radius of the ellipse
125
- * @param {number} ry Y-radius of the ellipse
126
- * @param {number} angle Rotation angle of the ellipse (in radians)
127
- * @param {boolean} [largeArc] Flag indicating whether to draw the larger of the two possible arcs
128
- * @param {boolean} [clockwise] Flag indicating the direction of the arc
129
- * @returns {[number, number]} Interpolated coordinates on the arc
130
- */
131
- export declare function arc(t: number, x1: number, y1: number, x2: number, y2: number, rx: number, ry: number, angle: number, largeArc?: boolean, clockwise?: boolean): [number, number];
132
- /**
133
- * Compute the curvature of an elliptical arc
134
- *
135
- * @param {number} x1 X-axis coordinate of the starting point of the arc
136
- * @param {number} y1 Y-axis coordinate of the starting point of the arc
137
- * @param {number} x2 X-axis coordinate of the ending point of the arc
138
- * @param {number} y2 Y-axis coordinate of the ending point of the arc
139
- * @param {number} rx X-radius of the ellipse
140
- * @param {number} ry Y-radius of the ellipse
141
- * @param {number} angle Rotation angle of the ellipse (in radians)
142
- * @param {boolean} [largeArc] Flag indicating whether to draw the larger of the two possible arcs
143
- * @param {boolean} [clockwise] Flag indicating the direction of the arc
144
- * @returns Computed curvature
145
- */
146
- export declare function computeArcCurvature(x1: number, y1: number, x2: number, y2: number, rx: number, ry: number, angle: number, largeArc?: boolean, clockwise?: boolean): number;
119
+ * @param {number} t Normalized time value to interpolate
120
+ * @param {number} cx X-axis coordinate of the center of the ellipse
121
+ * @param {number} cy Y-axis coordinate of the center of the ellipse
122
+ * @param {number} rx X-radius of the ellipse
123
+ * @param {number} ry Y-radius of the ellipse
124
+ * @param {number} [rotation=0] Rotation angle of the ellipse (in radians), counterclockwise from the positive X-axis
125
+ * @param {number} [startAngle=0] Start angle of the arc (in radians)
126
+ * @param {number} [endAngle=2*PI] End angle of the arc (in radians)
127
+ * @param {boolean} [counterclockwise=false] Flag indicating the direction of the arc
128
+ * @returns {Point} Interpolated coordinates on the arc
129
+ */
130
+ export declare function ellipse(t: number, cx: number, cy: number, rx: number, ry: number, rotation?: number, startAngle?: number, endAngle?: number, counterclockwise?: boolean): Point;
131
+ /**
132
+ * Interpolate a point on a circular arc
133
+ *
134
+ * @param {number} t Normalized time value to interpolate
135
+ * @param {number} cx X-axis coordinate of the center of the circle
136
+ * @param {number} cy Y-axis coordinate of the center of the circle
137
+ * @param {number} radius Radius of the circle
138
+ * @param {number} [startAngle] Start angle of the arc (in radians)
139
+ * @param {number} [endAngle] End angle of the arc (in radians)
140
+ * @param {boolean} [counterclockwise=false] Flag indicating the direction of the arc
141
+ * @returns {Point} Interpolated coordinates on the arc
142
+ */
143
+ export declare function arc(t: number, cx: number, cy: number, radius: number, startAngle?: number, endAngle?: number, counterclockwise?: boolean): Point;
144
+ /**
145
+ * Check if two points are coincident
146
+ *
147
+ * @param {number} x1 X-axis coordinate of the first point
148
+ * @param {number} y1 Y-axis coordinate of the first point
149
+ * @param {number} x2 X-axis coordinate of the second point
150
+ * @param {number} y2 Y-axis coordinate of the second point
151
+ * @returns {boolean} True if the two are coincident, false otherwise
152
+ */
153
+ export declare function isCoincident(x1: number, y1: number, x2: number, y2: number): boolean;
154
+ /**
155
+ * Check if three points are collinear (aligned on the same line)
156
+ *
157
+ * @param {number} x1 X-axis coordinate of the first point
158
+ * @param {number} y1 Y-axis coordinate of the first point
159
+ * @param {number} x2 X-axis coordinate of the second point
160
+ * @param {number} y2 Y-axis coordinate of the second point
161
+ * @param {number} x3 X-axis coordinate of the third point
162
+ * @param {number} y3 Y-axis coordinate of the third point
163
+ * @returns {boolean} True if the three points are collinear, false otherwise
164
+ */
165
+ export declare function isCollinear(x1: number, y1: number, x2: number, y2: number, x3: number, y3: number): boolean;
147
166
  export type FitInput = {
148
167
  width: number;
149
168
  height: number;