curvy 2.0.0-alpha.4 → 2.0.0-alpha.6

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.
@@ -1,11 +1,14 @@
1
- import { n as Weighted, t as Vector2 } from "../shared/vector2-euuV_bNQ.mjs";
1
+ import { n as Weighted, t as Vector2 } from "../shared/vector2-5GyA0jBj.mjs";
2
2
  import { t as Pipeable } from "../shared/utils-MCckigYk.mjs";
3
+ import { t as AtMostOne } from "../shared/solution-Cf_zoKFU.mjs";
4
+ import { r as CubicPath2d, t as RationalCubicPath2d } from "../shared/rationalCubic2d-DFFvp5S1.mjs";
3
5
 
4
6
  //#region src/splines/rationalBezier2d.internal.d.ts
5
7
  declare const RationalBezier2dTypeId: unique symbol;
6
8
  type RationalBezier2dTypeId = typeof RationalBezier2dTypeId;
7
- //#endregion
8
- //#region src/splines/rationalBezier2d.d.ts
9
+ declare namespace rationalBezier2d_d_exports {
10
+ export { RationalBezier2d, fromArray$4 as fromArray, fromBezier, fromPoints, fromTuples$4 as fromTuples, isRationalBezier2d, make$4 as make, subdivide$1 as subdivide, toPath$4 as toPath };
11
+ }
9
12
  /**
10
13
  * A piecewise rational cubic Bézier curve in 2D space.
11
14
  *
@@ -26,16 +29,132 @@ type RationalBezier2dTypeId = typeof RationalBezier2dTypeId;
26
29
  *
27
30
  * @since 2.0.0
28
31
  */
