toosoon-utils 4.1.9 → 4.2.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.
Files changed (62) hide show
  1. package/README.md +97 -885
  2. package/lib/constants.d.ts +0 -1
  3. package/lib/constants.js +3 -1
  4. package/lib/extras/color-scale/ColorScale.d.ts +2 -2
  5. package/lib/extras/color-scale/ColorScale.js +2 -2
  6. package/lib/extras/curves/CatmullRomCurve.d.ts +20 -5
  7. package/lib/extras/curves/CatmullRomCurve.js +23 -5
  8. package/lib/extras/curves/CatmullRomCurve3.d.ts +101 -0
  9. package/lib/extras/curves/CatmullRomCurve3.js +122 -0
  10. package/lib/extras/curves/CubicBezierCurve.d.ts +20 -5
  11. package/lib/extras/curves/CubicBezierCurve.js +23 -5
  12. package/lib/extras/curves/CubicBezierCurve3.d.ts +101 -0
  13. package/lib/extras/curves/CubicBezierCurve3.js +122 -0
  14. package/lib/extras/curves/Curve.d.ts +23 -24
  15. package/lib/extras/curves/Curve.js +19 -26
  16. package/lib/extras/curves/EllipseCurve.d.ts +21 -5
  17. package/lib/extras/curves/EllipseCurve.js +55 -6
  18. package/lib/extras/curves/LineCurve.d.ts +34 -10
  19. package/lib/extras/curves/LineCurve.js +35 -13
  20. package/lib/extras/curves/LineCurve3.d.ts +87 -0
  21. package/lib/extras/curves/LineCurve3.js +108 -0
  22. package/lib/extras/curves/PolylineCurve.d.ts +9 -8
  23. package/lib/extras/curves/PolylineCurve.js +6 -6
  24. package/lib/extras/curves/PolylineCurve3.d.ts +28 -0
  25. package/lib/extras/curves/PolylineCurve3.js +39 -0
  26. package/lib/extras/curves/QuadraticBezierCurve.d.ts +19 -5
  27. package/lib/extras/curves/QuadraticBezierCurve.js +22 -5
  28. package/lib/extras/curves/QuadraticBezierCurve3.d.ts +84 -0
  29. package/lib/extras/curves/QuadraticBezierCurve3.js +102 -0
  30. package/lib/extras/curves/SplineCurve.d.ts +12 -8
  31. package/lib/extras/curves/SplineCurve.js +9 -6
  32. package/lib/extras/curves/SplineCurve3.d.ts +28 -0
  33. package/lib/extras/curves/SplineCurve3.js +41 -0
  34. package/lib/extras/curves/index.d.ts +6 -0
  35. package/lib/extras/curves/index.js +6 -0
  36. package/lib/extras/geometry/Matrix2.d.ts +1 -0
  37. package/lib/extras/geometry/Matrix2.js +230 -0
  38. package/lib/extras/geometry/Matrix4.d.ts +1 -0
  39. package/lib/extras/geometry/Matrix4.js +632 -0
  40. package/lib/extras/geometry/Vector.d.ts +42 -0
  41. package/lib/extras/geometry/Vector.js +1 -0
  42. package/lib/extras/geometry/Vector2.d.ts +480 -0
  43. package/lib/extras/geometry/Vector2.js +709 -0
  44. package/lib/extras/geometry/Vector3.d.ts +486 -0
  45. package/lib/extras/geometry/Vector3.js +765 -0
  46. package/lib/extras/geometry/index.d.ts +3 -0
  47. package/lib/extras/geometry/index.js +2 -0
  48. package/lib/extras/paths/Path.d.ts +24 -18
  49. package/lib/extras/paths/Path.js +48 -35
  50. package/lib/extras/paths/PathContext.d.ts +97 -67
  51. package/lib/extras/paths/PathContext.js +326 -183
  52. package/lib/extras/paths/PathSVG.d.ts +43 -31
  53. package/lib/extras/paths/PathSVG.js +69 -56
  54. package/lib/geometry.d.ts +0 -135
  55. package/lib/geometry.js +1 -219
  56. package/lib/maths.d.ts +54 -22
  57. package/lib/maths.js +77 -27
  58. package/lib/random.d.ts +12 -16
  59. package/lib/random.js +19 -27
  60. package/lib/tsconfig.tsbuildinfo +1 -1
  61. package/lib/types.d.ts +43 -1
  62. package/package.json +2 -1
