curvy 2.0.0-alpha.2 → 2.0.0-alpha.4

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 (63) hide show
  1. package/dist/characteristic/index.d.mts +9 -9
  2. package/dist/characteristic/index.mjs +1 -1
  3. package/dist/curve/index.d.mts +10 -2
  4. package/dist/curve/index.mjs +1 -1
  5. package/dist/interval/index.d.mts +9 -3
  6. package/dist/interval/index.mjs +2 -2
  7. package/dist/matrix/index.d.mts +9 -2
  8. package/dist/path/index.d.mts +15 -223
  9. package/dist/path/index.mjs +6 -6
  10. package/dist/path/index.mjs.map +1 -1
  11. package/dist/polynomial/index.d.mts +9 -2
  12. package/dist/polynomial/index.mjs +2 -2
  13. package/dist/shared/{characteristic-B9nCh_cx.mjs → characteristic-DLlhja-I.mjs} +9 -9
  14. package/dist/shared/{characteristic-B9nCh_cx.mjs.map → characteristic-DLlhja-I.mjs.map} +1 -1
  15. package/dist/shared/{cubic-CpHAx8cC.mjs → cubic-CMonq6bg.mjs} +26 -5
  16. package/dist/shared/cubic-CMonq6bg.mjs.map +1 -0
  17. package/dist/shared/cubic-DkBqcZf-.d.mts +121 -0
  18. package/dist/shared/interval-Bhzeqp8M.d.mts +62 -0
  19. package/dist/shared/{interval-05CR6eBf.mjs → interval-X1EYuf-T.mjs} +2 -2
  20. package/dist/shared/{interval-05CR6eBf.mjs.map → interval-X1EYuf-T.mjs.map} +1 -1
  21. package/dist/shared/interval2d-BMk5UYXD.d.mts +29 -0
  22. package/dist/shared/{interval2d-8IBZnUOq.mjs → interval2d-ca0J1NMr.mjs} +8 -8
  23. package/dist/shared/{interval2d-8IBZnUOq.mjs.map → interval2d-ca0J1NMr.mjs.map} +1 -1
  24. package/dist/shared/matrix4x4-CaytTaB_.d.mts +168 -0
  25. package/dist/shared/{quadratic-CamozcFc.mjs → quadratic-DyeMtvET.mjs} +20 -2
  26. package/dist/shared/quadratic-DyeMtvET.mjs.map +1 -0
  27. package/dist/shared/rationalCubic2d-D-UevGKu.d.mts +60 -0
  28. package/dist/shared/{rationalCubic2d-Bys2Uory.mjs → rationalCubic2d-D658ltUM.mjs} +17 -17
  29. package/dist/shared/{rationalCubic2d-Bys2Uory.mjs.map → rationalCubic2d-D658ltUM.mjs.map} +1 -1
  30. package/dist/shared/rationalCubic2d-MgMSJaAU.d.mts +104 -0
  31. package/dist/shared/{rationalCubic2d-BEgUGSFf.mjs → rationalCubic2d-Vw4qGPZj.mjs} +9 -9
  32. package/dist/shared/{rationalCubic2d-BEgUGSFf.mjs.map → rationalCubic2d-Vw4qGPZj.mjs.map} +1 -1
  33. package/dist/shared/{solution-CrtLfqEq.mjs → solution-3TDATEMn.mjs} +28 -2
  34. package/dist/shared/solution-3TDATEMn.mjs.map +1 -0
  35. package/dist/shared/solution-DInDT2Hq.d.mts +60 -0
  36. package/dist/shared/{vector2-CL1HDdPr.mjs → vector2-CCuJx1rX.mjs} +6 -6
  37. package/dist/shared/{vector2-CL1HDdPr.mjs.map → vector2-CCuJx1rX.mjs.map} +1 -1
  38. package/dist/shared/vector2-euuV_bNQ.d.mts +58 -0
  39. package/dist/shared/vector3-3Xx7GVk7.d.mts +37 -0
  40. package/dist/shared/{vector3-D-tv_aKL.mjs → vector3-C-qgKAjR.mjs} +2 -2
  41. package/dist/shared/{vector3-D-tv_aKL.mjs.map → vector3-C-qgKAjR.mjs.map} +1 -1
  42. package/dist/shared/{vector4-5KbjoHVj.mjs → vector4-BhOKDhD5.mjs} +2 -2
  43. package/dist/shared/{vector4-5KbjoHVj.mjs.map → vector4-BhOKDhD5.mjs.map} +1 -1
  44. package/dist/solution/index.d.mts +7 -2
  45. package/dist/solution/index.mjs +1 -1
  46. package/dist/splines/index.d.mts +37 -606
  47. package/dist/splines/index.mjs +193 -35
  48. package/dist/splines/index.mjs.map +1 -1
  49. package/dist/vector/index.d.mts +10 -3
  50. package/dist/vector/index.mjs +3 -3
  51. package/package.json +1 -1
  52. package/dist/shared/cubic-BajUY0JT.d.mts +0 -1100
  53. package/dist/shared/cubic-CpHAx8cC.mjs.map +0 -1
  54. package/dist/shared/interval-Dy-RMEE3.d.mts +0 -533
  55. package/dist/shared/interval2d-C2id9u31.d.mts +0 -172
  56. package/dist/shared/matrix4x4-Dm_tSiH1.d.mts +0 -1183
  57. package/dist/shared/quadratic-CamozcFc.mjs.map +0 -1
  58. package/dist/shared/rationalCubic2d-B6g97ryJ.d.mts +0 -308
  59. package/dist/shared/rationalCubic2d-DlQfBURs.d.mts +0 -818
  60. package/dist/shared/solution-CrtLfqEq.mjs.map +0 -1
  61. package/dist/shared/solution-sNQ-ZVhN.d.mts +0 -251
  62. package/dist/shared/vector2-DPUY3_eA.d.mts +0 -470
  63. package/dist/shared/vector3-DqeOZtOB.d.mts +0 -703
@@ -1,6 +1,6 @@
1
- import { r as Vector4 } from "../shared/vector3-DqeOZtOB.mjs";
2
- import { t as Matrix4x4 } from "../shared/matrix4x4-Dm_tSiH1.mjs";
3
- import { t as CubicPolynomial } from "../shared/cubic-BajUY0JT.mjs";
1
+ import { n as Vector4 } from "../shared/vector3-3Xx7GVk7.mjs";
2
+ import { t as Matrix4x4 } from "../shared/matrix4x4-CaytTaB_.mjs";
3
+ import { t as CubicPolynomial } from "../shared/cubic-DkBqcZf-.mjs";
4
4
 
5
5
  //#region src/characteristic/characteristic.d.ts