29
- interface RationalBezier2d$1 extends Pipeable {
32
+ interface RationalBezier2d extends Pipeable {
30
33
  readonly [RationalBezier2dTypeId]: RationalBezier2dTypeId;
31
34
  [Symbol.iterator](): IterableIterator<Weighted>;
32
35
  }
36
+ /**
37
+ * Checks if a value is a `RationalBezier2d`.
38
+ *
39
+ * @param p - The value to check.
40
+ * @returns `true` if the value is a `RationalBezier2d`, `false` otherwise.
41
+ * @since 2.0.0
42
+ */
43
+ declare const isRationalBezier2d: (p: unknown) => p is RationalBezier2d;
44
+ /**
45
+ * Creates a new single-segment `RationalBezier2d` from four weighted control points.
46
+ *
47
+ * Equal weights produce a curve coincident with the corresponding polynomial
48
+ * cubic Bézier; unequal weights produce a true rational curve capable of
49
+ * representing conics exactly.
50
+ *
51
+ * @param p0 - The first weighted control point (curve start).
52
+ * @param p1 - The second weighted control point (start handle).
53
+ * @param p2 - The third weighted control point (end handle).
54
+ * @param p3 - The fourth weighted control point (curve end).
55
+ * @returns A new `RationalBezier2d` instance.
56
+ * @since 2.0.0
57
+ */
58
+ declare const make$4: (p0: Weighted, p1: Weighted, p2: Weighted, p3: Weighted) => RationalBezier2d;
59
+ /**
60
+ * Creates a new `RationalBezier2d` from an array of weighted control points.
61
+ *
62
+ * The array must contain `(n * 3) + 1` entries to describe `n` joined cubic
63
+ * segments.
64
+ *
65
+ * @param points - The weighted control points.
66
+ * @returns A new `RationalBezier2d` instance.
67
+ * @since 2.0.0
68
+ */
69
+ declare const fromArray$4: (points: ReadonlyArray<Weighted>) => RationalBezier2d;
70
+ /**
71
+ * Creates a new `RationalBezier2d` from an array of `[x, y, weight]` tuples.
72
+ * Weight is the projective denominator at each control point — `1` everywhere
73
+ * yields the polynomial Bézier; varying weights bend the curve toward the
74
+ * heavier control points.
75
+ *
76
+ * @param tuples - The weighted control points as `[x, y, weight]` tuples.
77
+ * @returns A new `RationalBezier2d` instance.
78
+ * @since 2.0.0
79
+ */
80
+ declare const fromTuples$4: (tuples: ReadonlyArray<readonly [number, number, number]>) => RationalBezier2d;
81
+ /**
82
+ * Creates a new single-segment `RationalBezier2d` from four points with all
83
+ * weights equal to one.
84
+ *
85
+ * Convenience constructor for callers who want the rational evaluator but
86
+ * don't yet have non-unit weights — the resulting curve is mathematically
87
+ * equivalent to the corresponding `Bezier2d.make(p0, p1, p2, p3)` and can
88
+ * later be subdivided or recombined using the rational machinery without
89
+ * conversion overhead.
90
+ *
91
+ * @param p0 - The first control point (curve start).
92
+ * @param p1 - The second control point (start handle).
93
+ * @param p2 - The third control point (end handle).
94
+ * @param p3 - The fourth control point (curve end).
95
+ * @returns A new `RationalBezier2d` with unit weights.
96
+ * @since 2.0.0
97
+ */
98
+ declare const fromPoints: (p0: Vector2, p1: Vector2, p2: Vector2, p3: Vector2) => RationalBezier2d;
99
+ /**
100
+ * Lifts a non-rational `Bezier2d` into a `RationalBezier2d` by assigning
101
+ * unit weight to every control point. The two curves trace the same path.
102
+ *
103
+ * @param b - The non-rational bezier to lift.
104
+ * @returns A new `RationalBezier2d` with unit weights.
105
+ * @since 2.0.0
106
+ */
107
+ declare const fromBezier: (b: Bezier2d) => RationalBezier2d;
108
+ /**
109
+ * Converts a `RationalBezier2d` to a `RationalCubicPath2d`.
110
+ *
111
+ * Each segment's four homogeneous control points are expanded into three
112
+ * per-segment monomial cubic polynomials — `x`, `y`, and the shared
113
+ * denominator `w` — yielding a path whose evaluator is three Horner passes
114
+ * plus two divisions per call.
115
+ *
116
+ * Mirrors `Bezier2d.toPath`: spline construction is converted to path
117
+ * evaluation form, and forward evaluation thereafter routes through the
118
+ * path's `solve`.
119
+ *
120
+ * @param r - The rational bezier to convert.
121
+ * @returns A new `RationalCubicPath2d` instance representing the same curve.
122
+ * @since 2.0.0
123
+ */
124
+ declare const toPath$4: (r: RationalBezier2d) => RationalCubicPath2d;
125
+ declare const subdivide$1: {
126
+ /**
127
+ * Splits a `RationalBezier2d` at the given global parameter `u ∈ (0, 1)`
128
+ * using de Casteljau's algorithm in homogeneous coordinates. The two
129
+ * returned beziers together trace the same curve as the input — the left
130
+ * covers `[0, u]`, the right covers `[u, 1]`.
131
+ *
132
+ * The subdivided halves' control-point weights generally differ from the
133
+ * original's even at unit input weights; this is expected and preserves
134
+ * the curve shape exactly.
135
+ *
136
+ * @param r - The rational bezier to split.
137
+ * @param u - The split parameter in the open interval `(0, 1)`.
138
+ * @returns A two-element tuple of the left and right halves.
139
+ * @since 2.0.0
140
+ */
141
+ (r: RationalBezier2d, u: number): [RationalBezier2d, RationalBezier2d];
142
+ /**
143
+ * Splits a `RationalBezier2d` at the given global parameter `u ∈ (0, 1)`.
144
+ *
145
+ * @param u - The split parameter in the open interval `(0, 1)`.
146
+ * @returns A function that takes a rational bezier and returns the halves.
147
+ * @since 2.0.0
148
+ */
149
+ (u: number): (r: RationalBezier2d) => [RationalBezier2d, RationalBezier2d];
150
+ };
33
151
  //#endregion
34
152
  //#region src/splines/bezier2d.internal.d.ts
35
153
  declare const Bezier2dTypeId: unique symbol;
36
154
  type Bezier2dTypeId = typeof Bezier2dTypeId;
37
- //#endregion
38
- //#region src/splines/bezier2d.d.ts
155
+ declare namespace bezier2d_d_exports {
156
+ export { Bezier2d, append$3 as append, appendAccelerationAligned, appendCurvatureAligned, appendTangentAligned, appendVelocityAligned, fromArray$3 as fromArray, fromRational, fromTuples$3 as fromTuples, isCubicBezier2d, make$3 as make, subdivide, toPath$3 as toPath };
157
+ }
39
158
  /**
40
159
  * A Bézier curve in 2D space.
41
160
  *
@@ -46,16 +165,195 @@ type Bezier2dTypeId = typeof Bezier2dTypeId;
46
165
  *
47
166
  * @since 1.0.0
48
167
  */
49
- interface Bezier2d$1 extends Pipeable {
168
+ interface Bezier2d extends Pipeable {
50
169
  readonly [Bezier2dTypeId]: Bezier2dTypeId;
51
170
  [Symbol.iterator](): IterableIterator<Vector2>;
52
171
  }
172
+ /**
173
+ * Creates a new `Bezier2d` instance.
174
+ *
175
+ * @param p0 - The first control point.
176
+ * @param p1 - The second control point.
177
+ * @param p2 - The third control point.
178
+ * @param p3 - The fourth control point.
179
+ * @returns A new `Bezier2d` instance.
180
+ * @since 1.0.0
181
+ */
182
+ declare const make$3: (p0: Vector2, p1: Vector2, p2: Vector2, p3: Vector2) => Bezier2d;
183
+ /**
184
+ * Creates a new `Bezier2d` instance from an array of control points.
185
+ *
186
+ * @param points - The control points.
187
+ * @returns A new `Bezier2d` instance.
188
+ * @since 1.0.0
189
+ */
190
+ declare const fromArray$3: (points: ReadonlyArray<Vector2>) => Bezier2d;
191
+ /**
192
+ * Creates a new `Bezier2d` from an array of `[x, y]` tuples. Convenient for
193
+ * data sourced from JSON, CSV, or other tuple-shaped formats.
194
+ *
195
+ * @param tuples - The control points as `[x, y]` tuples.
196
+ * @returns A new `Bezier2d` instance.
197
+ * @since 2.0.0
198
+ */
199
+ declare const fromTuples$3: (tuples: ReadonlyArray<readonly [number, number]>) => Bezier2d;
200
+ /**
201
+ * Checks if a value is a `Bezier2d`.
202
+ *
203
+ * @param p - The value to check.
204
+ * @returns `true` if the value is a `Bezier2d`, `false` otherwise.
205
+ * @since 1.0.0
206
+ */
207
+ declare const isCubicBezier2d: (p: unknown) => p is Bezier2d;
208
+ declare const append$3: {
209
+ /**
210
+ * Appends control points to a `Bezier2d`.
211
+ *
212
+ * @param p1 - The second control point (first tangent).
213
+ * @param p2 - The third control point (second tangent).
214
+ * @param p3 - The fourth control point (end point).
215
+ * @returns A function that takes a `Bezier2d` and returns a new `Bezier2d` instance with the appended control points.
216
+ */
217
+ (p1: Vector2, p2: Vector2, p3: Vector2): (p: Bezier2d) => Bezier2d;
218
+ /**
219
+ * Appends control points to a `Bezier2d`.
220
+ *
221
+ * @param p - The `Bezier2d` to append the control points to.
222
+ * @param p1 - The second control point (first tangent).
223
+ * @param p2 - The third control point (second tangent).
224
+ * @param p3 - The fourth control point (end point).
225
+ * @returns A new `Bezier2d` instance with the appended control points.
226
+ */
227
+ (p: Bezier2d, p1: Vector2, p2: Vector2, p3: Vector2): Bezier2d;
228
+ };
229
+ declare const appendTangentAligned: {
230
+ /**
231
+ * Appends control points to a `Bezier2d` with aligned tangents.
232
+ *
233
+ * @param ratio - The ratio of the tangents.
234
+ * @param p2 - The third control point (second tangent).
235
+ * @param p3 - The fourth control point (end point).
236
+ * @returns A function that takes a `Bezier2d` and returns a new `Bezier2d` instance with the appended control points.
237
+ */
238
+ (ratio: number, p2: Vector2, p3: Vector2): (p: Bezier2d) => Bezier2d;
239
+ /**
240
+ * Appends control points to a `Bezier2d` with aligned tangents.
241
+ *
242
+ * @param p - The `Bezier2d` to append the control points to.
243
+ * @param ratio - The ratio of the tangents.
244
+ * @param p2 - The third control point (second tangent).
245
+ * @param p3 - The fourth control point (end point).
246
+ * @returns A new `Bezier2d` instance with the appended control points.
247
+ */
248
+ (p: Bezier2d, ratio: number, p2: Vector2, p3: Vector2): Bezier2d;
249
+ };
250
+ declare const appendCurvatureAligned: {
251
+ /**
252
+ * Appends control points to a `Bezier2d` with aligned curvature (G² continuity).
253
+ *
254
+ * @param a - The first curvature parameter.
255
+ * @param b - The second curvature parameter.
256
+ * @param p6 - The sixth control point (end point).
257
+ * @returns A function that takes a `Bezier2d` and returns a new `Bezier2d` instance with the appended control points.
258
+ */
259
+ (a: number, b: number, p6: Vector2): (p: Bezier2d) => Bezier2d;
260
+ /**
261
+ * Appends control points to a `Bezier2d` with aligned curvature (G² continuity).
262
+ *
263
+ * @param p - The `Bezier2d` to append the control points to.
264
+ * @param a - The first curvature parameter.
265
+ * @param b - The second curvature parameter.
266
+ * @param p6 - The sixth control point (end point).
267
+ * @returns A new `Bezier2d` instance with the appended control points.
268
+ */
269
+ (p: Bezier2d, a: number, b: number, p6: Vector2): Bezier2d;
270
+ };
271
+ declare const appendVelocityAligned: {
272
+ /**
273
+ * Appends control points to a `Bezier2d` with aligned velocity.
274
+ *
275
+ * @param p2 - The second control point (first tangent).
276
+ * @param p3 - The third control point (second tangent).
277
+ * @returns A function that takes a `Bezier2d` and returns a new `Bezier2d` instance with the appended control points.
278
+ */
279
+ (p2: Vector2, p3: Vector2): (p: Bezier2d) => Bezier2d;
280
+ /**
281
+ * Appends control points to a `Bezier2d` with aligned velocity.
282
+ *
283
+ * @param p - The `Bezier2d` to append the control points to.
284
+ * @param p2 - The second control point (first tangent).
285
+ * @param p3 - The third control point (second tangent).
286
+ * @returns A new `Bezier2d` instance with the appended control points.
287
+ */
288
+ (p: Bezier2d, p2: Vector2, p3: Vector2): Bezier2d;
289
+ };
290
+ declare const appendAccelerationAligned: {
291
+ /**
292
+ * Appends control points to a `Bezier2d` with aligned acceleration.
293
+ *
294
+ * @param p3 - The third control point (second tangent).
295
+ * @returns A function that takes a `Bezier2d` and returns a new `Bezier2d` instance with the appended control points.
296
+ */
297
+ (p3: Vector2): (p: Bezier2d) => Bezier2d;
298
+ /**
299
+ * Appends control points to a `Bezier2d` with aligned acceleration.
300
+ *
301
+ * @param p - The `Bezier2d` to append the control points to.
302
+ * @param p3 - The third control point (second tangent).
303
+ * @returns A new `Bezier2d` instance with the appended control points.
304
+ */
305
+ (p: Bezier2d, p3: Vector2): Bezier2d;
306
+ };
307
+ /**
308
+ * Converts a `Bezier2d` to a `CubicPath2d`.
309
+ *
310
+ * @param p - The `Bezier2d` to convert.
311
+ * @returns A new `CubicPath2d` instance representing the same curve as the `Bezier2d`.
312
+ * @since 1.0.0
313
+ */
314
+ declare const toPath$3: (p: Bezier2d) => CubicPath2d;
315
+ /**
316
+ * Attempts to lower a `RationalBezier2d` to a non-rational `Bezier2d`.
317
+ *
318
+ * Succeeds with `Solution.one(bezier)` when the rational curve's weights are
319
+ * uniform (the curve is mathematically a polynomial Bézier) and returns
320
+ * `Solution.none` otherwise — the rational curve cannot be represented
321
+ * exactly by a non-rational cubic Bézier.
322
+ *
323
+ * @param r - The rational bezier to convert.
324
+ * @returns Either a `Bezier2d` instance or `Solution.none`.
325
+ * @since 2.0.0
326
+ */
327
+ declare const fromRational: (r: RationalBezier2d) => AtMostOne<Bezier2d>;
328
+ declare const subdivide: {
329
+ /**
330
+ * Splits a `Bezier2d` at the given global parameter `u ∈ (0, 1)` using
331
+ * de Casteljau's algorithm. The two returned beziers together trace the
332
+ * same curve as the input — the left covers `[0, u]`, the right covers
333
+ * `[u, 1]`.
334
+ *
335
+ * @param b - The bezier to split.
336
+ * @param u - The split parameter in the open interval `(0, 1)`.
337
+ * @returns A two-element tuple of the left and right halves.
338
+ * @since 1.1.0
339
+ */
340
+ (b: Bezier2d, u: number): [Bezier2d, Bezier2d];
341
+ /**
342
+ * Splits a `Bezier2d` at the given global parameter `u ∈ (0, 1)`.
343
+ *
344
+ * @param u - The split parameter in the open interval `(0, 1)`.
345
+ * @returns A function that takes a bezier and returns the two halves.
346
+ * @since 1.1.0
347
+ */
348
+ (u: number): (b: Bezier2d) => [Bezier2d, Bezier2d];
349
+ };
53
350
  //#endregion
54
351
  //#region src/splines/cardinal2d.internal.d.ts
55
352
  declare const Cardinal2dTypeId: unique symbol;
56
353
  type Cardinal2dTypeId = typeof Cardinal2dTypeId;
57
- //#endregion
58
- //#region src/splines/cardinal2d.d.ts
354
+ declare namespace cardinal2d_d_exports {
355
+ export { Cardinal2d, Options, append$2 as append, fromArray$2 as fromArray, fromTuples$2 as fromTuples, isCardinal2d, make$2 as make, prepend$2 as prepend, toBezier$2 as toBezier, toPath$2 as toPath, withAlpha, withDuplicatedEndpoints, withInterpolatedEndpoints, withOptions, withReflectedEndpoints, withTension };
356
+ }
59
357
  /**
60
358
  * A Cardinal spline in 2D space.
61
359
  *
@@ -73,19 +371,260 @@ type Cardinal2dTypeId = typeof Cardinal2dTypeId;
73
371
  *
74
372
  * @since 1.0.0
75
373
  */
76
- interface Cardinal2d$1 extends Pipeable {
374
+ interface Cardinal2d extends Pipeable {
77
375
  readonly [Cardinal2dTypeId]: Cardinal2dTypeId;
78
376
  readonly points: ReadonlyArray<Vector2>;
79
377
  readonly tension: number;
80
378
  readonly alpha: number;
81
379
  [Symbol.iterator](): IterableIterator<Vector2>;
82
380
  }
381
+ /**
382
+ * Configuration for a Cardinal spline. Both fields are optional and carry
383
+ * sensible defaults.
384
+ *
385
+ * - **`tension`** controls how loose or tight the curve is at each interior
386
+ * control point. `tension = 0.5` is classical Catmull-Rom; `tension = 0`
387
+ * produces zero-tangent endpoints (smoothstep-shaped segments between
388
+ * consecutive control points); higher values produce looser, more curved
389
+ * shapes. Default: `0.5`.
390
+ *
391
+ * - **`alpha`** controls how chord lengths between control points scale the
392
+ * tangents. `alpha = 0` is uniform parameterization (classical Catmull-Rom),
393
+ * which can produce cusps and self-intersections when control points
394
+ * cluster. `alpha = 0.5` is centripetal parameterization — Yuksel's
395
+ * recommended default, eliminating those failure modes at minimal shape
396
+ * cost. `alpha = 1` is chordal parameterization. Default: `0.5`
397
+ * (centripetal).
398
+ *
399
+ * @since 2.0.0
400
+ */
401
+ interface Options {
402
+ readonly tension?: number;
403
+ readonly alpha?: number;
404
+ }
405
+ /**
406
+ * Checks if a value is a `Cardinal2d`.
407
+ *
408
+ * @param p - The value to check.
409
+ * @returns `true` if the value is a `Cardinal2d`, `false` otherwise.
410
+ * @since 1.0.0
411
+ */
412
+ declare const isCardinal2d: (p: unknown) => p is Cardinal2d;
413
+ declare const make$2: {
414
+ /**
415
+ * Creates a new `Cardinal2d` with default tension and alpha.
416
+ *
417
+ * @param p0 - The first control point.
418
+ * @param p1 - The second control point.
419
+ * @param points - The remaining control points.
420
+ * @returns A new `Cardinal2d` instance.
421
+ * @since 1.0.0
422
+ */
423
+ (p0: Vector2, p1: Vector2, ...points: ReadonlyArray<Vector2>): Cardinal2d;
424
+ /**
425
+ * Creates a new `Cardinal2d` with the given options.
426
+ *
427
+ * @param options - Tension and alpha. See {@link Options}.
428
+ * @param p0 - The first control point.
429
+ * @param p1 - The second control point.
430
+ * @param points - The remaining control points.
431
+ * @returns A new `Cardinal2d` instance.
432
+ * @since 2.0.0
433
+ */
434
+ (options: Options, p0: Vector2, p1: Vector2, ...points: ReadonlyArray<Vector2>): Cardinal2d;
435
+ };
436
+ /**
437
+ * Creates a new `Cardinal2d` from an array of control points.
438
+ *
439
+ * @param points - The control points.
440
+ * @param options - Tension and alpha. See {@link Options}. Defaults to centripetal Catmull-Rom.
441
+ * @returns A new `Cardinal2d` instance.
442
+ * @since 1.0.0
443
+ */
444
+ declare const fromArray$2: (points: ReadonlyArray<Vector2>, options?: Options) => Cardinal2d;
445
+ /**
446
+ * Creates a new `Cardinal2d` from an array of `[x, y]` tuples.
447
+ *
448
+ * @param tuples - The control points as `[x, y]` tuples.
449
+ * @param options - Tension and alpha. See {@link Options}. Defaults to centripetal Catmull-Rom.
450
+ * @returns A new `Cardinal2d` instance.
451
+ * @since 2.0.0
452
+ */
453
+ declare const fromTuples$2: (tuples: ReadonlyArray<readonly [number, number]>, options?: Options) => Cardinal2d;
454
+ declare const append$2: {
455
+ /**
456
+ * Appends control points to a `Cardinal2d`. Tension and alpha are preserved.
457
+ *
458
+ * @param points - The control points to append.
459
+ * @returns A function that takes a `Cardinal2d` and returns a new instance.
460
+ * @since 1.0.0
461
+ */
462
+ (...points: ReadonlyArray<Vector2>): (c: Cardinal2d) => Cardinal2d;
463
+ /**
464
+ * Appends control points to a `Cardinal2d`. Tension and alpha are preserved.
465
+ *
466
+ * @param c - The `Cardinal2d` to append to.
467
+ * @param points - The control points to append.
468
+ * @returns A new `Cardinal2d` instance.
469
+ * @since 1.0.0
470
+ */
471
+ (c: Cardinal2d, ...points: ReadonlyArray<Vector2>): Cardinal2d;
472
+ };
473
+ declare const prepend$2: {
474
+ /**
475
+ * Prepends control points to a `Cardinal2d`. Tension and alpha are preserved.
476
+ *
477
+ * @param points - The control points to prepend.
478
+ * @returns A function that takes a `Cardinal2d` and returns a new instance.
479
+ * @since 1.0.0
480
+ */
481
+ (...points: ReadonlyArray<Vector2>): (c: Cardinal2d) => Cardinal2d;
482
+ /**
483
+ * Prepends control points to a `Cardinal2d`. Tension and alpha are preserved.
484
+ *
485
+ * @param c - The `Cardinal2d` to prepend to.
486
+ * @param points - The control points to prepend.
487
+ * @returns A new `Cardinal2d` instance.
488
+ * @since 1.0.0
489
+ */
490
+ (c: Cardinal2d, ...points: ReadonlyArray<Vector2>): Cardinal2d;
491
+ };
492
+ /**
493
+ * Doubles the endpoints of a `Cardinal2d` spline. Tension and alpha are
494
+ * preserved.
495
+ *
496
+ * @param c - The `Cardinal2d` to duplicate the endpoints of.
497
+ * @returns A new `Cardinal2d` instance with duplicated endpoints.
498
+ * @since 1.0.0
499
+ */
500
+ declare const withDuplicatedEndpoints: (c: Cardinal2d) => Cardinal2d;
501
+ /**
502
+ * Pads the spline so that it interpolates its first and last control points.
503
+ * The resulting path passes through `points[0]` at `u = 0` and `points[points.length - 1]`
504
+ * at `u = 1`. Equivalent to {@link withReflectedEndpoints} called with
505
+ * `scale = 0` (and to {@link withDuplicatedEndpoints}), but reads more
506
+ * directly as the user-facing intent.
507
+ *
508
+ * Tension and alpha are preserved.
509
+ *
510
+ * @param c - The `Cardinal2d` to pad.
511
+ * @returns A new `Cardinal2d` instance whose first and last control points are interpolated.
512
+ * @since 2.0.0
513
+ */
514
+ declare const withInterpolatedEndpoints: (c: Cardinal2d) => Cardinal2d;
515
+ declare const withReflectedEndpoints: {
516
+ /**
517
+ * Reflects the endpoints of a `Cardinal2d` spline. Tension and alpha are
518
+ * preserved.
519
+ *
520
+ * @param scale - The scale factor for the reflection.
521
+ * @returns A function that takes a `Cardinal2d` and returns a new instance.
522
+ * @since 1.0.0
523
+ */
524
+ (scale: number): (c: Cardinal2d) => Cardinal2d;
525
+ /**
526
+ * Reflects the endpoints of a `Cardinal2d` spline. Tension and alpha are
527
+ * preserved.
528
+ *
529
+ * @param c - The `Cardinal2d` to reflect the endpoints of.
530
+ * @param scale - The scale factor for the reflection.
531
+ * @returns A new `Cardinal2d` instance with reflected endpoints.
532
+ * @since 1.0.0
533
+ */
534
+ (c: Cardinal2d, scale?: number): Cardinal2d;
535
+ };
536
+ declare const withTension: {
537
+ /**
538
+ * Returns a new `Cardinal2d` with the given tension; control points and
539
+ * alpha are preserved.
540
+ *
541
+ * @param tension - The new tension value.
542
+ * @returns A function that takes a `Cardinal2d` and returns a new instance.
543
+ * @since 2.0.0
544
+ */
545
+ (tension: number): (c: Cardinal2d) => Cardinal2d;
546
+ /**
547
+ * Returns a new `Cardinal2d` with the given tension; control points and
548
+ * alpha are preserved.
549
+ *
550
+ * @param c - The `Cardinal2d` to update.
551
+ * @param tension - The new tension value.
552
+ * @returns A new `Cardinal2d` instance.
553
+ * @since 2.0.0
554
+ */
555
+ (c: Cardinal2d, tension: number): Cardinal2d;
556
+ };
557
+ declare const withAlpha: {
558
+ /**
559
+ * Returns a new `Cardinal2d` with the given alpha; control points and
560
+ * tension are preserved.
561
+ *
562
+ * @param alpha - The new alpha value.
563
+ * @returns A function that takes a `Cardinal2d` and returns a new instance.
564
+ * @since 2.0.0
565
+ */
566
+ (alpha: number): (c: Cardinal2d) => Cardinal2d;
567
+ /**
568
+ * Returns a new `Cardinal2d` with the given alpha; control points and
569
+ * tension are preserved.
570
+ *
571
+ * @param c - The `Cardinal2d` to update.
572
+ * @param alpha - The new alpha value.
573
+ * @returns A new `Cardinal2d` instance.
574
+ * @since 2.0.0
575
+ */
576
+ (c: Cardinal2d, alpha: number): Cardinal2d;
577
+ };
578
+ declare const withOptions: {
579
+ /**
580
+ * Returns a new `Cardinal2d` with the given options merged into the
581
+ * existing tension/alpha. Omitted fields are preserved from the input.
582
+ *
583
+ * @param options - The options to merge.
584
+ * @returns A function that takes a `Cardinal2d` and returns a new instance.
585
+ * @since 2.0.0
586
+ */
587
+ (options: Options): (c: Cardinal2d) => Cardinal2d;
588
+ /**
589
+ * Returns a new `Cardinal2d` with the given options merged in.
590
+ *
591
+ * @param c - The `Cardinal2d` to update.
592
+ * @param options - The options to merge.
593
+ * @returns A new `Cardinal2d` instance.
594
+ * @since 2.0.0
595
+ */
596
+ (c: Cardinal2d, options: Options): Cardinal2d;
597
+ };
598
+ /**
599
+ * Converts a `Cardinal2d` to a `CubicPath2d` using the spline's `tension` and
600
+ * `alpha`. With the default options (`{ tension: 0.5, alpha: 0.5 }`) the
601
+ * result is a centripetal Catmull-Rom path — the canonical recommended
602
+ * Catmull-Rom variant, which avoids the cusps and self-intersections that
603
+ * uniform Catmull-Rom can produce when control points cluster.
604
+ *
605
+ * @param c - The Cardinal spline.
606
+ * @returns A new `CubicPath2d` representing the spline.
607
+ * @since 1.0.0
608
+ */
609
+ declare const toPath$2: (c: Cardinal2d) => CubicPath2d;
610
+ /**
611
+ * Converts a `Cardinal2d` to a `Bezier2d`. Equivalent to {@link toPath}
612
+ * followed by per-segment monomial-to-Bernstein conversion — same underlying
613
+ * curve, expressed in cubic Bézier control-point form. Uses the spline's
614
+ * `tension` and `alpha`.
615
+ *
616
+ * @param c - The Cardinal spline.
617
+ * @returns A new `Bezier2d` representing the spline.
618
+ * @since 1.0.0
619
+ */
620
+ declare const toBezier$2: (c: Cardinal2d) => Bezier2d;
83
621
  //#endregion
84
622
  //#region src/splines/hermite2d.internal.d.ts
85
623
  declare const Hermite2dTypeId: unique symbol;
86
624
  type Hermite2dTypeId = typeof Hermite2dTypeId;
87
- //#endregion
88
- //#region src/splines/hermite2d.d.ts
625
+ declare namespace hermite2d_d_exports {
626
+ export { Hermite2d, append$1 as append, fromArray$1 as fromArray, fromTuples$1 as fromTuples, isHermite2d, make$1 as make, prepend$1 as prepend, toBezier$1 as toBezier, toPath$1 as toPath };
627
+ }
89
628
  /**
90
629
  * A Hermite spline in 2D space.
91
630
  *
@@ -96,16 +635,111 @@ type Hermite2dTypeId = typeof Hermite2dTypeId;
96
635
  *
97
636
  * @since 1.0.0
98
637
  */
99
- interface Hermite2d$1 extends Pipeable {
638
+ interface Hermite2d extends Pipeable {
100
639
  readonly [Hermite2dTypeId]: Hermite2dTypeId;
101
640
  [Symbol.iterator](): IterableIterator<Vector2>;
102
641
  }
642
+ /**
643
+ * Checks if a value is a `Hermite2d`.
644
+ *
645
+ * @param p - The value to check.
646
+ * @returns `true` if the value is a `Hermite2d`, `false` otherwise.
647
+ * @since 1.0.0
648
+ */
649
+ declare const isHermite2d: (p: unknown) => p is Hermite2d;
650
+ /**
651
+ * Creates a new `Hermite2d` instance.
652
+ *
653
+ * @param p0 - The first control point.
654
+ * @param v0 - The first tangent vector.
655
+ * @param p1 - The second control point.
656
+ * @param v1 - The second tangent vector.
657
+ * @returns A new `Hermite2d` instance.
658
+ * @since 1.0.0
659
+ */
660
+ declare const make$1: (p0: Vector2, v0: Vector2, p1: Vector2, v1: Vector2) => Hermite2d;
661
+ /**
662
+ * Creates a new `Hermite2d` instance from an array of control points.
663
+ *
664
+ * @param points - The control points.
665
+ * @returns A new `Hermite2d` instance.
666
+ * @since 1.0.0
667
+ */
668
+ declare const fromArray$1: (points: ReadonlyArray<Vector2>) => Hermite2d;
669
+ /**
670
+ * Creates a new `Hermite2d` from an array of `[x, y]` tuples, alternating
671
+ * `[position, velocity]` pairs.
672
+ *
673
+ * @param tuples - The point/velocity pairs as `[x, y]` tuples.
674
+ * @returns A new `Hermite2d` instance.
675
+ * @since 2.0.0
676
+ */
677
+ declare const fromTuples$1: (tuples: ReadonlyArray<readonly [number, number]>) => Hermite2d;
678
+ declare const append$1: {
679
+ /**
680
+ * Appends a new control point and tangent vector to the Hermite spline.
681
+ *
682
+ * @param p1 - The new control point.
683
+ * @param v1 - The new tangent vector.
684
+ * @returns A new `Hermite2d` instance with the appended control point and tangent vector.
685
+ * @since 1.0.0
686
+ */
687
+ (p1: Vector2, v1: Vector2): (p: Hermite2d) => Hermite2d;
688
+ /**
689
+ * Appends a new control point and tangent vector to the Hermite spline.
690
+ *
691
+ * @param p - The `Hermite2d` to append the control point and tangent vector to.
692
+ * @param p1 - The new control point.
693
+ * @param v1 - The new tangent vector.
694
+ * @returns A new `Hermite2d` instance with the appended control point and tangent vector.
695
+ * @since 1.0.0
696
+ */
697
+ (p: Hermite2d, p1: Vector2, v1: Vector2): Hermite2d;
698
+ };
699
+ declare const prepend$1: {
700
+ /**
701
+ * Prepends a new control point and tangent vector to the Hermite spline.
702
+ *
703
+ * @param p0 - The new control point.
704
+ * @param v0 - The new tangent vector.
705
+ * @returns A new `Hermite2d` instance with the prepended control point and tangent vector.
706
+ * @since 1.0.0
707
+ */
708
+ (p0: Vector2, v0: Vector2): (p: Hermite2d) => Hermite2d;
709
+ /**
710
+ * Prepends a new control point and tangent vector to the Hermite spline.
711
+ *
712
+ * @param p - The `Hermite2d` to prepend the control point and tangent vector to.
713
+ * @param p0 - The new control point.
714
+ * @param v0 - The new tangent vector.
715
+ * @returns A new `Hermite2d` instance with the prepended control point and tangent vector.
716
+ * @since 1.0.0
717
+ */
718
+ (p: Hermite2d, p0: Vector2, v0: Vector2): Hermite2d;
719
+ };
720
+ /**
721
+ * Creates a new `CubicPath2d` instance from a `Hermite2d`.
722
+ *
723
+ * @param p - The `Hermite2d` to convert.
724
+ * @returns A new `CubicPath2d` instance.
725
+ * @since 1.0.0
726
+ */
727
+ declare const toPath$1: (p: Hermite2d) => CubicPath2d;
728
+ /**
729
+ * Converts a `Hermite2d` to a `Bezier2d`.
730
+ *
731
+ * @param p - The `Hermite2d` to convert.
732
+ * @returns A new `Bezier2d` instance.
733
+ * @since 1.0.0
734
+ */
735
+ declare const toBezier$1: (p: Hermite2d) => Bezier2d;
103
736
  //#endregion
104
737
  //#region src/splines/basis2d.internal.d.ts
105
738
  declare const Basis2dTypeId: unique symbol;
106
739
  type Basis2dTypeId = typeof Basis2dTypeId;
107
- //#endregion
108
- //#region src/splines/basis2d.d.ts
740
+ declare namespace basis2d_d_exports {
741
+ export { Basis2d, append, fromArray, fromTuples, isBasis2d, make, prepend, toBezier, toPath, withTriplicatedEndpoints };
742
+ }
109
743
  /**
110
744
  * A Basis Spline (uniform cubic B-spline) in 2D space.
111
745
  *
@@ -116,17 +750,109 @@ type Basis2dTypeId = typeof Basis2dTypeId;
116
750
  *
117
751
  * @since 1.0.0
118
752
  */
119
- interface Basis2d$1 extends Pipeable {
753
+ interface Basis2d extends Pipeable {
120
754
  readonly [Basis2dTypeId]: Basis2dTypeId;
121
755
  [Symbol.iterator](): Iterator<Vector2>;
122
756
  }
757
+ /**
758
+ * Checks if a value is a `Basis2d`.
759
+ *
760
+ * @param p - The value to check.
761
+ * @returns `true` if the value is a `Basis2d`, `false` otherwise.
762
+ * @since 1.0.0
763
+ */
764
+ declare const isBasis2d: (p: unknown) => p is Basis2d;
765
+ /**
766
+ * Creates a new `Basis2d` instance.
767
+ *
768
+ * @param p0 - The first control point.
769
+ * @param p1 - The second control point.
770
+ * @param p2 - The third control point.
771
+ * @param p3 - The fourth control point.
772
+ * @returns A new `Basis2d` instance.
773
+ * @since 1.0.0
774
+ */
775
+ declare const make: (p0: Vector2, p1: Vector2, p2: Vector2, p3: Vector2) => Basis2d;
776
+ /**
777
+ * Creates a new `Basis2d` instance from an array of control points.
778
+ *
779
+ * @param points - The control points.
780
+ * @returns A new `Basis2d` instance.
781
+ * @since 1.0.0
782
+ */
783
+ declare const fromArray: (points: ReadonlyArray<Vector2>) => Basis2d;
784
+ /**
785
+ * Creates a new `Basis2d` from an array of `[x, y]` tuples.
786
+ *
787
+ * @param tuples - The control points as `[x, y]` tuples.
788
+ * @returns A new `Basis2d` instance.
789
+ * @since 2.0.0
790
+ */
791
+ declare const fromTuples: (tuples: ReadonlyArray<readonly [number, number]>) => Basis2d;
792
+ declare const append: {
793
+ /**
794
+ * Appends control points to a `Basis2d`.
795
+ *
796
+ * @param points - The control points to append.
797
+ * @returns A function that takes a `Basis2d` and returns a new `Basis2d` instance with the appended control points.
798
+ * @since 1.0.0
799
+ */
800
+ (...points: ReadonlyArray<Vector2>): (p: Basis2d) => Basis2d;
801
+ /**
802
+ * Appends control points to a `Basis2d`.
803
+ *
804
+ * @param p - The `Basis2d` to append the control points to.
805
+ * @param points - The control points to append.
806
+ * @returns A new `Basis2d` instance with the appended control points.
807
+ * @since 1.0.0
808
+ */
809
+ (p: Basis2d, ...points: ReadonlyArray<Vector2>): Basis2d;
810
+ };
811
+ declare const prepend: {
812
+ /**
813
+ * Prepends control points to a `Basis2d`.
814
+ *
815
+ * @param points - The control points to prepend.
816
+ * @returns A function that takes a `Basis2d` and returns a new `Basis2d` instance with the prepended control points.
817
+ * @since 1.0.0
818
+ */
819
+ (...points: ReadonlyArray<Vector2>): (p: Basis2d) => Basis2d;
820
+ /**
821
+ * Prepends control points to a `Basis2d`.
822
+ *
823
+ * @param p - The `Basis2d` to prepend the control points to.
824
+ * @param points - The control points to prepend.
825
+ * @returns A new `Basis2d` instance with the prepended control points.
826
+ * @since 1.0.0
827
+ */
828
+ (p: Basis2d, ...points: ReadonlyArray<Vector2>): Basis2d;
829
+ };
830
+ /**
831
+ * Triplicates the endpoints of a `Basis2d`.
832
+ *
833
+ * This is useful for creating a closed loop spline.
834
+ *
835
+ * @param p - The `Basis2d` to triplicate the endpoints of.
836
+ * @returns A new `Basis2d` instance with the triplicated endpoints.
837
+ * @since 1.0.0
838
+ */
839
+ declare const withTriplicatedEndpoints: (p: Basis2d) => Basis2d;
840
+ /**
841
+ * Creates a new `Path2d` from a `Basis2d`.
842
+ *
843
+ * @param p - The `Basis2d` to convert to a `Path2d`.
844
+ * @returns A new `Path2d` instance.
845
+ * @since 1.0.0
846
+ */
847
+ declare const toPath: (p: Basis2d) => CubicPath2d;
848
+ /**
849
+ * Converts a `Basis2d` to a `Bezier2d`.
850
+ *
851
+ * @param p - The `Basis2d` to convert.
852
+ * @returns A new `Bezier2d` instance.
853
+ * @since 1.0.0
854
+ */
855
+ declare const toBezier: (p: Basis2d) => Bezier2d;
123
856
  //#endregion
124
- //#region src/splines/index.d.ts
125
- type Bezier2d = Bezier2d$1;
126
- type Cardinal2d = Cardinal2d$1;
127
- type Hermite2d = Hermite2d$1;
128
- type Basis2d = Basis2d$1;
129
- type RationalBezier2d = RationalBezier2d$1;
130
- //#endregion
131
- export { Basis2d, Bezier2d, Cardinal2d, Hermite2d, RationalBezier2d };
857
+ export { basis2d_d_exports as Basis2d, bezier2d_d_exports as Bezier2d, cardinal2d_d_exports as Cardinal2d, hermite2d_d_exports as Hermite2d, rationalBezier2d_d_exports as RationalBezier2d };
132
858
  //# sourceMappingURL=index.d.mts.map