@@ -1,14 +1,9 @@
1
- import Curve from '../curves/Curve';
2
- import LineCurve from '../curves/LineCurve';
3
- import PolylineCurve from '../curves/PolylineCurve';
4
- import QuadraticBezierCurve from '../curves/QuadraticBezierCurve';
5
- import CubicBezierCurve from '../curves/CubicBezierCurve';
6
- import CatmullRomCurve from '../curves/CatmullRomCurve';
7
- import SplineCurve from '../curves/SplineCurve';
8
- import EllipseCurve from '../curves/EllipseCurve';
9
- import ArcCurve from '../curves/ArcCurve';
1
+ import { Curve, LineCurve, PolylineCurve, QuadraticBezierCurve, CubicBezierCurve, CatmullRomCurve, SplineCurve, EllipseCurve, ArcCurve } from '../curves';
2
+ import { type Vector2 } from '../geometry';
10
3
  import PathContext from './PathContext';
11
- export type SerializationParams = {
4
+ import Path from './Path';
5
+ export type PathSVGSerializationParams = {
6
+ approximate?: boolean;
12
7
  curveResolution?: number;
13
8
  };
14
9
  /**
@@ -21,80 +16,97 @@ export type SerializationParams = {
21
16
  * @extends PathContext
22
17
  */
23
18
  export default class PathSVG extends PathContext {
19
+ /**
20
+ * Convert a {@link Curve} into spaced points
21
+ *
22
+ * @param {Curve} curve Curve to approximate
23
+ * @param {number} [resolution=5] Approximation resolution
24
+ * @returns
25
+ */
26
+ static approximate(curve: Curve<Vector2>, resolution?: number): Vector2[];
24
27
  /**
25
28
  * Serialize a {@link Curve}
26
29
  *
27
- * @param {Curve} curve
28
- * @param {object} [params.curveResolution=5] Resolution used for Catmull-Rom curves and Spline curves approximations
30
+ * @param {Curve} curve Curve to serialize
31
+ * @param {object} [params] Serialization parameters
32
+ * @param {boolean} [params.approximate] Flag indicating if given curve should be approximated into straight lines
33
+ * @param {number} [params.curveResolution] Resolution used for curve approximations
29
34
  * @returns string
30
35
  */
31
- static serialize(curve: Curve, { curveResolution }?: SerializationParams): string;
36
+ static serialize(curve: Curve<Vector2>, { approximate, curveResolution }?: PathSVGSerializationParams): string;
32
37
  /**
33
38
  * Serialize a {@link LineCurve}
34
39
  *
35
- * @param {LineCurve} curve
40
+ * @param {LineCurve} curve LineCurve to serialize
36
41
  * @returns string
37
42
  */
38
43
  static serializeLineCurve(curve: LineCurve): string;
39
44
  /**
40
45
  * Serialize a {@link PolylineCurve}
41
46
  *
42
- * @param {PolylineCurve} curve
47
+ * @param {PolylineCurve} curve PolylineCurve to serialize
43
48
  * @returns string
44
49
  */
45
50
  static serializePolylineCurve(curve: PolylineCurve): string;
46
51
  /**
47
52
  * Serialize a {@link QuadraticBezierCurve}
48
53
  *
49
- * @param {QuadraticBezierCurve} curve
54
+ * @param {QuadraticBezierCurve} curve QuadraticBezierCurve to serialize
50
55
  * @returns string
51
56
  */
52
57
  static serializeQuadraticBezierCurve(curve: QuadraticBezierCurve): string;
53
58
  /**
54
59
  * Serialize a {@link CubicBezierCurve}
55
60
  *
56
- * @param {CubicBezierCurve} curve
61
+ * @param {CubicBezierCurve} curve CubicBezierCurve to serialize
57
62
  * @returns string
58
63
  */
59
64
  static serializeCubicBezierCurve(curve: CubicBezierCurve): string;
60
65
  /**
61
- * Serialize a {@link CatmullRomCurve}
66
+ * Serialize a {@link CatmullRomCurve} by approximating it into straight lines
62
67
  *
63
- * @param {CatmullRomCurve} curve
64
- * @param {object} params
65
- * @param {number} [params.curveResolution=5]
68
+ * @param {CatmullRomCurve} curve CatmullRomCurve to serialize
69
+ * @param {number} [curveResolution] Approximation resolution
66
70
  * @returns string
67
71
  */
68
- static serializeCatmullRomCurve(curve: CatmullRomCurve, { curveResolution }: Pick<SerializationParams, 'curveResolution'>): string;
72
+ static serializeCatmullRomCurve(curve: CatmullRomCurve, curveResolution?: number): string;
69
73
  /**
70
- * Serialize a {@link SplineCurve}
74
+ * Serialize a {@link SplineCurve} by approximating it into straight lines
71
75
  *
72
- * @param {SplineCurve} curve
73
- * @param {object} params
74
- * @param {number} [params.curveResolution=5]
76
+ * @param {SplineCurve} curve SplineCurve to serialize
77
+ * @param {number} [curveResolution] Approximation resolution
75
78
  * @returns string
76
79
  */
77
- static serializeSplineCurve(curve: SplineCurve, { curveResolution }: Pick<SerializationParams, 'curveResolution'>): string;
80
+ static serializeSplineCurve(curve: SplineCurve, curveResolution?: number): string;
78
81
  /**
79
82
  * Serialize an {@link EllipseCurve}
80
83
  *
81
- * @param {EllipseCurve} curve
84
+ * @param {EllipseCurve} curve EllipseCurve to serialize
82
85
  * @returns string
83
86
  */
84
87
  static serializeEllipseCurve(curve: EllipseCurve): string;
85
88
  /**
86
89
  * Serialize an {@link ArcCurve}
87
90
  *
88
- * @param {ArcCurve} curve
91
+ * @param {ArcCurve} curve ArcCurve to serialize
89
92
  * @returns string
90
93
  */
91
94
  static serializeArcCurve(curve: ArcCurve): string;
95
+ /**
96
+ * Serialize an {@link Path}
97
+ *
98
+ * @param {Path} path Path to serialize
99
+ * @param {object} [params]
100
+ * @param {object} [params.curveResolution] Resolution used for curves approximations
101
+ * @returns string
102
+ */
103
+ static serializePath(path: Path<Vector2>, params?: PathSVGSerializationParams): string;
92
104
  /**
93
105
  * Return SVG path data string
94
106
  *
95
107
  * @param {object} [params]
96
- * @param {object} [params.curveResolution=5] Resolution used for Catmull-Rom curves and Spline curves approximations
108
+ * @param {object} [params.curveResolution] Resolution used for curves approximations
97
109
  * @returns {string}
98
110
  */
99
- toString(params?: SerializationParams): string;
111
+ toString(params?: PathSVGSerializationParams): string;
100
112
  }
@@ -1,13 +1,6 @@
1
- import { EPSILON, PI, TWO_PI, TAU_EPSILON } from '../../constants';
2
- import { isCoincident, toDegrees } from '../../geometry';
3
- import LineCurve from '../curves/LineCurve';
4
- import PolylineCurve from '../curves/PolylineCurve';
5
- import QuadraticBezierCurve from '../curves/QuadraticBezierCurve';
6
- import CubicBezierCurve from '../curves/CubicBezierCurve';
7
- import CatmullRomCurve from '../curves/CatmullRomCurve';
8
- import SplineCurve from '../curves/SplineCurve';
9
- import EllipseCurve from '../curves/EllipseCurve';
10
- import ArcCurve from '../curves/ArcCurve';
1
+ import { EPSILON, PI, TWO_PI } from '../../constants';
2
+ import { toDegrees } from '../../geometry';
3
+ import { LineCurve, PolylineCurve, QuadraticBezierCurve, CubicBezierCurve, CatmullRomCurve, SplineCurve, EllipseCurve, ArcCurve } from '../curves';
11
4
  import PathContext from './PathContext';
12
5
  /**
13
6
  * Utility class for manipulating connected curves and generating SVG path
@@ -19,14 +12,31 @@ import PathContext from './PathContext';
19
12
  * @extends PathContext
20
13
  */
21
14
  export default class PathSVG extends PathContext {
15
+ /**
16
+ * Convert a {@link Curve} into spaced points
17
+ *
18
+ * @param {Curve} curve Curve to approximate
19
+ * @param {number} [resolution=5] Approximation resolution
20
+ * @returns
21
+ */
22
+ static approximate(curve, resolution = 5) {
23
+ const divisions = (curve.getLength() * resolution) / 100;
24
+ return curve.getSpacedPoints(divisions);
25
+ }
22
26
  /**
23
27
  * Serialize a {@link Curve}
24
28
  *
25
- * @param {Curve} curve
26
- * @param {object} [params.curveResolution=5] Resolution used for Catmull-Rom curves and Spline curves approximations
29
+ * @param {Curve} curve Curve to serialize
30
+ * @param {object} [params] Serialization parameters
31
+ * @param {boolean} [params.approximate] Flag indicating if given curve should be approximated into straight lines
32
+ * @param {number} [params.curveResolution] Resolution used for curve approximations
27
33
  * @returns string
28
34
  */
29
- static serialize(curve, { curveResolution } = {}) {
35
+ static serialize(curve, { approximate, curveResolution } = {}) {
36
+ if (approximate === true) {
37
+ const points = PathSVG.approximate(curve, curveResolution);
38
+ return points.map(([x, y]) => `L${x},${y}`).join(' ');
39
+ }
30
40
  if (curve instanceof LineCurve) {
31
41
  return PathSVG.serializeLineCurve(curve);
32
42
  }
@@ -40,10 +50,10 @@ export default class PathSVG extends PathContext {
40
50
  return PathSVG.serializeCubicBezierCurve(curve);
41
51
  }
42
52
  if (curve instanceof CatmullRomCurve) {
43
- return PathSVG.serializeCatmullRomCurve(curve, { curveResolution });
53
+ return PathSVG.serializeCatmullRomCurve(curve, curveResolution);
44
54
  }
45
55
  if (curve instanceof SplineCurve) {
46
- return PathSVG.serializeSplineCurve(curve, { curveResolution });
56
+ return PathSVG.serializeSplineCurve(curve, curveResolution);
47
57
  }
48
58
  if (curve instanceof EllipseCurve) {
49
59
  return PathSVG.serializeEllipseCurve(curve);
@@ -56,7 +66,7 @@ export default class PathSVG extends PathContext {
56
66
  /**
57
67
  * Serialize a {@link LineCurve}
58
68
  *
59
- * @param {LineCurve} curve
69
+ * @param {LineCurve} curve LineCurve to serialize
60
70
  * @returns string
61
71
  */
62
72
  static serializeLineCurve(curve) {
@@ -66,7 +76,7 @@ export default class PathSVG extends PathContext {
66
76
  /**
67
77
  * Serialize a {@link PolylineCurve}
68
78
  *
69
- * @param {PolylineCurve} curve
79
+ * @param {PolylineCurve} curve PolylineCurve to serialize
70
80
  * @returns string
71
81
  */
72
82
  static serializePolylineCurve(curve) {
@@ -76,7 +86,7 @@ export default class PathSVG extends PathContext {
76
86
  /**
77
87
  * Serialize a {@link QuadraticBezierCurve}
78
88
  *
79
- * @param {QuadraticBezierCurve} curve
89
+ * @param {QuadraticBezierCurve} curve QuadraticBezierCurve to serialize
80
90
  * @returns string
81
91
  */
82
92
  static serializeQuadraticBezierCurve(curve) {
@@ -86,7 +96,7 @@ export default class PathSVG extends PathContext {
86
96
  /**
87
97
  * Serialize a {@link CubicBezierCurve}
88
98
  *
89
- * @param {CubicBezierCurve} curve
99
+ * @param {CubicBezierCurve} curve CubicBezierCurve to serialize
90
100
  * @returns string
91
101
  */
92
102
  static serializeCubicBezierCurve(curve) {
@@ -94,39 +104,31 @@ export default class PathSVG extends PathContext {
94
104
  return `C${cp1x},${cp1y},${cp2x},${cp2y},${x2},${y2}`;
95
105
  }
96
106
  /**
97
- * Serialize a {@link CatmullRomCurve}
107
+ * Serialize a {@link CatmullRomCurve} by approximating it into straight lines
98
108
  *
99
- * @param {CatmullRomCurve} curve
100
- * @param {object} params
101
- * @param {number} [params.curveResolution=5]
109
+ * @param {CatmullRomCurve} curve CatmullRomCurve to serialize
110
+ * @param {number} [curveResolution] Approximation resolution
102
111
  * @returns string
103
112
  */
104
- static serializeCatmullRomCurve(curve, { curveResolution = 5 }) {
105
- const divisions = (curve.getLength() * curveResolution) / 100;
106
- return curve
107
- .getSpacedPoints(divisions)
108
- .map(([x, y]) => `L${x},${y}`)
109
- .join(' ');
113
+ static serializeCatmullRomCurve(curve, curveResolution) {
114
+ const points = PathSVG.approximate(curve, curveResolution);
115
+ return points.map(([x, y]) => `L${x},${y}`).join(' ');
110
116
  }
111
117
  /**
112
- * Serialize a {@link SplineCurve}
118
+ * Serialize a {@link SplineCurve} by approximating it into straight lines
113
119
  *
114
- * @param {SplineCurve} curve
115
- * @param {object} params
116
- * @param {number} [params.curveResolution=5]
120
+ * @param {SplineCurve} curve SplineCurve to serialize
121
+ * @param {number} [curveResolution] Approximation resolution
117
122
  * @returns string
118
123
  */
119
- static serializeSplineCurve(curve, { curveResolution = 5 }) {
120
- const divisions = (curve.getLength() * curveResolution) / 100;
121
- return curve
122
- .getSpacedPoints(divisions)
123
- .map(([x, y]) => `L${x},${y}`)
124
- .join(' ');
124
+ static serializeSplineCurve(curve, curveResolution) {
125
+ const points = PathSVG.approximate(curve, curveResolution);
126
+ return points.map(([x, y]) => `L${x},${y}`).join(' ');
125
127
  }
126
128
  /**
127
129
  * Serialize an {@link EllipseCurve}
128
130
  *
129
- * @param {EllipseCurve} curve
131
+ * @param {EllipseCurve} curve EllipseCurve to serialize
130
132
  * @returns string
131
133
  */
132
134
  static serializeEllipseCurve(curve) {
@@ -137,7 +139,7 @@ export default class PathSVG extends PathContext {
137
139
  const xAxisRotation = toDegrees(rotation);
138
140
  const largeArcFlag = deltaAngle >= PI ? 1 : 0;
139
141
  const sweepFlag = counterclockwise ? 0 : 1;
140
- if (deltaAngle > TAU_EPSILON) {
142
+ if (deltaAngle > TWO_PI - EPSILON) {
141
143
  const dx = Math.cos(startAngle) * rx;
142
144
  const dy = Math.sin(startAngle) * ry;
143
145
  return (`A${rx},${ry},${xAxisRotation},1,${sweepFlag},${cx - dx},${cy - dy}` +
@@ -153,35 +155,46 @@ export default class PathSVG extends PathContext {
153
155
  /**
154
156
  * Serialize an {@link ArcCurve}
155
157
  *
156
- * @param {ArcCurve} curve
158
+ * @param {ArcCurve} curve ArcCurve to serialize
157
159
  * @returns string
158
160
  */
159
161
  static serializeArcCurve(curve) {
160
162
  return PathSVG.serializeEllipseCurve(curve);
161
163
  }
162
164
  /**
163
- * Return SVG path data string
165
+ * Serialize an {@link Path}
164
166
  *
167
+ * @param {Path} path Path to serialize
165
168
  * @param {object} [params]
166
- * @param {object} [params.curveResolution=5] Resolution used for Catmull-Rom curves and Spline curves approximations
167
- * @returns {string}
169
+ * @param {object} [params.curveResolution] Resolution used for curves approximations
170
+ * @returns string
168
171
  */
169
- toString(params = {}) {
170
- return this.curves
172
+ static serializePath(path, params = {}) {
173
+ return path.subpaths
171
174
  .map((curve, index) => {
172
175
  let commands = ``;
173
- const lastPoint = index === 0 ? this.curves[0]?.getPoint(0) : this.curves[index - 1]?.getPoint(1);
174
- if (index === 0 || !isCoincident(...lastPoint, ...curve.getPoint(0))) {
175
- commands += `M${lastPoint[0]},${lastPoint[1]}`;
176
+ const previousPoint = path.subpaths[index - 1]?.getPoint(1);
177
+ const newPoint = curve.getPoint(0);
178
+ if (!previousPoint?.equals(newPoint)) {
179
+ commands += `M${newPoint.x},${newPoint.y}`;
176
180
  }
177
- // commands += PathSVG.serialize(curve, params);
178
- const divisions = curve.getLength() / 50;
179
- commands += curve
180
- .getSpacedPoints(divisions)
181
- .map(([x, y]) => `L${x},${y}`)
182
- .join(' ');
181
+ commands += PathSVG.serialize(curve, params);
183
182
  return commands;
184
183
  })
185
184
  .join(' ');
186
185
  }
186
+ /**
187
+ * Return SVG path data string
188
+ *
189
+ * @param {object} [params]
190
+ * @param {object} [params.curveResolution] Resolution used for curves approximations
191
+ * @returns {string}
192
+ */
193
+ toString(params = {}) {
194
+ let commands = ``;
195
+ const firstPoint = this.subpaths[0]?.getPoint(0);
196
+ commands += `M${firstPoint.x},${firstPoint.y}`;
197
+ commands += PathSVG.serialize(this, params);
198
+ return commands;
199
+ }
187
200
  }
package/lib/geometry.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- import type { Point, Point3 } from './types';
2
1
  /**
3
2
  * Convert a radians value into degrees
4
3
  *
@@ -41,26 +40,6 @@ export declare function closestAngle(source: number, target: number): number;
41
40
  * @returns {number} Computed distance
42
41
  */
43
42
  export declare function distance(x1: number, y1: number, x2: number, y2: number): number;
44
- /**
45
- * Calculate the dot product of two vectors
46
- *
47
- * @param {number} x1 X-axis coordinate of the first vector
48
- * @param {number} y1 Y-axis coordinate of the first vector
49
- * @param {number} x2 X-axis coordinate of the second vector
50
- * @param {number} y2 Y-axis coordinate of the second vector
51
- * @returns {number} Computed dot product
52
- */
53
- export declare function dot(x1: number, y1: number, x2: number, y2: number): number;
54
- /**
55
- * Calculate the cross product of two vectors
56
- *
57
- * @param {number} x1 X-axis coordinate of the first vector
58
- * @param {number} y1 Y-axis coordinate of the first vector
59
- * @param {number} x2 X-axis coordinate of the second vector
60
- * @param {number} y2 Y-axis coordinate of the second vector
61
- * @returns {number} Computed cross product
62
- */
63
- export declare function cross(x1: number, y1: number, x2: number, y2: number): number;
64
43
  /**
65
44
  * Calculate the length of the diagonal of a rectangle
66
45
  *
@@ -69,120 +48,6 @@ export declare function cross(x1: number, y1: number, x2: number, y2: number): n
69
48
  * @returns {number} Diagonal length
70
49
  */
71
50
  export declare function diagonal(width: number, height: number): number;
72
- /**
73
- * Convert radians to a 3D point on the surface of a unit sphere
74
- *
75
- * @param {number} radius Radius of the sphere
76
- * @param {number} phi Polar angle from the y (up) axis : [0, PI]
77
- * @param {number} theta Equator angle around the y (up) axis : [0, 2*PI]
78
- * @param {Point3} target Target 3D point
79
- * @returns {Point3}
80
- */
81
- export declare function radToSphere(radius: number, phi: number, theta: number, target?: Point3): Point3;
82
- /**
83
- * Interpolate a point on a line
84
- *
85
- * @param {number} t Normalized time value to interpolate
86
- * @param {number} x1 X-axis coordinate of the start point
87
- * @param {number} y1 Y-axis coordinate of the start point
88
- * @param {number} x2 X-axis coordinate of the end point
89
- * @param {number} y2 Y-axis coordinate of the end point
90
- * @returns {Point} Interpolated coordinates on the line
91
- */
92
- export declare function line(t: number, x1: number, y1: number, x2: number, y2: number): Point;
93
- /**
94
- * Interpolate a point on a Quadratic Bézier curve
95
- *
96
- * @param {number} t Normalized time value to interpolate
97
- * @param {number} x1 X-axis coordinate of the start point
98
- * @param {number} y1 Y-axis coordinate of the start point
99
- * @param {number} cpx X-axis coordinate of the control point
100
- * @param {number} cpy Y-axis coordinate of the control point
101
- * @param {number} x2 X-axis coordinate of the end point
102
- * @param {number} y2 Y-axis coordinate of the end point
103
- * @returns {Point} Interpolated coordinates on the curve
104
- */
105
- export declare function quadraticBezier(t: number, x1: number, y1: number, cpx: number, cpy: number, x2: number, y2: number): Point;
106
- /**
107
- * Interpolate a point on a Cubic Bézier curve
108
- *
109
- * @param {number} t Normalized time value to interpolate
110
- * @param {number} x1 X-axis coordinate of the start point
111
- * @param {number} y1 Y-axis coordinate of the start point
112
- * @param {number} cp1x X-axis coordinate of the first control point
113
- * @param {number} cp1y Y-axis coordinate of the first control point
114
- * @param {number} cp2x X-axis coordinate of the second control point
115
- * @param {number} cp2y Y-axis coordinate of the second control point
116
- * @param {number} x2 X-axis coordinate of the end point
117
- * @param {number} y2 Y-axis coordinate of the end point
118
- * @returns {Point} Interpolated coordinates on the curve
119
- */
120
- export declare function cubicBezier(t: number, x1: number, y1: number, cp1x: number, cp1y: number, cp2x: number, cp2y: number, x2: number, y2: number): Point;
121
- /**
122
- * Interpolate a point on a Catmull-Rom spline
123
- *
124
- * @param {number} t Normalized time value to interpolate
125
- * @param {number} x1 X-axis coordinate of the start point
126
- * @param {number} y1 Y-axis coordinate of the start point
127
- * @param {number} cp1x X-axis coordinate of the first control point
128
- * @param {number} cp1y Y-axis coordinate of the first control point
129
- * @param {number} cp2x X-axis coordinate of the second control point
130
- * @param {number} cp2y Y-axis coordinate of the second control point
131
- * @param {number} x2 X-axis coordinate of the end point
132
- * @param {number} y2 Y-axis coordinate of the end point
133
- * @returns {Point} Interpolated coordinates on the spline
134
- */
135
- export declare function catmullRom(t: number, x1: number, y1: number, cp1x: number, cp1y: number, cp2x: number, cp2y: number, x2: number, y2: number): Point;
136
- /**
137
- * Interpolate a point on an elliptical arc
138
- *
139
- * @param {number} t Normalized time value to interpolate
140
- * @param {number} cx X-axis coordinate of the center of the ellipse
141
- * @param {number} cy Y-axis coordinate of the center of the ellipse
142
- * @param {number} rx X-radius of the ellipse
143
- * @param {number} ry Y-radius of the ellipse
144
- * @param {number} [rotation=0] Rotation angle of the ellipse (in radians), counterclockwise from the positive X-axis
145
- * @param {number} [startAngle=0] Start angle of the arc (in radians)
146
- * @param {number} [endAngle=2*PI] End angle of the arc (in radians)
147
- * @param {boolean} [counterclockwise=false] Flag indicating the direction of the arc
148
- * @returns {Point} Interpolated coordinates on the arc
149
- */
150
- export declare function ellipse(t: number, cx: number, cy: number, rx: number, ry: number, rotation?: number, startAngle?: number, endAngle?: number, counterclockwise?: boolean): Point;
151
- /**
152
- * Interpolate a point on a circular arc
153
- *
154
- * @param {number} t Normalized time value to interpolate
155
- * @param {number} cx X-axis coordinate of the center of the circle
156
- * @param {number} cy Y-axis coordinate of the center of the circle
157
- * @param {number} radius Radius of the circle
158
- * @param {number} [startAngle] Start angle of the arc (in radians)
159
- * @param {number} [endAngle] End angle of the arc (in radians)
160
- * @param {boolean} [counterclockwise=false] Flag indicating the direction of the arc
161
- * @returns {Point} Interpolated coordinates on the arc
162
- */
163
- export declare function arc(t: number, cx: number, cy: number, radius: number, startAngle?: number, endAngle?: number, counterclockwise?: boolean): Point;
164
- /**
165
- * Check if two points are coincident
166
- *
167
- * @param {number} x1 X-axis coordinate of the first point
168
- * @param {number} y1 Y-axis coordinate of the first point
169
- * @param {number} x2 X-axis coordinate of the second point
170
- * @param {number} y2 Y-axis coordinate of the second point
171
- * @returns {boolean} True if the two are coincident, false otherwise
172
- */
173
- export declare function isCoincident(x1: number, y1: number, x2: number, y2: number): boolean;
174
- /**
175
- * Check if three points are collinear (aligned on the same line)
176
- *
177
- * @param {number} x1 X-axis coordinate of the first point
178
- * @param {number} y1 Y-axis coordinate of the first point
179
- * @param {number} x2 X-axis coordinate of the second point
180
- * @param {number} y2 Y-axis coordinate of the second point
181
- * @param {number} x3 X-axis coordinate of the third point
182
- * @param {number} y3 Y-axis coordinate of the third point
183
- * @returns {boolean} True if the three points are collinear, false otherwise
184
- */
185
- export declare function isCollinear(x1: number, y1: number, x2: number, y2: number, x3: number, y3: number): boolean;
186
51
  export type FitInput = {
187
52
  width: number;
188
53
  height: number;