6
6
  declare namespace characteristic_d_exports {
@@ -14,7 +14,7 @@ declare namespace characteristic_d_exports {
14
14
  * IS the Bézier spline family — combined with control points (via {@link apply}),
15
15
  * it produces the cubic polynomial that parameterizes the curve.
16
16
  *
17
- * @since 2.1.0
17
+ * @since 2.0.0
18
18
  */
19
19
  declare const cubicBezier: Matrix4x4;
20
20
  /**
@@ -23,7 +23,7 @@ declare const cubicBezier: Matrix4x4;
23
23
  * Maps Hermite control data `(P₀, V₀, P₁, V₁)` — two endpoints and two
24
24
  * tangent vectors — to monomial cubic coefficients.
25
25
  *
26
- * @since 2.1.0
26
+ * @since 2.0.0
27
27
  */
28
28
  declare const cubicHermite: Matrix4x4;
29
29
  /**
@@ -34,7 +34,7 @@ declare const cubicHermite: Matrix4x4;
34
34
  * application produces a C² piecewise spline; the curve does not generally
35
35
  * pass through the control points.
36
36
  *
37
- * @since 2.1.0
37
+ * @since 2.0.0
38
38
  */
39
39
  declare const cubicBasisSpline: Matrix4x4;
40
40
  /**
@@ -52,7 +52,7 @@ declare const cubicBasisSpline: Matrix4x4;
52
52
  *
53
53
  * @param tension - The tension parameter.
54
54
  * @returns The characteristic matrix for that tension.
55
- * @since 2.1.0
55
+ * @since 2.0.0
56
56
  */
57
57
  declare const cubicCardinal: (tension: number) => Matrix4x4;
58
58
  /**
@@ -60,7 +60,7 @@ declare const cubicCardinal: (tension: number) => Matrix4x4;
60
60
  * The most common Cardinal-family variant; reused widely enough to deserve
61
61
  * a constant.
62
62
  *
63
- * @since 2.1.0
63
+ * @since 2.0.0
64
64
  */
65
65
  declare const cubicCatmullRom: Matrix4x4;
66
66
  /**
@@ -80,7 +80,7 @@ declare const cubicCatmullRom: Matrix4x4;
80
80
  * @param matrix - The characteristic matrix of the spline family.
81
81
  * @param channels - One `Vector4` per output polynomial, packing the four control values for that channel.
82
82
  * @returns A tuple of cubic polynomials, one per input channel.
83
- * @since 2.1.0
83
+ * @since 2.0.0
84
84
  */
85
85
  declare const apply: <const Channels extends ReadonlyArray<Vector4>>(matrix: Matrix4x4, ...channels: Channels) => { readonly [K in keyof Channels]: CubicPolynomial };
86
86
  //#endregion
@@ -1,2 +1,2 @@
1
- import { n as characteristic_exports } from "../shared/characteristic-B9nCh_cx.mjs";
1
+ import { n as characteristic_exports } from "../shared/characteristic-DLlhja-I.mjs";
2
2
  export { characteristic_exports as Characteristic };
@@ -1,2 +1,10 @@
1
- import { c as linear2d_d_exports, i as cubic2d_d_exports, n as rationalCubic2d_d_exports, o as quadratic2d_d_exports } from "../shared/rationalCubic2d-DlQfBURs.mjs";
2
- export { cubic2d_d_exports as CubicCurve2d, linear2d_d_exports as LinearCurve2d, quadratic2d_d_exports as QuadraticCurve2d, rationalCubic2d_d_exports as RationalCubicCurve2d };
1
+ import { i as LinearCurve2d$1, n as CubicCurve2d$1, r as QuadraticCurve2d$1, t as RationalCubicCurve2d$1 } from "../shared/rationalCubic2d-MgMSJaAU.mjs";
2
+
3
+ //#region src/curve/index.d.ts
4
+ type LinearCurve2d = LinearCurve2d$1;
5
+ type QuadraticCurve2d = QuadraticCurve2d$1;
6
+ type CubicCurve2d = CubicCurve2d$1;
7
+ type RationalCubicCurve2d = RationalCubicCurve2d$1;
8
+ //#endregion
9
+ export { CubicCurve2d, LinearCurve2d, QuadraticCurve2d, RationalCubicCurve2d };
10
+ //# sourceMappingURL=index.d.mts.map
@@ -1,2 +1,2 @@
1
- import { _ as linear2d_exports, o as cubic2d_exports, p as quadratic2d_exports, r as rationalCubic2d_exports } from "../shared/rationalCubic2d-Bys2Uory.mjs";
1
+ import { m as quadratic2d_exports, o as cubic2d_exports, r as rationalCubic2d_exports, v as linear2d_exports } from "../shared/rationalCubic2d-D658ltUM.mjs";
2
2
  export { cubic2d_exports as CubicCurve2d, linear2d_exports as LinearCurve2d, quadratic2d_exports as QuadraticCurve2d, rationalCubic2d_exports as RationalCubicCurve2d };
@@ -1,3 +1,9 @@
1
- import { i as interval_d_exports } from "../shared/interval-Dy-RMEE3.mjs";
2
- import { n as interval2d_d_exports } from "../shared/interval2d-C2id9u31.mjs";
3
- export { interval_d_exports as Interval, interval2d_d_exports as Interval2d };
1
+ import { t as Interval$1 } from "../shared/interval-Bhzeqp8M.mjs";
2
+ import { t as Interval2d$1 } from "../shared/interval2d-BMk5UYXD.mjs";
3
+
4
+ //#region src/interval/index.d.ts
5
+ type Interval = Interval$1;
6
+ type Interval2d = Interval2d$1;
7
+ //#endregion
8
+ export { Interval, Interval2d };
9
+ //# sourceMappingURL=index.d.mts.map
@@ -1,3 +1,3 @@
1
- import { s as interval_exports } from "../shared/interval-05CR6eBf.mjs";
2
- import { t as interval2d_exports } from "../shared/interval2d-8IBZnUOq.mjs";
1
+ import { s as interval_exports } from "../shared/interval-X1EYuf-T.mjs";
2
+ import { t as interval2d_exports } from "../shared/interval2d-ca0J1NMr.mjs";
3
3
  export { interval_exports as Interval, interval2d_exports as Interval2d };
@@ -1,2 +1,9 @@
1
- import { i as matrix2x2_d_exports, n as matrix4x4_d_exports, r as matrix3x3_d_exports } from "../shared/matrix4x4-Dm_tSiH1.mjs";
2
- export { matrix2x2_d_exports as Matrix2x2, matrix3x3_d_exports as Matrix3x3, matrix4x4_d_exports as Matrix4x4 };
1
+ import { n as Matrix3x3$1, r as Matrix2x2$1, t as Matrix4x4$1 } from "../shared/matrix4x4-CaytTaB_.mjs";
2
+
3
+ //#region src/matrix/index.d.ts
4
+ type Matrix2x2 = Matrix2x2$1;
5
+ type Matrix3x3 = Matrix3x3$1;
6
+ type Matrix4x4 = Matrix4x4$1;
7
+ //#endregion
8
+ export { Matrix2x2, Matrix3x3, Matrix4x4 };
9
+ //# sourceMappingURL=index.d.mts.map
@@ -1,16 +1,12 @@
1
- import { t as Vector2 } from "../shared/vector2-DPUY3_eA.mjs";
2
1
  import { t as Pipeable } from "../shared/utils-MCckigYk.mjs";
3
- import { n as Closed } from "../shared/interval-Dy-RMEE3.mjs";
4
- import { t as Interval2d } from "../shared/interval2d-C2id9u31.mjs";
5
- import { a as QuadraticCurve2d, s as LinearCurve2d } from "../shared/rationalCubic2d-DlQfBURs.mjs";
6
- import { a as Continuous, i as cubic2d_d_exports, n as rationalCubic2d_d_exports, o as PathTraits } from "../shared/rationalCubic2d-B6g97ryJ.mjs";
2
+ import { i as LinearCurve2d, r as QuadraticCurve2d } from "../shared/rationalCubic2d-MgMSJaAU.mjs";
3
+ import { n as CubicPath2d$1, r as PathTraits, t as RationalCubicPath2d$1 } from "../shared/rationalCubic2d-D-UevGKu.mjs";
7
4
 
8
5
  //#region src/path/linear2d.internal.d.ts
9
6
  declare const LinearPath2dTypeId: unique symbol;
10
7
  type LinearPath2dTypeId = typeof LinearPath2dTypeId;
11
- declare namespace linear2d_d_exports {
12
- export { Continuous, LinearPath2d, append$1 as append, asContinuous$1 as asContinuous, boundingBox$1 as boundingBox, fromArray$1 as fromArray, isContinuous$1 as isContinuous, isLinearPath2d, length$1 as length, make$1 as make, solve$1 as solve, toPathData$1 as toPathData };
13
- }
8
+ //#endregion
9
+ //#region src/path/linear2d.d.ts
14
10
  /**
15
11
  * A linear path in 2D space.
16
12
  *
@@ -22,125 +18,16 @@ declare namespace linear2d_d_exports {
22
18
  *
23
19
  * @since 1.0.0
24
20
  */
25
- interface LinearPath2d<out Trait = unknown> extends Pipeable, Iterable<LinearCurve2d> {
21
+ interface LinearPath2d$1<out Trait = unknown> extends Pipeable, Iterable<LinearCurve2d> {
26
22
  readonly [LinearPath2dTypeId]: LinearPath2dTypeId;
27
23
  readonly [PathTraits]: Trait;
28
24
  }
29
- /**
30
- * Creates a new `LinearPath2d` instance from a sequence of curves.
31
- *
32
- * @param curves - The curves to create the path from.
33
- * @returns A new `LinearPath2d` instance.
34
- * @since 2.0.0
35
- */
36
- declare const make$1: (...curves: ReadonlyArray<LinearCurve2d>) => LinearPath2d;
37
- /**
38
- * Creates a new `LinearPath2d` instance from an array of curves.
39
- *
40
- * @param curves - The curves to create the path from.
41
- * @returns A new `LinearPath2d` instance.
42
- * @since 2.0.0
43
- */
44
- declare const fromArray$1: (curves: ReadonlyArray<LinearCurve2d>) => LinearPath2d;
45
- /**
46
- * Checks if a value is a `LinearPath2d`.
47
- *
48
- * @param p - The value to check.
49
- * @returns `true` if the value is a `LinearPath2d`, `false` otherwise.
50
- * @since 1.0.0
51
- */
52
- declare const isLinearPath2d: (p: unknown) => p is LinearPath2d;
53
- declare const append$1: {
54
- /**
55
- * Appends a linear curve to a linear path.
56
- *
57
- * @param c - The linear curve to append.
58
- * @returns A function that takes a linear path and returns a new linear path.
59
- * @since 1.0.0
60
- */
61
- (c: LinearCurve2d): (p: LinearPath2d) => LinearPath2d;
62
- /**
63
- * Appends a linear curve to a linear path.
64
- *
65
- * @param p - The linear path to append to.
66
- * @param c - The linear curve to append.
67
- * @returns A new `LinearPath2d` instance with the appended curve.
68
- * @since 1.0.0
69
- */
70
- (p: LinearPath2d, c: LinearCurve2d): LinearPath2d;
71
- };
72
- /**
73
- * Calculates the length of a linear path.
74
- *
75
- * @param p - The linear path to calculate the length of.
76
- * @returns The length of the linear path.
77
- * @since 1.0.0
78
- */
79
- declare const length$1: (p: LinearPath2d) => number;
80
- declare const solve$1: {
81
- /**
82
- * Solves a linear path for a given parameter.
83
- *
84
- * @param u - The parameter to solve for.
85
- * @returns A function that takes a linear path and returns the solved point.
86
- * @since 1.0.0
87
- */
88
- (u: number): (p: LinearPath2d) => Vector2;
89
- /**
90
- * Solves a linear path for a given parameter.
91
- *
92
- * @param p - The linear path to solve.
93
- * @param u - The parameter to solve for.
94
- * @returns The solved point on the linear path.
95
- * @since 1.0.0
96
- */
97
- (p: LinearPath2d, u: number): Vector2;
98
- };
99
- /**
100
- * Serializes a linear path as an SVG path data string (the value of a `<path>`
101
- * element's `d` attribute), using `M` and `L` commands. Discontinuities between
102
- * curves emit a fresh `M` command.
103
- *
104
- * @param p - The linear path to serialize.
105
- * @returns The SVG path data string.
106
- * @since 2.0.0
107
- */
108
- declare const toPathData$1: (p: LinearPath2d) => string;
109
- /**
110
- * Type-narrowing predicate: refines `LinearPath2d<T>` to
111
- * `LinearPath2d<T & Continuous>` when adjacent curves connect at their join
112
- * points.
113
- *
114
- * @param p - The linear path to check.
115
- * @returns `true` when the path is continuous (G⁰).
116
- * @since 2.0.0
117
- */
118
- declare const isContinuous$1: <T>(p: LinearPath2d<T>) => p is LinearPath2d<T & Continuous>;
119
- /**
120
- * Asserts that the linear path is continuous, throwing on failure.
121
- *
122
- * @param p - The linear path to assert against.
123
- * @returns The same path, typed with the `Continuous` brand.
124
- * @throws When the path has a discontinuity between adjacent curves.
125
- * @since 2.0.0
126
- */
127
- declare const asContinuous$1: <T>(p: LinearPath2d<T>) => LinearPath2d<T & Continuous>;
128
- /**
129
- * Computes the axis-aligned bounding box of the path — the smallest closed
130
- * `Box2d` enclosing every segment.
131
- *
132
- * @param p - The linear path.
133
- * @returns A closed `Box2d` enclosing the path.
134
- * @since 2.1.0
135
- */
136
- declare const boundingBox$1: (p: LinearPath2d) => Interval2d<Closed, Closed>;
137
25
  //#endregion
138
26
  //#region src/path/quadratic2d.internal.d.ts
139
27
  declare const QuadraticPath2dTypeId: unique symbol;
140
28
  type QuadraticPath2dTypeId = typeof QuadraticPath2dTypeId;
141
- declare namespace quadratic2d_d_exports {
142
- export { Continuous, QuadraticPath2d, append, asContinuous, boundingBox, fromArray, isContinuous, isQuadraticPath2d, length, make, solve, toPathData };
143
- }
29
+ //#endregion
30
+ //#region src/path/quadratic2d.d.ts
144
31
  /**
145
32
  * A quadratic path in 2D space.
146
33
  *
@@ -151,111 +38,16 @@ declare namespace quadratic2d_d_exports {
151
38
  *
152
39
  * @since 1.0.0
153
40
  */
154
- interface QuadraticPath2d<out Trait = unknown> extends Pipeable, Iterable<QuadraticCurve2d> {
41
+ interface QuadraticPath2d$1<out Trait = unknown> extends Pipeable, Iterable<QuadraticCurve2d> {
155
42
  readonly [QuadraticPath2dTypeId]: QuadraticPath2dTypeId;
156
43
  readonly [PathTraits]: Trait;
157
44
  }
158
- /**
159
- * Creates a new `QuadraticPath2d` instance from a sequence of curves.
160
- *
161
- * @param curves - The curves to create the path from.
162
- * @returns A new `QuadraticPath2d` instance.
163
- * @since 2.0.0
164
- */
165
- declare const make: (...curves: ReadonlyArray<QuadraticCurve2d>) => QuadraticPath2d;
166
- /**
167
- * Creates a new `QuadraticPath2d` instance from an array of curves.
168
- *
169
- * @param curves - The curves to create the path from.
170
- * @returns A new `QuadraticPath2d` instance.
171
- * @since 2.0.0
172
- */
173
- declare const fromArray: (curves: ReadonlyArray<QuadraticCurve2d>) => QuadraticPath2d;
174
- /**
175
- * Checks if a value is a `QuadraticPath2d`.
176
- *
177
- * @param p - The value to check.
178
- * @returns `true` if the value is a `QuadraticPath2d`, `false` otherwise.
179
- * @since 1.0.0
180
- */
181
- declare const isQuadraticPath2d: (p: unknown) => p is QuadraticPath2d;
182
- declare const append: {
183
- /**
184
- * Appends a quadratic curve to a quadratic path.
185
- *
186
- * @param c - The quadratic curve to append.
187
- * @returns A function that takes a quadratic path and returns a new quadratic path.
188
- * @since 1.0.0
189
- */
190
- (c: QuadraticCurve2d): (p: QuadraticPath2d) => QuadraticPath2d;
191
- /**
192
- * Appends a quadratic curve to a quadratic path.
193
- *
194
- * @param p - The quadratic path to append to.
195
- * @param c - The quadratic curve to append.
196
- * @returns A new `QuadraticPath2d` instance with the appended curve.
197
- * @since 1.0.0
198
- */
199
- (p: QuadraticPath2d, c: QuadraticCurve2d): QuadraticPath2d;
200
- };
201
- /**
202
- * Calculates the length of a quadratic path.
203
- *
204
- * @param p - The quadratic path to calculate the length of.
205
- * @returns The length of the path.
206
- */
207
- declare const length: (p: QuadraticPath2d) => number;
208
- declare const solve: {
209
- /**
210
- * Solves a quadratic path at a given parameter.
211
- *
212
- * @param u - The parameter to solve for.
213
- * @returns A function that takes a quadratic path and returns the solved point.
214
- * @since 1.0.0
215
- */
216
- (u: number): (p: QuadraticPath2d) => Vector2;
217
- /**
218
- * Solves a quadratic path at a given parameter.
219
- *
220
- * @param p - The quadratic path to solve.
221
- * @param u - The parameter to solve for.
222
- * @returns The solved point.
223
- * @since 1.0.0
224
- */
225
- (p: QuadraticPath2d, u: number): Vector2;
226
- };
227
- /**
228
- * Serializes a quadratic path as an SVG path data string (the value of a
229
- * `<path>` element's `d` attribute), using `M` and `Q` commands. Discontinuities
230
- * between curves emit a fresh `M` command.
231
- *
232
- * @param p - The quadratic path to serialize.
233
- * @returns The SVG path data string.
234
- * @since 2.0.0
235
- */
236
- declare const toPathData: (p: QuadraticPath2d) => string;
237
- /**
238
- * Type-narrowing predicate: refines `QuadraticPath2d<T>` to
239
- * `QuadraticPath2d<T & Continuous>` when adjacent curves connect.
240
- *
241
- * @since 2.0.0
242
- */
243
- declare const isContinuous: <T>(p: QuadraticPath2d<T>) => p is QuadraticPath2d<T & Continuous>;
244
- /**
245
- * Asserts that the quadratic path is continuous, throwing on failure.
246
- *
247
- * @since 2.0.0
248
- */
249
- declare const asContinuous: <T>(p: QuadraticPath2d<T>) => QuadraticPath2d<T & Continuous>;
250
- /**
251
- * Computes the axis-aligned bounding box of the path — the smallest closed
252
- * `Box2d` enclosing every segment.
253
- *
254
- * @param p - The quadratic path.
255
- * @returns A closed `Box2d` enclosing the path.
256
- * @since 2.1.0
257
- */
258
- declare const boundingBox: (p: QuadraticPath2d) => Interval2d<Closed, Closed>;
259
45
  //#endregion
260
- export { cubic2d_d_exports as CubicPath2d, linear2d_d_exports as LinearPath2d, quadratic2d_d_exports as QuadraticPath2d, rationalCubic2d_d_exports as RationalCubicPath2d };
46
+ //#region src/path/index.d.ts
47
+ type LinearPath2d = LinearPath2d$1;
48
+ type QuadraticPath2d = QuadraticPath2d$1;
49
+ type CubicPath2d = CubicPath2d$1;
50
+ type RationalCubicPath2d = RationalCubicPath2d$1;
51
+ //#endregion
52
+ export { CubicPath2d, LinearPath2d, QuadraticPath2d, RationalCubicPath2d };
261
53
  //# sourceMappingURL=index.d.mts.map
@@ -1,10 +1,10 @@
1
1
  import { t as __exportAll } from "../shared/chunk-25Hzd3z8.mjs";
2
2
  import { Pipeable, dual, invariant } from "../utils.mjs";
3
3
  import { epsEquals } from "../number.mjs";
4
- import { p as unit } from "../shared/interval-05CR6eBf.mjs";
5
- import { r as union } from "../shared/interval2d-8IBZnUOq.mjs";
6
- import { d as boundingBox$5, f as length$5, g as length$4, h as boundingBox$4, m as solve$5, v as solve$4 } from "../shared/rationalCubic2d-Bys2Uory.mjs";
7
- import { n as rationalCubic2d_exports, r as cubic2d_exports } from "../shared/rationalCubic2d-BEgUGSFf.mjs";
4
+ import { p as unit } from "../shared/interval-X1EYuf-T.mjs";
5
+ import { r as union } from "../shared/interval2d-ca0J1NMr.mjs";
6
+ import { _ as length$4, f as boundingBox$5, g as boundingBox$4, h as solve$5, p as length$5, y as solve$4 } from "../shared/rationalCubic2d-D658ltUM.mjs";
7
+ import { n as rationalCubic2d_exports, r as cubic2d_exports } from "../shared/rationalCubic2d-Vw4qGPZj.mjs";
8
8
  //#region src/path/linear2d.internal.ts
9
9
  const LinearPath2dTypeId = Symbol("curvy/path/linear2d");
10
10
  var LinearPath2dImpl = class extends Pipeable {
@@ -158,7 +158,7 @@ const asContinuous$2 = asContinuous$3;
158
158
  *
159
159
  * @param p - The linear path.
160
160
  * @returns A closed `Box2d` enclosing the path.
161
- * @since 2.1.0
161
+ * @since 2.0.0
162
162
  */
163
163
  const boundingBox$2 = boundingBox$3;
164
164
  //#endregion
@@ -316,7 +316,7 @@ const asContinuous = asContinuous$1;
316
316
  *
317
317
  * @param p - The quadratic path.
318
318
  * @returns A closed `Box2d` enclosing the path.
319
- * @since 2.1.0
319
+ * @since 2.0.0
320
320
  */
321
321
  const boundingBox = boundingBox$1;
322
322
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":["isLinearPath2d","make","fromArray","append","length","LinearCurve2d.length","Interval.unit","solve","LinearCurve2d.solve","toPathData","isContinuous","asContinuous","boundingBox","LinearCurve2d.boundingBox","Interval2d.union","make","internal.make","fromArray","internal.fromArray","internal.isLinearPath2d","append","internal.append","length","internal.length","solve","internal.solve","toPathData","internal.toPathData","isContinuous","internal.isContinuous","asContinuous","internal.asContinuous","boundingBox","internal.boundingBox","isQuadraticPath2d","make","fromArray","append","length","QuadraticCurve2d.length","Interval.unit","solve","QuadraticCurve2d.solve","toPathData","isContinuous","asContinuous","boundingBox","QuadraticCurve2d.boundingBox","Interval2d.union","internal.make","internal.fromArray","internal.isQuadraticPath2d","internal.append","internal.length","internal.solve","internal.toPathData","internal.isContinuous","internal.asContinuous","internal.boundingBox"],"sources":["../../src/path/linear2d.internal.ts","../../src/path/linear2d.ts","../../src/path/quadratic2d.internal.ts","../../src/path/quadratic2d.ts"],"sourcesContent":["import * as Interval2d from '../interval/interval2d'\nimport * as LinearCurve2d from '../curve/linear2d'\nimport * as Interval from '../interval/interval'\nimport { dual, Pipeable } from '../utils'\nimport { invariant } from '../utils'\nimport { epsEquals } from '../number'\nimport type { Vector2 } from '../vector/vector2'\nimport type { LinearPath2d } from './linear2d'\nimport { PathTraits, type Continuous } from './traits'\n\nexport const LinearPath2dTypeId: unique symbol = Symbol('curvy/path/linear2d')\nexport type LinearPath2dTypeId = typeof LinearPath2dTypeId\n\nexport class LinearPath2dImpl extends Pipeable implements LinearPath2d<unknown> {\n readonly [LinearPath2dTypeId]: LinearPath2dTypeId = LinearPath2dTypeId\n declare readonly [PathTraits]: unknown\n\n readonly curves: ReadonlyArray<LinearCurve2d.LinearCurve2d>\n\n constructor(curves: ReadonlyArray<LinearCurve2d.LinearCurve2d>) {\n super()\n this.curves = curves\n }\n\n [Symbol.iterator](): Iterator<LinearCurve2d.LinearCurve2d> {\n return this.curves[Symbol.iterator]()\n }\n}\n\nexport const isLinearPath2d = (p: unknown): p is LinearPath2d =>\n typeof p === 'object' && p !== null && LinearPath2dTypeId in p\n\nexport const make = (...curves: ReadonlyArray<LinearCurve2d.LinearCurve2d>): LinearPath2d =>\n new LinearPath2dImpl(curves)\n\nexport const fromArray = (curves: ReadonlyArray<LinearCurve2d.LinearCurve2d>) =>\n new LinearPath2dImpl(curves)\n\nexport const append = dual<\n (c: LinearCurve2d.LinearCurve2d) => (p: LinearPath2d) => LinearPath2d,\n (p: LinearPath2d, c: LinearCurve2d.LinearCurve2d) => LinearPath2d\n>(2, (p: LinearPath2d, c: LinearCurve2d.LinearCurve2d) => fromArray([...p, c]))\n\nexport const length = (p: LinearPath2d) => {\n let total = 0\n for (const curve of p) {\n total += LinearCurve2d.length(curve, Interval.unit)\n }\n\n return total\n}\n\nexport const solve = dual<\n (u: number) => (p: LinearPath2d) => Vector2,\n (p: LinearPath2d, u: number) => Vector2\n>(2, (p: LinearPath2d, u: number) => {\n const curves = p instanceof LinearPath2dImpl ? p.curves : [...p]\n\n if (u === 1) {\n const last = curves.at(-1) as LinearCurve2d.LinearCurve2d\n return LinearCurve2d.solve(last, 1)\n }\n\n const t = u * curves.length\n const i = Math.floor(t)\n const curve = curves[i] as LinearCurve2d.LinearCurve2d\n return LinearCurve2d.solve(curve, t - i)\n})\n\nexport const toPathData = (p: LinearPath2d): string => {\n let result = ''\n let prevEndX = Number.NaN\n let prevEndY = Number.NaN\n\n for (const curve of p) {\n const startX = curve.x.c0\n const startY = curve.y.c0\n const endX = curve.x.c0 + curve.x.c1\n const endY = curve.y.c0 + curve.y.c1\n\n if (!epsEquals(startX, prevEndX) || !epsEquals(startY, prevEndY)) {\n result += ` M ${startX},${startY}`\n }\n result += ` L ${endX},${endY}`\n\n prevEndX = endX\n prevEndY = endY\n }\n\n return result.slice(1)\n}\n\nexport const isContinuous = <T>(p: LinearPath2d<T>): p is LinearPath2d<T & Continuous> => {\n let prevEndX = Number.NaN\n let prevEndY = Number.NaN\n let first = true\n\n for (const curve of p) {\n const startX = curve.x.c0\n const startY = curve.y.c0\n if (!first && (!epsEquals(startX, prevEndX) || !epsEquals(startY, prevEndY))) {\n return false\n }\n prevEndX = curve.x.c0 + curve.x.c1\n prevEndY = curve.y.c0 + curve.y.c1\n first = false\n }\n return true\n}\n\nexport const asContinuous = <T>(p: LinearPath2d<T>): LinearPath2d<T & Continuous> => {\n invariant(isContinuous(p), 'linear path is not continuous')\n return p\n}\n\nexport const boundingBox = (\n p: LinearPath2d,\n): Interval2d.Interval2d<Interval.Closed, Interval.Closed> => {\n const iter = p[Symbol.iterator]()\n const first = iter.next()\n // path invariant: at least one curve, so first.value is defined\n let acc = LinearCurve2d.boundingBox(first.value as LinearCurve2d.LinearCurve2d)\n for (let next = iter.next(); !next.done; next = iter.next()) {\n acc = Interval2d.union(acc, LinearCurve2d.boundingBox(next.value))\n }\n return acc\n}\n","import type { Interval2d } from '../interval/interval2d'\nimport type { LinearCurve2d } from '../curve/linear2d'\nimport type { Closed } from '../interval/interval'\nimport type { Pipeable } from '../utils'\nimport type { Vector2 } from '../vector/vector2'\nimport type { LinearPath2dTypeId } from './linear2d.internal'\nimport * as internal from './linear2d.internal'\nimport type { Continuous, PathTraits } from './traits'\n\nexport type { Continuous } from './traits'\n\n/**\n * A linear path in 2D space.\n *\n * All fields are readonly and immutable, and all operations create new instances.\n *\n * The `Trait` type parameter accumulates trait brands as the path is refined\n * via `isContinuous` / `asContinuous`. A `Continuous` path's `toPathData`\n * skips the per-segment discontinuity check.\n *\n * @since 1.0.0\n */\nexport interface LinearPath2d<out Trait = unknown> extends Pipeable, Iterable<LinearCurve2d> {\n readonly [LinearPath2dTypeId]: LinearPath2dTypeId\n readonly [PathTraits]: Trait\n}\n\n/**\n * Creates a new `LinearPath2d` instance from a sequence of curves.\n *\n * @param curves - The curves to create the path from.\n * @returns A new `LinearPath2d` instance.\n * @since 2.0.0\n */\nexport const make: (...curves: ReadonlyArray<LinearCurve2d>) => LinearPath2d = internal.make\n\n/**\n * Creates a new `LinearPath2d` instance from an array of curves.\n *\n * @param curves - The curves to create the path from.\n * @returns A new `LinearPath2d` instance.\n * @since 2.0.0\n */\nexport const fromArray: (curves: ReadonlyArray<LinearCurve2d>) => LinearPath2d = internal.fromArray\n\n/**\n * Checks if a value is a `LinearPath2d`.\n *\n * @param p - The value to check.\n * @returns `true` if the value is a `LinearPath2d`, `false` otherwise.\n * @since 1.0.0\n */\nexport const isLinearPath2d: (p: unknown) => p is LinearPath2d = internal.isLinearPath2d\n\nexport const append: {\n /**\n * Appends a linear curve to a linear path.\n *\n * @param c - The linear curve to append.\n * @returns A function that takes a linear path and returns a new linear path.\n * @since 1.0.0\n */\n (c: LinearCurve2d): (p: LinearPath2d) => LinearPath2d\n /**\n * Appends a linear curve to a linear path.\n *\n * @param p - The linear path to append to.\n * @param c - The linear curve to append.\n * @returns A new `LinearPath2d` instance with the appended curve.\n * @since 1.0.0\n */\n (p: LinearPath2d, c: LinearCurve2d): LinearPath2d\n} = internal.append\n\n/**\n * Calculates the length of a linear path.\n *\n * @param p - The linear path to calculate the length of.\n * @returns The length of the linear path.\n * @since 1.0.0\n */\nexport const length: (p: LinearPath2d) => number = internal.length\n\nexport const solve: {\n /**\n * Solves a linear path for a given parameter.\n *\n * @param u - The parameter to solve for.\n * @returns A function that takes a linear path and returns the solved point.\n * @since 1.0.0\n */\n (u: number): (p: LinearPath2d) => Vector2\n /**\n * Solves a linear path for a given parameter.\n *\n * @param p - The linear path to solve.\n * @param u - The parameter to solve for.\n * @returns The solved point on the linear path.\n * @since 1.0.0\n */\n (p: LinearPath2d, u: number): Vector2\n} = internal.solve\n\n/**\n * Serializes a linear path as an SVG path data string (the value of a `<path>`\n * element's `d` attribute), using `M` and `L` commands. Discontinuities between\n * curves emit a fresh `M` command.\n *\n * @param p - The linear path to serialize.\n * @returns The SVG path data string.\n * @since 2.0.0\n */\nexport const toPathData: (p: LinearPath2d) => string = internal.toPathData\n\n/**\n * Type-narrowing predicate: refines `LinearPath2d<T>` to\n * `LinearPath2d<T & Continuous>` when adjacent curves connect at their join\n * points.\n *\n * @param p - The linear path to check.\n * @returns `true` when the path is continuous (G⁰).\n * @since 2.0.0\n */\nexport const isContinuous: <T>(p: LinearPath2d<T>) => p is LinearPath2d<T & Continuous> =\n internal.isContinuous\n\n/**\n * Asserts that the linear path is continuous, throwing on failure.\n *\n * @param p - The linear path to assert against.\n * @returns The same path, typed with the `Continuous` brand.\n * @throws When the path has a discontinuity between adjacent curves.\n * @since 2.0.0\n */\nexport const asContinuous: <T>(p: LinearPath2d<T>) => LinearPath2d<T & Continuous> =\n internal.asContinuous\n\n/**\n * Computes the axis-aligned bounding box of the path — the smallest closed\n * `Box2d` enclosing every segment.\n *\n * @param p - The linear path.\n * @returns A closed `Box2d` enclosing the path.\n * @since 2.1.0\n */\nexport const boundingBox: (p: LinearPath2d) => Interval2d<Closed, Closed> = internal.boundingBox\n","import * as Interval2d from '../interval/interval2d'\nimport * as QuadraticCurve2d from '../curve/quadratic2d'\nimport * as Interval from '../interval/interval'\nimport { dual, Pipeable } from '../utils'\nimport { invariant } from '../utils'\nimport { epsEquals } from '../number'\nimport type { Vector2 } from '../vector/vector2'\nimport type { QuadraticPath2d } from './quadratic2d'\nimport { PathTraits, type Continuous } from './traits'\n\nexport const QuadraticPath2dTypeId: unique symbol = Symbol('curvy/path/quadratic2d')\nexport type QuadraticPath2dTypeId = typeof QuadraticPath2dTypeId\n\nexport class QuadraticPath2dImpl extends Pipeable implements QuadraticPath2d<unknown> {\n readonly [QuadraticPath2dTypeId]: QuadraticPath2dTypeId = QuadraticPath2dTypeId\n declare readonly [PathTraits]: unknown\n\n readonly curves: ReadonlyArray<QuadraticCurve2d.QuadraticCurve2d>\n\n constructor(curves: ReadonlyArray<QuadraticCurve2d.QuadraticCurve2d>) {\n super()\n this.curves = curves\n }\n\n [Symbol.iterator](): Iterator<QuadraticCurve2d.QuadraticCurve2d> {\n return this.curves[Symbol.iterator]()\n }\n}\n\nexport const isQuadraticPath2d = (p: unknown): p is QuadraticPath2d =>\n typeof p === 'object' && p !== null && QuadraticPath2dTypeId in p\n\nexport const make = (\n ...curves: ReadonlyArray<QuadraticCurve2d.QuadraticCurve2d>\n): QuadraticPath2d => new QuadraticPath2dImpl(curves)\n\nexport const fromArray = (\n curves: ReadonlyArray<QuadraticCurve2d.QuadraticCurve2d>,\n): QuadraticPath2d => new QuadraticPath2dImpl(curves)\n\nexport const append = dual<\n (c: QuadraticCurve2d.QuadraticCurve2d) => (p: QuadraticPath2d) => QuadraticPath2d,\n (p: QuadraticPath2d, c: QuadraticCurve2d.QuadraticCurve2d) => QuadraticPath2d\n>(2, (p: QuadraticPath2d, c: QuadraticCurve2d.QuadraticCurve2d) => fromArray([...p, c]))\n\nexport const length = (p: QuadraticPath2d) => {\n let total = 0\n for (const curve of p) {\n total += QuadraticCurve2d.length(curve, Interval.unit)\n }\n\n return total\n}\n\nexport const solve = dual<\n (u: number) => (p: QuadraticPath2d) => Vector2,\n (p: QuadraticPath2d, u: number) => Vector2\n>(2, (p: QuadraticPath2d, u: number) => {\n const curves = p instanceof QuadraticPath2dImpl ? p.curves : [...p]\n\n if (u === 1) {\n const last = curves.at(-1) as QuadraticCurve2d.QuadraticCurve2d\n return QuadraticCurve2d.solve(last, 1)\n }\n\n const t = u * curves.length\n const i = Math.floor(t)\n const curve = curves[i] as QuadraticCurve2d.QuadraticCurve2d\n return QuadraticCurve2d.solve(curve, t - i)\n})\n\n// Quadratic Bernstein basis: P(t) = (1-t)²·p0 + 2(1-t)t·p1 + t²·p2\n// expanded gives c0 = p0, c1 = -2p0 + 2p1, c2 = p0 - 2p1 + p2, so:\n// p0 = c0, p1 = c0 + c1/2, p2 = c0 + c1 + c2.\nexport const toPathData = (p: QuadraticPath2d): string => {\n let result = ''\n let prevEndX = Number.NaN\n let prevEndY = Number.NaN\n\n for (const curve of p) {\n const c0x = curve.x.c0\n const c0y = curve.y.c0\n const c1x = curve.x.c1\n const c1y = curve.y.c1\n const c2x = curve.x.c2\n const c2y = curve.y.c2\n\n const startX = c0x\n const startY = c0y\n const ctrlX = c0x + c1x / 2\n const ctrlY = c0y + c1y / 2\n const endX = c0x + c1x + c2x\n const endY = c0y + c1y + c2y\n\n if (!epsEquals(startX, prevEndX) || !epsEquals(startY, prevEndY)) {\n result += ` M ${startX},${startY}`\n }\n result += ` Q ${ctrlX},${ctrlY} ${endX},${endY}`\n\n prevEndX = endX\n prevEndY = endY\n }\n\n return result.slice(1)\n}\n\nexport const isContinuous = <T>(p: QuadraticPath2d<T>): p is QuadraticPath2d<T & Continuous> => {\n let prevEndX = Number.NaN\n let prevEndY = Number.NaN\n let first = true\n\n for (const curve of p) {\n const startX = curve.x.c0\n const startY = curve.y.c0\n if (!first && (!epsEquals(startX, prevEndX) || !epsEquals(startY, prevEndY))) {\n return false\n }\n prevEndX = curve.x.c0 + curve.x.c1 + curve.x.c2\n prevEndY = curve.y.c0 + curve.y.c1 + curve.y.c2\n first = false\n }\n return true\n}\n\nexport const asContinuous = <T>(p: QuadraticPath2d<T>): QuadraticPath2d<T & Continuous> => {\n invariant(isContinuous(p), 'quadratic path is not continuous')\n return p\n}\n\nexport const boundingBox = (\n p: QuadraticPath2d,\n): Interval2d.Interval2d<Interval.Closed, Interval.Closed> => {\n const iter = p[Symbol.iterator]()\n const first = iter.next()\n let acc = QuadraticCurve2d.boundingBox(first.value as QuadraticCurve2d.QuadraticCurve2d)\n for (let next = iter.next(); !next.done; next = iter.next()) {\n acc = Interval2d.union(acc, QuadraticCurve2d.boundingBox(next.value))\n }\n return acc\n}\n","import type { Interval2d } from '../interval/interval2d'\nimport type { QuadraticCurve2d } from '../curve/quadratic2d'\nimport type { Closed } from '../interval/interval'\nimport type { Pipeable } from '../utils'\nimport type { Vector2 } from '../vector/vector2'\nimport type { QuadraticPath2dTypeId } from './quadratic2d.internal'\nimport * as internal from './quadratic2d.internal'\nimport type { Continuous, PathTraits } from './traits'\n\nexport type { Continuous } from './traits'\n\n/**\n * A quadratic path in 2D space.\n *\n * All fields are readonly and immutable, and all operations create new instances.\n *\n * The `Trait` type parameter accumulates trait brands as the path is refined\n * via `isContinuous` / `asContinuous`.\n *\n * @since 1.0.0\n */\nexport interface QuadraticPath2d<out Trait = unknown> extends Pipeable, Iterable<QuadraticCurve2d> {\n readonly [QuadraticPath2dTypeId]: QuadraticPath2dTypeId\n readonly [PathTraits]: Trait\n}\n\n/**\n * Creates a new `QuadraticPath2d` instance from a sequence of curves.\n *\n * @param curves - The curves to create the path from.\n * @returns A new `QuadraticPath2d` instance.\n * @since 2.0.0\n */\nexport const make: (...curves: ReadonlyArray<QuadraticCurve2d>) => QuadraticPath2d = internal.make\n\n/**\n * Creates a new `QuadraticPath2d` instance from an array of curves.\n *\n * @param curves - The curves to create the path from.\n * @returns A new `QuadraticPath2d` instance.\n * @since 2.0.0\n */\nexport const fromArray: (curves: ReadonlyArray<QuadraticCurve2d>) => QuadraticPath2d =\n internal.fromArray\n\n/**\n * Checks if a value is a `QuadraticPath2d`.\n *\n * @param p - The value to check.\n * @returns `true` if the value is a `QuadraticPath2d`, `false` otherwise.\n * @since 1.0.0\n */\nexport const isQuadraticPath2d: (p: unknown) => p is QuadraticPath2d = internal.isQuadraticPath2d\n\nexport const append: {\n /**\n * Appends a quadratic curve to a quadratic path.\n *\n * @param c - The quadratic curve to append.\n * @returns A function that takes a quadratic path and returns a new quadratic path.\n * @since 1.0.0\n */\n (c: QuadraticCurve2d): (p: QuadraticPath2d) => QuadraticPath2d\n /**\n * Appends a quadratic curve to a quadratic path.\n *\n * @param p - The quadratic path to append to.\n * @param c - The quadratic curve to append.\n * @returns A new `QuadraticPath2d` instance with the appended curve.\n * @since 1.0.0\n */\n (p: QuadraticPath2d, c: QuadraticCurve2d): QuadraticPath2d\n} = internal.append\n\n/**\n * Calculates the length of a quadratic path.\n *\n * @param p - The quadratic path to calculate the length of.\n * @returns The length of the path.\n */\nexport const length: (p: QuadraticPath2d) => number = internal.length\n\nexport const solve: {\n /**\n * Solves a quadratic path at a given parameter.\n *\n * @param u - The parameter to solve for.\n * @returns A function that takes a quadratic path and returns the solved point.\n * @since 1.0.0\n */\n (u: number): (p: QuadraticPath2d) => Vector2\n /**\n * Solves a quadratic path at a given parameter.\n *\n * @param p - The quadratic path to solve.\n * @param u - The parameter to solve for.\n * @returns The solved point.\n * @since 1.0.0\n */\n (p: QuadraticPath2d, u: number): Vector2\n} = internal.solve\n\n/**\n * Serializes a quadratic path as an SVG path data string (the value of a\n * `<path>` element's `d` attribute), using `M` and `Q` commands. Discontinuities\n * between curves emit a fresh `M` command.\n *\n * @param p - The quadratic path to serialize.\n * @returns The SVG path data string.\n * @since 2.0.0\n */\nexport const toPathData: (p: QuadraticPath2d) => string = internal.toPathData\n\n/**\n * Type-narrowing predicate: refines `QuadraticPath2d<T>` to\n * `QuadraticPath2d<T & Continuous>` when adjacent curves connect.\n *\n * @since 2.0.0\n */\nexport const isContinuous: <T>(p: QuadraticPath2d<T>) => p is QuadraticPath2d<T & Continuous> =\n internal.isContinuous\n\n/**\n * Asserts that the quadratic path is continuous, throwing on failure.\n *\n * @since 2.0.0\n */\nexport const asContinuous: <T>(p: QuadraticPath2d<T>) => QuadraticPath2d<T & Continuous> =\n internal.asContinuous\n\n/**\n * Computes the axis-aligned bounding box of the path — the smallest closed\n * `Box2d` enclosing every segment.\n *\n * @param p - The quadratic path.\n * @returns A closed `Box2d` enclosing the path.\n * @since 2.1.0\n */\nexport const boundingBox: (p: QuadraticPath2d) => Interval2d<Closed, Closed> = internal.boundingBox\n"],"mappings":";;;;;;;;AAUA,MAAa,qBAAoC,OAAO,sBAAsB;AAG9E,IAAa,mBAAb,cAAsC,SAA0C;CAC9E,CAAU,sBAA0C;CAGpD;CAEA,YAAY,QAAoD;EAC9D,OAAO;EACP,KAAK,SAAS;;CAGhB,CAAC,OAAO,YAAmD;EACzD,OAAO,KAAK,OAAO,OAAO,WAAW;;;AAIzC,MAAaA,oBAAkB,MAC7B,OAAO,MAAM,YAAY,MAAM,QAAQ,sBAAsB;AAE/D,MAAaC,UAAQ,GAAG,WACtB,IAAI,iBAAiB,OAAO;AAE9B,MAAaC,eAAa,WACxB,IAAI,iBAAiB,OAAO;AAE9B,MAAaC,WAAS,KAGpB,IAAI,GAAiB,MAAmCD,YAAU,CAAC,GAAG,GAAG,EAAE,CAAC,CAAC;AAE/E,MAAaE,YAAU,MAAoB;CACzC,IAAI,QAAQ;CACZ,KAAK,MAAM,SAAS,GAClB,SAASC,SAAqB,OAAOC,KAAc;CAGrD,OAAO;;AAGT,MAAaC,UAAQ,KAGnB,IAAI,GAAiB,MAAc;CACnC,MAAM,SAAS,aAAa,mBAAmB,EAAE,SAAS,CAAC,GAAG,EAAE;CAEhE,IAAI,MAAM,GAER,OAAOC,QADM,OAAO,GAAG,GACI,EAAM,EAAE;CAGrC,MAAM,IAAI,IAAI,OAAO;CACrB,MAAM,IAAI,KAAK,MAAM,EAAE;CACvB,MAAM,QAAQ,OAAO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,MACoB,CAAM,MAA2C;CACxF,KAAK,IAAI,OAAO,KAAK,MAAM,EAAE,CAAC,KAAK,MAAM,OAAO,KAAK,MAAM,EACzD,MAAMC,MAAiB,KAAKD,cAA6B,KAAK,MAAM,CAAC;CAEvE,OAAO;;;;;;;;;;;;;;;;;;;;;;;ACzGT,MAAa,OAAwEE;;;;;;;;AASrF,MAAa,YACXC;;;;;;;;AASF,MAAa,oBAA0DC;AAEvE,MAAa,SAkBTC;;;;;;;AAQJ,MAAa,SAAyCC;AAEtD,MAAa,QAkBTC;;;;;;;;;;AAWJ,MAAa,aAA6CC;;;;;;;AAQ1D,MAAa,eACXC;;;;;;AAOF,MAAa,eACXC;;;;;;;;;AAUF,MAAa,cAAkEC"}
1
+ {"version":3,"file":"index.mjs","names":["isLinearPath2d","make","fromArray","append","length","LinearCurve2d.length","Interval.unit","solve","LinearCurve2d.solve","toPathData","isContinuous","asContinuous","boundingBox","LinearCurve2d.boundingBox","Interval2d.union","make","internal.make","fromArray","internal.fromArray","internal.isLinearPath2d","append","internal.append","length","internal.length","solve","internal.solve","toPathData","internal.toPathData","isContinuous","internal.isContinuous","asContinuous","internal.asContinuous","boundingBox","internal.boundingBox","isQuadraticPath2d","make","fromArray","append","length","QuadraticCurve2d.length","Interval.unit","solve","QuadraticCurve2d.solve","toPathData","isContinuous","asContinuous","boundingBox","QuadraticCurve2d.boundingBox","Interval2d.union","internal.make","internal.fromArray","internal.isQuadraticPath2d","internal.append","internal.length","internal.solve","internal.toPathData","internal.isContinuous","internal.asContinuous","internal.boundingBox"],"sources":["../../src/path/linear2d.internal.ts","../../src/path/linear2d.ts","../../src/path/quadratic2d.internal.ts","../../src/path/quadratic2d.ts"],"sourcesContent":["import * as Interval2d from '../interval/interval2d'\nimport * as LinearCurve2d from '../curve/linear2d'\nimport * as Interval from '../interval/interval'\nimport { dual, Pipeable } from '../utils'\nimport { invariant } from '../utils'\nimport { epsEquals } from '../number'\nimport type { Vector2 } from '../vector/vector2'\nimport type { LinearPath2d } from './linear2d'\nimport { PathTraits, type Continuous } from './traits'\n\nexport const LinearPath2dTypeId: unique symbol = Symbol('curvy/path/linear2d')\nexport type LinearPath2dTypeId = typeof LinearPath2dTypeId\n\nexport class LinearPath2dImpl extends Pipeable implements LinearPath2d<unknown> {\n readonly [LinearPath2dTypeId]: LinearPath2dTypeId = LinearPath2dTypeId\n declare readonly [PathTraits]: unknown\n\n readonly curves: ReadonlyArray<LinearCurve2d.LinearCurve2d>\n\n constructor(curves: ReadonlyArray<LinearCurve2d.LinearCurve2d>) {\n super()\n this.curves = curves\n }\n\n [Symbol.iterator](): Iterator<LinearCurve2d.LinearCurve2d> {\n return this.curves[Symbol.iterator]()\n }\n}\n\nexport const isLinearPath2d = (p: unknown): p is LinearPath2d =>\n typeof p === 'object' && p !== null && LinearPath2dTypeId in p\n\nexport const make = (...curves: ReadonlyArray<LinearCurve2d.LinearCurve2d>): LinearPath2d =>\n new LinearPath2dImpl(curves)\n\nexport const fromArray = (curves: ReadonlyArray<LinearCurve2d.LinearCurve2d>) =>\n new LinearPath2dImpl(curves)\n\nexport const append = dual<\n (c: LinearCurve2d.LinearCurve2d) => (p: LinearPath2d) => LinearPath2d,\n (p: LinearPath2d, c: LinearCurve2d.LinearCurve2d) => LinearPath2d\n>(2, (p: LinearPath2d, c: LinearCurve2d.LinearCurve2d) => fromArray([...p, c]))\n\nexport const length = (p: LinearPath2d) => {\n let total = 0\n for (const curve of p) {\n total += LinearCurve2d.length(curve, Interval.unit)\n }\n\n return total\n}\n\nexport const solve = dual<\n (u: number) => (p: LinearPath2d) => Vector2,\n (p: LinearPath2d, u: number) => Vector2\n>(2, (p: LinearPath2d, u: number) => {\n const curves = p instanceof LinearPath2dImpl ? p.curves : [...p]\n\n if (u === 1) {\n const last = curves.at(-1) as LinearCurve2d.LinearCurve2d\n return LinearCurve2d.solve(last, 1)\n }\n\n const t = u * curves.length\n const i = Math.floor(t)\n const curve = curves[i] as LinearCurve2d.LinearCurve2d\n return LinearCurve2d.solve(curve, t - i)\n})\n\nexport const toPathData = (p: LinearPath2d): string => {\n let result = ''\n let prevEndX = Number.NaN\n let prevEndY = Number.NaN\n\n for (const curve of p) {\n const startX = curve.x.c0\n const startY = curve.y.c0\n const endX = curve.x.c0 + curve.x.c1\n const endY = curve.y.c0 + curve.y.c1\n\n if (!epsEquals(startX, prevEndX) || !epsEquals(startY, prevEndY)) {\n result += ` M ${startX},${startY}`\n }\n result += ` L ${endX},${endY}`\n\n prevEndX = endX\n prevEndY = endY\n }\n\n return result.slice(1)\n}\n\nexport const isContinuous = <T>(p: LinearPath2d<T>): p is LinearPath2d<T & Continuous> => {\n let prevEndX = Number.NaN\n let prevEndY = Number.NaN\n let first = true\n\n for (const curve of p) {\n const startX = curve.x.c0\n const startY = curve.y.c0\n if (!first && (!epsEquals(startX, prevEndX) || !epsEquals(startY, prevEndY))) {\n return false\n }\n prevEndX = curve.x.c0 + curve.x.c1\n prevEndY = curve.y.c0 + curve.y.c1\n first = false\n }\n return true\n}\n\nexport const asContinuous = <T>(p: LinearPath2d<T>): LinearPath2d<T & Continuous> => {\n invariant(isContinuous(p), 'linear path is not continuous')\n return p\n}\n\nexport const boundingBox = (\n p: LinearPath2d,\n): Interval2d.Interval2d<Interval.Closed, Interval.Closed> => {\n const iter = p[Symbol.iterator]()\n const first = iter.next()\n // path invariant: at least one curve, so first.value is defined\n let acc = LinearCurve2d.boundingBox(first.value as LinearCurve2d.LinearCurve2d)\n for (let next = iter.next(); !next.done; next = iter.next()) {\n acc = Interval2d.union(acc, LinearCurve2d.boundingBox(next.value))\n }\n return acc\n}\n","import type { Interval2d } from '../interval/interval2d'\nimport type { LinearCurve2d } from '../curve/linear2d'\nimport type { Closed } from '../interval/interval'\nimport type { Pipeable } from '../utils'\nimport type { Vector2 } from '../vector/vector2'\nimport type { LinearPath2dTypeId } from './linear2d.internal'\nimport * as internal from './linear2d.internal'\nimport type { Continuous, PathTraits } from './traits'\n\nexport type { Continuous } from './traits'\n\n/**\n * A linear path in 2D space.\n *\n * All fields are readonly and immutable, and all operations create new instances.\n *\n * The `Trait` type parameter accumulates trait brands as the path is refined\n * via `isContinuous` / `asContinuous`. A `Continuous` path's `toPathData`\n * skips the per-segment discontinuity check.\n *\n * @since 1.0.0\n */\nexport interface LinearPath2d<out Trait = unknown> extends Pipeable, Iterable<LinearCurve2d> {\n readonly [LinearPath2dTypeId]: LinearPath2dTypeId\n readonly [PathTraits]: Trait\n}\n\n/**\n * Creates a new `LinearPath2d` instance from a sequence of curves.\n *\n * @param curves - The curves to create the path from.\n * @returns A new `LinearPath2d` instance.\n * @since 2.0.0\n */\nexport const make: (...curves: ReadonlyArray<LinearCurve2d>) => LinearPath2d = internal.make\n\n/**\n * Creates a new `LinearPath2d` instance from an array of curves.\n *\n * @param curves - The curves to create the path from.\n * @returns A new `LinearPath2d` instance.\n * @since 2.0.0\n */\nexport const fromArray: (curves: ReadonlyArray<LinearCurve2d>) => LinearPath2d = internal.fromArray\n\n/**\n * Checks if a value is a `LinearPath2d`.\n *\n * @param p - The value to check.\n * @returns `true` if the value is a `LinearPath2d`, `false` otherwise.\n * @since 1.0.0\n */\nexport const isLinearPath2d: (p: unknown) => p is LinearPath2d = internal.isLinearPath2d\n\nexport const append: {\n /**\n * Appends a linear curve to a linear path.\n *\n * @param c - The linear curve to append.\n * @returns A function that takes a linear path and returns a new linear path.\n * @since 1.0.0\n */\n (c: LinearCurve2d): (p: LinearPath2d) => LinearPath2d\n /**\n * Appends a linear curve to a linear path.\n *\n * @param p - The linear path to append to.\n * @param c - The linear curve to append.\n * @returns A new `LinearPath2d` instance with the appended curve.\n * @since 1.0.0\n */\n (p: LinearPath2d, c: LinearCurve2d): LinearPath2d\n} = internal.append\n\n/**\n * Calculates the length of a linear path.\n *\n * @param p - The linear path to calculate the length of.\n * @returns The length of the linear path.\n * @since 1.0.0\n */\nexport const length: (p: LinearPath2d) => number = internal.length\n\nexport const solve: {\n /**\n * Solves a linear path for a given parameter.\n *\n * @param u - The parameter to solve for.\n * @returns A function that takes a linear path and returns the solved point.\n * @since 1.0.0\n */\n (u: number): (p: LinearPath2d) => Vector2\n /**\n * Solves a linear path for a given parameter.\n *\n * @param p - The linear path to solve.\n * @param u - The parameter to solve for.\n * @returns The solved point on the linear path.\n * @since 1.0.0\n */\n (p: LinearPath2d, u: number): Vector2\n} = internal.solve\n\n/**\n * Serializes a linear path as an SVG path data string (the value of a `<path>`\n * element's `d` attribute), using `M` and `L` commands. Discontinuities between\n * curves emit a fresh `M` command.\n *\n * @param p - The linear path to serialize.\n * @returns The SVG path data string.\n * @since 2.0.0\n */\nexport const toPathData: (p: LinearPath2d) => string = internal.toPathData\n\n/**\n * Type-narrowing predicate: refines `LinearPath2d<T>` to\n * `LinearPath2d<T & Continuous>` when adjacent curves connect at their join\n * points.\n *\n * @param p - The linear path to check.\n * @returns `true` when the path is continuous (G⁰).\n * @since 2.0.0\n */\nexport const isContinuous: <T>(p: LinearPath2d<T>) => p is LinearPath2d<T & Continuous> =\n internal.isContinuous\n\n/**\n * Asserts that the linear path is continuous, throwing on failure.\n *\n * @param p - The linear path to assert against.\n * @returns The same path, typed with the `Continuous` brand.\n * @throws When the path has a discontinuity between adjacent curves.\n * @since 2.0.0\n */\nexport const asContinuous: <T>(p: LinearPath2d<T>) => LinearPath2d<T & Continuous> =\n internal.asContinuous\n\n/**\n * Computes the axis-aligned bounding box of the path — the smallest closed\n * `Box2d` enclosing every segment.\n *\n * @param p - The linear path.\n * @returns A closed `Box2d` enclosing the path.\n * @since 2.0.0\n */\nexport const boundingBox: (p: LinearPath2d) => Interval2d<Closed, Closed> = internal.boundingBox\n","import * as Interval2d from '../interval/interval2d'\nimport * as QuadraticCurve2d from '../curve/quadratic2d'\nimport * as Interval from '../interval/interval'\nimport { dual, Pipeable } from '../utils'\nimport { invariant } from '../utils'\nimport { epsEquals } from '../number'\nimport type { Vector2 } from '../vector/vector2'\nimport type { QuadraticPath2d } from './quadratic2d'\nimport { PathTraits, type Continuous } from './traits'\n\nexport const QuadraticPath2dTypeId: unique symbol = Symbol('curvy/path/quadratic2d')\nexport type QuadraticPath2dTypeId = typeof QuadraticPath2dTypeId\n\nexport class QuadraticPath2dImpl extends Pipeable implements QuadraticPath2d<unknown> {\n readonly [QuadraticPath2dTypeId]: QuadraticPath2dTypeId = QuadraticPath2dTypeId\n declare readonly [PathTraits]: unknown\n\n readonly curves: ReadonlyArray<QuadraticCurve2d.QuadraticCurve2d>\n\n constructor(curves: ReadonlyArray<QuadraticCurve2d.QuadraticCurve2d>) {\n super()\n this.curves = curves\n }\n\n [Symbol.iterator](): Iterator<QuadraticCurve2d.QuadraticCurve2d> {\n return this.curves[Symbol.iterator]()\n }\n}\n\nexport const isQuadraticPath2d = (p: unknown): p is QuadraticPath2d =>\n typeof p === 'object' && p !== null && QuadraticPath2dTypeId in p\n\nexport const make = (\n ...curves: ReadonlyArray<QuadraticCurve2d.QuadraticCurve2d>\n): QuadraticPath2d => new QuadraticPath2dImpl(curves)\n\nexport const fromArray = (\n curves: ReadonlyArray<QuadraticCurve2d.QuadraticCurve2d>,\n): QuadraticPath2d => new QuadraticPath2dImpl(curves)\n\nexport const append = dual<\n (c: QuadraticCurve2d.QuadraticCurve2d) => (p: QuadraticPath2d) => QuadraticPath2d,\n (p: QuadraticPath2d, c: QuadraticCurve2d.QuadraticCurve2d) => QuadraticPath2d\n>(2, (p: QuadraticPath2d, c: QuadraticCurve2d.QuadraticCurve2d) => fromArray([...p, c]))\n\nexport const length = (p: QuadraticPath2d) => {\n let total = 0\n for (const curve of p) {\n total += QuadraticCurve2d.length(curve, Interval.unit)\n }\n\n return total\n}\n\nexport const solve = dual<\n (u: number) => (p: QuadraticPath2d) => Vector2,\n (p: QuadraticPath2d, u: number) => Vector2\n>(2, (p: QuadraticPath2d, u: number) => {\n const curves = p instanceof QuadraticPath2dImpl ? p.curves : [...p]\n\n if (u === 1) {\n const last = curves.at(-1) as QuadraticCurve2d.QuadraticCurve2d\n return QuadraticCurve2d.solve(last, 1)\n }\n\n const t = u * curves.length\n const i = Math.floor(t)\n const curve = curves[i] as QuadraticCurve2d.QuadraticCurve2d\n return QuadraticCurve2d.solve(curve, t - i)\n})\n\n// Quadratic Bernstein basis: P(t) = (1-t)²·p0 + 2(1-t)t·p1 + t²·p2\n// expanded gives c0 = p0, c1 = -2p0 + 2p1, c2 = p0 - 2p1 + p2, so:\n// p0 = c0, p1 = c0 + c1/2, p2 = c0 + c1 + c2.\nexport const toPathData = (p: QuadraticPath2d): string => {\n let result = ''\n let prevEndX = Number.NaN\n let prevEndY = Number.NaN\n\n for (const curve of p) {\n const c0x = curve.x.c0\n const c0y = curve.y.c0\n const c1x = curve.x.c1\n const c1y = curve.y.c1\n const c2x = curve.x.c2\n const c2y = curve.y.c2\n\n const startX = c0x\n const startY = c0y\n const ctrlX = c0x + c1x / 2\n const ctrlY = c0y + c1y / 2\n const endX = c0x + c1x + c2x\n const endY = c0y + c1y + c2y\n\n if (!epsEquals(startX, prevEndX) || !epsEquals(startY, prevEndY)) {\n result += ` M ${startX},${startY}`\n }\n result += ` Q ${ctrlX},${ctrlY} ${endX},${endY}`\n\n prevEndX = endX\n prevEndY = endY\n }\n\n return result.slice(1)\n}\n\nexport const isContinuous = <T>(p: QuadraticPath2d<T>): p is QuadraticPath2d<T & Continuous> => {\n let prevEndX = Number.NaN\n let prevEndY = Number.NaN\n let first = true\n\n for (const curve of p) {\n const startX = curve.x.c0\n const startY = curve.y.c0\n if (!first && (!epsEquals(startX, prevEndX) || !epsEquals(startY, prevEndY))) {\n return false\n }\n prevEndX = curve.x.c0 + curve.x.c1 + curve.x.c2\n prevEndY = curve.y.c0 + curve.y.c1 + curve.y.c2\n first = false\n }\n return true\n}\n\nexport const asContinuous = <T>(p: QuadraticPath2d<T>): QuadraticPath2d<T & Continuous> => {\n invariant(isContinuous(p), 'quadratic path is not continuous')\n return p\n}\n\nexport const boundingBox = (\n p: QuadraticPath2d,\n): Interval2d.Interval2d<Interval.Closed, Interval.Closed> => {\n const iter = p[Symbol.iterator]()\n const first = iter.next()\n let acc = QuadraticCurve2d.boundingBox(first.value as QuadraticCurve2d.QuadraticCurve2d)\n for (let next = iter.next(); !next.done; next = iter.next()) {\n acc = Interval2d.union(acc, QuadraticCurve2d.boundingBox(next.value))\n }\n return acc\n}\n","import type { Interval2d } from '../interval/interval2d'\nimport type { QuadraticCurve2d } from '../curve/quadratic2d'\nimport type { Closed } from '../interval/interval'\nimport type { Pipeable } from '../utils'\nimport type { Vector2 } from '../vector/vector2'\nimport type { QuadraticPath2dTypeId } from './quadratic2d.internal'\nimport * as internal from './quadratic2d.internal'\nimport type { Continuous, PathTraits } from './traits'\n\nexport type { Continuous } from './traits'\n\n/**\n * A quadratic path in 2D space.\n *\n * All fields are readonly and immutable, and all operations create new instances.\n *\n * The `Trait` type parameter accumulates trait brands as the path is refined\n * via `isContinuous` / `asContinuous`.\n *\n * @since 1.0.0\n */\nexport interface QuadraticPath2d<out Trait = unknown> extends Pipeable, Iterable<QuadraticCurve2d> {\n readonly [QuadraticPath2dTypeId]: QuadraticPath2dTypeId\n readonly [PathTraits]: Trait\n}\n\n/**\n * Creates a new `QuadraticPath2d` instance from a sequence of curves.\n *\n * @param curves - The curves to create the path from.\n * @returns A new `QuadraticPath2d` instance.\n * @since 2.0.0\n */\nexport const make: (...curves: ReadonlyArray<QuadraticCurve2d>) => QuadraticPath2d = internal.make\n\n/**\n * Creates a new `QuadraticPath2d` instance from an array of curves.\n *\n * @param curves - The curves to create the path from.\n * @returns A new `QuadraticPath2d` instance.\n * @since 2.0.0\n */\nexport const fromArray: (curves: ReadonlyArray<QuadraticCurve2d>) => QuadraticPath2d =\n internal.fromArray\n\n/**\n * Checks if a value is a `QuadraticPath2d`.\n *\n * @param p - The value to check.\n * @returns `true` if the value is a `QuadraticPath2d`, `false` otherwise.\n * @since 1.0.0\n */\nexport const isQuadraticPath2d: (p: unknown) => p is QuadraticPath2d = internal.isQuadraticPath2d\n\nexport const append: {\n /**\n * Appends a quadratic curve to a quadratic path.\n *\n * @param c - The quadratic curve to append.\n * @returns A function that takes a quadratic path and returns a new quadratic path.\n * @since 1.0.0\n */\n (c: QuadraticCurve2d): (p: QuadraticPath2d) => QuadraticPath2d\n /**\n * Appends a quadratic curve to a quadratic path.\n *\n * @param p - The quadratic path to append to.\n * @param c - The quadratic curve to append.\n * @returns A new `QuadraticPath2d` instance with the appended curve.\n * @since 1.0.0\n */\n (p: QuadraticPath2d, c: QuadraticCurve2d): QuadraticPath2d\n} = internal.append\n\n/**\n * Calculates the length of a quadratic path.\n *\n * @param p - The quadratic path to calculate the length of.\n * @returns The length of the path.\n */\nexport const length: (p: QuadraticPath2d) => number = internal.length\n\nexport const solve: {\n /**\n * Solves a quadratic path at a given parameter.\n *\n * @param u - The parameter to solve for.\n * @returns A function that takes a quadratic path and returns the solved point.\n * @since 1.0.0\n */\n (u: number): (p: QuadraticPath2d) => Vector2\n /**\n * Solves a quadratic path at a given parameter.\n *\n * @param p - The quadratic path to solve.\n * @param u - The parameter to solve for.\n * @returns The solved point.\n * @since 1.0.0\n */\n (p: QuadraticPath2d, u: number): Vector2\n} = internal.solve\n\n/**\n * Serializes a quadratic path as an SVG path data string (the value of a\n * `<path>` element's `d` attribute), using `M` and `Q` commands. Discontinuities\n * between curves emit a fresh `M` command.\n *\n * @param p - The quadratic path to serialize.\n * @returns The SVG path data string.\n * @since 2.0.0\n */\nexport const toPathData: (p: QuadraticPath2d) => string = internal.toPathData\n\n/**\n * Type-narrowing predicate: refines `QuadraticPath2d<T>` to\n * `QuadraticPath2d<T & Continuous>` when adjacent curves connect.\n *\n * @since 2.0.0\n */\nexport const isContinuous: <T>(p: QuadraticPath2d<T>) => p is QuadraticPath2d<T & Continuous> =\n internal.isContinuous\n\n/**\n * Asserts that the quadratic path is continuous, throwing on failure.\n *\n * @since 2.0.0\n */\nexport const asContinuous: <T>(p: QuadraticPath2d<T>) => QuadraticPath2d<T & Continuous> =\n internal.asContinuous\n\n/**\n * Computes the axis-aligned bounding box of the path — the smallest closed\n * `Box2d` enclosing every segment.\n *\n * @param p - The quadratic path.\n * @returns A closed `Box2d` enclosing the path.\n * @since 2.0.0\n */\nexport const boundingBox: (p: QuadraticPath2d) => Interval2d<Closed, Closed> = internal.boundingBox\n"],"mappings":";;;;;;;;AAUA,MAAa,qBAAoC,OAAO,sBAAsB;AAG9E,IAAa,mBAAb,cAAsC,SAA0C;CAC9E,CAAU,sBAA0C;CAGpD;CAEA,YAAY,QAAoD;EAC9D,OAAO;EACP,KAAK,SAAS;;CAGhB,CAAC,OAAO,YAAmD;EACzD,OAAO,KAAK,OAAO,OAAO,WAAW;;;AAIzC,MAAaA,oBAAkB,MAC7B,OAAO,MAAM,YAAY,MAAM,QAAQ,sBAAsB;AAE/D,MAAaC,UAAQ,GAAG,WACtB,IAAI,iBAAiB,OAAO;AAE9B,MAAaC,eAAa,WACxB,IAAI,iBAAiB,OAAO;AAE9B,MAAaC,WAAS,KAGpB,IAAI,GAAiB,MAAmCD,YAAU,CAAC,GAAG,GAAG,EAAE,CAAC,CAAC;AAE/E,MAAaE,YAAU,MAAoB;CACzC,IAAI,QAAQ;CACZ,KAAK,MAAM,SAAS,GAClB,SAASC,SAAqB,OAAOC,KAAc;CAGrD,OAAO;;AAGT,MAAaC,UAAQ,KAGnB,IAAI,GAAiB,MAAc;CACnC,MAAM,SAAS,aAAa,mBAAmB,EAAE,SAAS,CAAC,GAAG,EAAE;CAEhE,IAAI,MAAM,GAER,OAAOC,QADM,OAAO,GAAG,GACI,EAAM,EAAE;CAGrC,MAAM,IAAI,IAAI,OAAO;CACrB,MAAM,IAAI,KAAK,MAAM,EAAE;CACvB,MAAM,QAAQ,OAAO;CACrB,OAAOA,QAAoB,OAAO,IAAI,EAAE;EACxC;AAEF,MAAaC,gBAAc,MAA4B;CACrD,IAAI,SAAS;CACb,IAAI,WAAW;CACf,IAAI,WAAW;CAEf,KAAK,MAAM,SAAS,GAAG;EACrB,MAAM,SAAS,MAAM,EAAE;EACvB,MAAM,S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MAAa,OAAwEE;;;;;;;;AASrF,MAAa,YACXC;;;;;;;;AASF,MAAa,oBAA0DC;AAEvE,MAAa,SAkBTC;;;;;;;AAQJ,MAAa,SAAyCC;AAEtD,MAAa,QAkBTC;;;;;;;;;;AAWJ,MAAa,aAA6CC;;;;;;;AAQ1D,MAAa,eACXC;;;;;;AAOF,MAAa,eACXC;;;;;;;;;AAUF,MAAa,cAAkEC"}
@@ -1,2 +1,9 @@
1
- import { i as quadratic_d_exports, n as cubic_d_exports, o as linear_d_exports } from "../shared/cubic-BajUY0JT.mjs";
2
- export { cubic_d_exports as CubicPolynomial, linear_d_exports as LinearPolynomial, quadratic_d_exports as QuadraticPolynomial };
1
+ import { n as QuadraticPolynomial$1, r as LinearPolynomial$1, t as CubicPolynomial$1 } from "../shared/cubic-DkBqcZf-.mjs";
2
+
3
+ //#region src/polynomial/index.d.ts
4
+ type LinearPolynomial = LinearPolynomial$1;
5
+ type QuadraticPolynomial = QuadraticPolynomial$1;
6
+ type CubicPolynomial = CubicPolynomial$1;
7
+ //#endregion
8
+ export { CubicPolynomial, LinearPolynomial, QuadraticPolynomial };
9
+ //# sourceMappingURL=index.d.mts.map
@@ -1,3 +1,3 @@
1
- import { t as cubic_exports } from "../shared/cubic-CpHAx8cC.mjs";
2
- import { o as quadratic_exports, p as linear_exports } from "../shared/quadratic-CamozcFc.mjs";
1
+ import { t as cubic_exports } from "../shared/cubic-CMonq6bg.mjs";
2
+ import { o as quadratic_exports, p as linear_exports } from "../shared/quadratic-DyeMtvET.mjs";
3
3
  export { cubic_exports as CubicPolynomial, linear_exports as LinearPolynomial, quadratic_exports as QuadraticPolynomial };
@@ -1,7 +1,7 @@
1
1
  import { t as __exportAll } from "./chunk-25Hzd3z8.mjs";
2
2
  import { roundDown } from "../number.mjs";
3
3
  import { a as vectorProductLeft, n as make } from "./matrix4x4-Ck2WROK-.mjs";
4
- import { r as fromVector } from "./cubic-CpHAx8cC.mjs";
4
+ import { r as fromVector } from "./cubic-CMonq6bg.mjs";
5
5
  //#region src/characteristic/characteristic.ts
6
6
  var characteristic_exports = /* @__PURE__ */ __exportAll({
7
7
  apply: () => apply,
@@ -19,7 +19,7 @@ var characteristic_exports = /* @__PURE__ */ __exportAll({
19
19
  * IS the Bézier spline family — combined with control points (via {@link apply}),
20
20
  * it produces the cubic polynomial that parameterizes the curve.
21
21
  *
22
- * @since 2.1.0
22
+ * @since 2.0.0
23
23
  */
24
24
  const cubicBezier = make(1, 0, 0, 0, -3, 3, 0, 0, 3, -6, 3, 0, -1, 3, -3, 1);
25
25
  /**
@@ -28,7 +28,7 @@ const cubicBezier = make(1, 0, 0, 0, -3, 3, 0, 0, 3, -6, 3, 0, -1, 3, -3, 1);
28
28
  * Maps Hermite control data `(P₀, V₀, P₁, V₁)` — two endpoints and two
29
29
  * tangent vectors — to monomial cubic coefficients.
30
30
  *
31
- * @since 2.1.0
31
+ * @since 2.0.0
32
32
  */
33
33
  const cubicHermite = make(1, 0, 0, 0, 0, 1, 0, 0, -3, -2, 3, -1, 2, 1, -2, 1);
34
34
  /**
@@ -39,7 +39,7 @@ const cubicHermite = make(1, 0, 0, 0, 0, 1, 0, 0, -3, -2, 3, -1, 2, 1, -2, 1);
39
39
  * application produces a C² piecewise spline; the curve does not generally
40
40
  * pass through the control points.
41
41
  *
42
- * @since 2.1.0
42
+ * @since 2.0.0
43
43
  */
44
44
  const cubicBasisSpline = make(1 / 6, 4 / 6, roundDown(1 / 6), 0, -.5, 0, .5, 0, .5, -1, .5, 0, -1 / 6, .5, -.5, 1 / 6);
45
45
  const cardinalCache = /* @__PURE__ */ new Map();
@@ -58,7 +58,7 @@ const cardinalCache = /* @__PURE__ */ new Map();
58
58
  *
59
59
  * @param tension - The tension parameter.
60
60
  * @returns The characteristic matrix for that tension.
61
- * @since 2.1.0
61
+ * @since 2.0.0
62
62
  */
63
63
  const cubicCardinal = (tension) => {
64
64
  let m = cardinalCache.get(tension);
@@ -73,7 +73,7 @@ const cubicCardinal = (tension) => {
73
73
  * The most common Cardinal-family variant; reused widely enough to deserve
74
74
  * a constant.
75
75
  *
76
- * @since 2.1.0
76
+ * @since 2.0.0
77
77
  */
78
78
  const cubicCatmullRom = cubicCardinal(.5);
79
79
  /**
@@ -93,12 +93,12 @@ const cubicCatmullRom = cubicCardinal(.5);
93
93
  * @param matrix - The characteristic matrix of the spline family.
94
94
  * @param channels - One `Vector4` per output polynomial, packing the four control values for that channel.
95
95
  * @returns A tuple of cubic polynomials, one per input channel.
96
- * @since 2.1.0
96
+ * @since 2.0.0
97
97
  */
98
98
  const apply = (matrix, ...channels) => {
99
99
  return channels.map((c) => fromVector(vectorProductLeft(matrix, c)));
100
100
  };
101
101
  //#endregion
102
- export { cubicCardinal as a, cubicBezier as i, characteristic_exports as n, cubicHermite as o, cubicBasisSpline as r, apply as t };
102
+ export { cubicHermite as a, cubicBezier as i, characteristic_exports as n, cubicBasisSpline as r, apply as t };
103
103
 
104
- //# sourceMappingURL=characteristic-B9nCh_cx.mjs.map
104
+ //# sourceMappingURL=characteristic-DLlhja-I.mjs.map