curvy 2.0.0-alpha.11 → 2.0.0-alpha.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/characteristic/index.mjs +1 -1
- package/dist/curve/index.mjs +1 -1
- package/dist/curve/rationalCubic2d.d.ts +195 -11
- package/dist/interval/index.mjs +1 -1
- package/dist/monotonicity/index.d.ts +4 -0
- package/dist/monotonicity/index.mjs +2 -0
- package/dist/monotonicity/monotonicity.d.ts +80 -0
- package/dist/path/index.mjs +16 -387
- package/dist/path/index.mjs.map +1 -1
- package/dist/path/rationalCubic2d.d.ts +27 -0
- package/dist/polynomial/cubic.d.ts +2 -2
- package/dist/polynomial/index.mjs +2 -2
- package/dist/polynomial/linear.d.ts +7 -7
- package/dist/polynomial/quadratic.d.ts +2 -2
- package/dist/shared/{characteristic-Hb7F8SBw.mjs → characteristic-BkEr-rr8.mjs} +2 -2
- package/dist/shared/{characteristic-Hb7F8SBw.mjs.map → characteristic-BkEr-rr8.mjs.map} +1 -1
- package/dist/shared/{cubic-DHJrzZJN.mjs → cubic-BL6dpuHh.mjs} +18 -30
- package/dist/shared/cubic-BL6dpuHh.mjs.map +1 -0
- package/dist/shared/{interval2d-DPmvk_Qe.mjs → interval2d-AtneyI45.mjs} +1 -1
- package/dist/shared/{interval2d-DPmvk_Qe.mjs.map → interval2d-AtneyI45.mjs.map} +1 -1
- package/dist/shared/monotonicity-BdebFOtv.mjs +34 -0
- package/dist/shared/monotonicity-BdebFOtv.mjs.map +1 -0
- package/dist/shared/{quadratic-BZmfZE71.mjs → quadratic-DPrUsFCp.mjs} +9 -9
- package/dist/shared/quadratic-DPrUsFCp.mjs.map +1 -0
- package/dist/shared/{rationalCubic2d-IroMR6AA.mjs → rationalCubic2d-CeHgpNht.mjs} +373 -79
- package/dist/shared/rationalCubic2d-CeHgpNht.mjs.map +1 -0
- package/dist/shared/{rationalCubic2d-nN-oSrLr.mjs → rationalCubic2d-H1J2Fjyy.mjs} +404 -23
- package/dist/shared/rationalCubic2d-H1J2Fjyy.mjs.map +1 -0
- package/dist/shared/{solution-B6KY1E7M.mjs → solution-B2JdOZpe.mjs} +1 -1
- package/dist/shared/{solution-B6KY1E7M.mjs.map → solution-B2JdOZpe.mjs.map} +1 -1
- package/dist/solution/index.mjs +1 -1
- package/dist/splines/index.d.ts +3 -0
- package/dist/splines/index.mjs +218 -120
- package/dist/splines/index.mjs.map +1 -1
- package/dist/splines/linear2d.d.ts +102 -0
- package/dist/splines/linear2d.internal.d.ts +2 -0
- package/package.json +5 -1
- package/dist/polynomial/monotonicity.d.ts +0 -3
- package/dist/shared/cubic-DHJrzZJN.mjs.map +0 -1
- package/dist/shared/quadratic-BZmfZE71.mjs.map +0 -1
- package/dist/shared/rationalCubic2d-IroMR6AA.mjs.map +0 -1
- package/dist/shared/rationalCubic2d-nN-oSrLr.mjs.map +0 -1
package/dist/splines/index.mjs
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
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 { a as make$
|
|
5
|
-
import { t as make$
|
|
6
|
-
import { n as transpose, t as make$
|
|
4
|
+
import { a as make$12, c as subtract, i as magnitude, o as makeWeighted, r as isVector2, s as scale, t as add } from "../shared/vector2-CSkaMXvp.mjs";
|
|
5
|
+
import { t as make$13 } from "../shared/vector3-CR2LPV03.mjs";
|
|
6
|
+
import { n as transpose, t as make$14 } from "../shared/vector4-PO_7EYd-.mjs";
|
|
7
7
|
import { a as vectorProductLeft, i as multiply, t as inverse } from "../shared/matrix4x4-BWmf4lZM.mjs";
|
|
8
|
-
import { o as none, s as one } from "../shared/solution-
|
|
9
|
-
import { c as
|
|
10
|
-
import { a as cubicHermite, i as cubicBezier, r as cubicBasisSpline, t as apply } from "../shared/characteristic-
|
|
11
|
-
import { i as make$
|
|
8
|
+
import { o as none, s as one } from "../shared/solution-B2JdOZpe.mjs";
|
|
9
|
+
import { S as fromEndpoints, c as fromCoefficients, l as fromPolynomials, r as fromBezierPoints } from "../shared/rationalCubic2d-CeHgpNht.mjs";
|
|
10
|
+
import { a as cubicHermite, i as cubicBezier, r as cubicBasisSpline, t as apply } from "../shared/characteristic-BkEr-rr8.mjs";
|
|
11
|
+
import { a as fromArray$13, i as make$15, t as fromArray$12 } from "../shared/rationalCubic2d-H1J2Fjyy.mjs";
|
|
12
12
|
//#region src/splines/rationalBezier2d.internal.ts
|
|
13
13
|
const RationalBezier2dTypeId = Symbol("curvy/splines/rationalBezier2d");
|
|
14
14
|
var RationalBezier2dImpl = class extends Pipeable {
|
|
@@ -26,34 +26,34 @@ var RationalBezier2dImpl = class extends Pipeable {
|
|
|
26
26
|
};
|
|
27
27
|
/** @internal */
|
|
28
28
|
const isRationalBezier2d$1 = (p) => typeof p === "object" && p !== null && RationalBezier2dTypeId in p;
|
|
29
|
-
const lift = (p) => make$
|
|
29
|
+
const lift = (p) => make$13(p.x * p.weight, p.y * p.weight, p.weight);
|
|
30
30
|
/** @internal */
|
|
31
|
-
const make$
|
|
31
|
+
const make$11 = (p0, p1, p2, p3) => new RationalBezier2dImpl([
|
|
32
32
|
lift(p0),
|
|
33
33
|
lift(p1),
|
|
34
34
|
lift(p2),
|
|
35
35
|
lift(p3)
|
|
36
36
|
]);
|
|
37
37
|
/** @internal */
|
|
38
|
-
const fromArray$
|
|
38
|
+
const fromArray$11 = (points) => new RationalBezier2dImpl(points.map(lift));
|
|
39
39
|
/** @internal */
|
|
40
|
-
const fromTuples$
|
|
40
|
+
const fromTuples$11 = (tuples) => new RationalBezier2dImpl(tuples.map(([x, y, weight]) => make$13(x * weight, y * weight, weight)));
|
|
41
41
|
/** @internal */
|
|
42
42
|
const fromPoints$1 = (p0, p1, p2, p3) => new RationalBezier2dImpl([
|
|
43
|
-
make$
|
|
44
|
-
make$
|
|
45
|
-
make$
|
|
46
|
-
make$
|
|
43
|
+
make$13(p0.x, p0.y, 1),
|
|
44
|
+
make$13(p1.x, p1.y, 1),
|
|
45
|
+
make$13(p2.x, p2.y, 1),
|
|
46
|
+
make$13(p3.x, p3.y, 1)
|
|
47
47
|
]);
|
|
48
48
|
/** @internal */
|
|
49
49
|
const fromBezier$1 = (b) => {
|
|
50
50
|
const homogeneous = [];
|
|
51
|
-
for (const p of b) homogeneous.push(make$
|
|
51
|
+
for (const p of b) homogeneous.push(make$13(p.x, p.y, 1));
|
|
52
52
|
return new RationalBezier2dImpl(homogeneous);
|
|
53
53
|
};
|
|
54
54
|
const homogeneousOf = (r) => r instanceof RationalBezier2dImpl ? r.homogeneous : Array.from(r, lift);
|
|
55
55
|
/** @internal */
|
|
56
|
-
const toPath$
|
|
56
|
+
const toPath$11 = (r) => {
|
|
57
57
|
const homogeneous = homogeneousOf(r);
|
|
58
58
|
const segmentCount = (homogeneous.length - 1) / 3;
|
|
59
59
|
const curves = [];
|
|
@@ -65,7 +65,7 @@ const toPath$9 = (r) => {
|
|
|
65
65
|
const h3 = homogeneous[base + 3];
|
|
66
66
|
curves.push(fromBezierPoints(makeWeighted(h0.x / h0.z, h0.y / h0.z, h0.z), makeWeighted(h1.x / h1.z, h1.y / h1.z, h1.z), makeWeighted(h2.x / h2.z, h2.y / h2.z, h2.z), makeWeighted(h3.x / h3.z, h3.y / h3.z, h3.z)));
|
|
67
67
|
}
|
|
68
|
-
return fromArray$
|
|
68
|
+
return fromArray$12(curves);
|
|
69
69
|
};
|
|
70
70
|
/** @internal */
|
|
71
71
|
const subdivide$3 = dual(2, (r, u) => {
|
|
@@ -97,12 +97,12 @@ const subdivide$3 = dual(2, (r, u) => {
|
|
|
97
97
|
const sx = r0x + (r1x - r0x) * localT;
|
|
98
98
|
const sy = r0y + (r1y - r0y) * localT;
|
|
99
99
|
const sw = r0w + (r1w - r0w) * localT;
|
|
100
|
-
const q0 = make$
|
|
101
|
-
const r0 = make$
|
|
102
|
-
const sLeft = make$
|
|
103
|
-
const sRight = make$
|
|
104
|
-
const r1 = make$
|
|
105
|
-
const q2 = make$
|
|
100
|
+
const q0 = make$13(q0x, q0y, q0w);
|
|
101
|
+
const r0 = make$13(r0x, r0y, r0w);
|
|
102
|
+
const sLeft = make$13(sx, sy, sw);
|
|
103
|
+
const sRight = make$13(sx, sy, sw);
|
|
104
|
+
const r1 = make$13(r1x, r1y, r1w);
|
|
105
|
+
const q2 = make$13(q2x, q2y, q2w);
|
|
106
106
|
const leftPoints = [
|
|
107
107
|
...homogeneous.slice(0, i * 3 + 1),
|
|
108
108
|
q0,
|
|
@@ -124,7 +124,7 @@ const toBezierPoints = (r) => {
|
|
|
124
124
|
const points = [];
|
|
125
125
|
for (const h of homogeneous) {
|
|
126
126
|
if (!epsEquals(h.z, w0)) return none;
|
|
127
|
-
points.push(make$
|
|
127
|
+
points.push(make$12(h.x / h.z, h.y / h.z));
|
|
128
128
|
}
|
|
129
129
|
return one(points);
|
|
130
130
|
};
|
|
@@ -202,18 +202,18 @@ var Bezier2dImpl = class extends Pipeable {
|
|
|
202
202
|
/** @internal */
|
|
203
203
|
const isCubicBezier2d$1 = (p) => typeof p === "object" && p !== null && Bezier2dTypeId in p;
|
|
204
204
|
/** @internal */
|
|
205
|
-
const make$
|
|
205
|
+
const make$10 = (p0, p1, p2, p3) => new Bezier2dImpl([
|
|
206
206
|
p0,
|
|
207
207
|
p1,
|
|
208
208
|
p2,
|
|
209
209
|
p3
|
|
210
210
|
]);
|
|
211
211
|
/** @internal */
|
|
212
|
-
const fromArray$
|
|
212
|
+
const fromArray$10 = (points) => new Bezier2dImpl(points);
|
|
213
213
|
/** @internal */
|
|
214
|
-
const fromTuples$
|
|
214
|
+
const fromTuples$10 = (tuples) => new Bezier2dImpl(tuples.map(([x, y]) => make$12(x, y)));
|
|
215
215
|
/** @internal */
|
|
216
|
-
const append$
|
|
216
|
+
const append$9 = dual(4, (p, p1, p2, p3) => new Bezier2dImpl((p instanceof Bezier2dImpl ? p.points : Array.from(p)).concat(p1, p2, p3)));
|
|
217
217
|
/** @internal */
|
|
218
218
|
const fromBasis = (p, matrix, stride) => {
|
|
219
219
|
const conversion = getConversionMatrix(matrix);
|
|
@@ -221,19 +221,19 @@ const fromBasis = (p, matrix, stride) => {
|
|
|
221
221
|
let x;
|
|
222
222
|
let y;
|
|
223
223
|
for (const [p0, p1, p2, p3] of toPointQuads(p, stride)) {
|
|
224
|
-
x = vectorProductLeft(conversion, make$
|
|
225
|
-
y = vectorProductLeft(conversion, make$
|
|
226
|
-
points.push(make$
|
|
224
|
+
x = vectorProductLeft(conversion, make$14(p0.x, p1.x, p2.x, p3.x));
|
|
225
|
+
y = vectorProductLeft(conversion, make$14(p0.y, p1.y, p2.y, p3.y));
|
|
226
|
+
points.push(make$12(x.x, y.x), make$12(x.y, y.y), make$12(x.z, y.z));
|
|
227
227
|
}
|
|
228
|
-
if (x && y) points.push(make$
|
|
229
|
-
return fromArray$
|
|
228
|
+
if (x && y) points.push(make$12(x.w, y.w));
|
|
229
|
+
return fromArray$10(points);
|
|
230
230
|
};
|
|
231
231
|
/** @internal */
|
|
232
232
|
const appendTangentAligned$1 = dual(4, (p, a, p5, p6) => {
|
|
233
233
|
const points = p instanceof Bezier2dImpl ? p.points : Array.from(p);
|
|
234
234
|
const p2 = points[points.length - 2];
|
|
235
235
|
const p3 = points[points.length - 1];
|
|
236
|
-
return append$
|
|
236
|
+
return append$9(p, make$12(p3.x + (p3.x - p2.x) * a, p3.y + (p3.y - p2.y) * a), p5, p6);
|
|
237
237
|
});
|
|
238
238
|
/** @internal */
|
|
239
239
|
const appendCurvatureAligned$1 = dual(4, (p, a, b, p6) => {
|
|
@@ -241,7 +241,7 @@ const appendCurvatureAligned$1 = dual(4, (p, a, b, p6) => {
|
|
|
241
241
|
const p1 = points[points.length - 3];
|
|
242
242
|
const p2 = points[points.length - 2];
|
|
243
243
|
const p3 = points[points.length - 1];
|
|
244
|
-
return append$
|
|
244
|
+
return append$9(p, make$12(p3.x + (p3.x - p2.x) * a, p3.y + (p3.y - p2.y) * a), make$12(p3.x + (p3.x - p2.x) * (2 * a + a ** 2 + b / 2) + (p1.x - p2.x) * a ** 2, p3.y + (p3.y - p2.y) * (2 * a + a ** 2 + b / 2) + (p1.y - p2.y) * a ** 2), p6);
|
|
245
245
|
});
|
|
246
246
|
/** @internal */
|
|
247
247
|
const appendVelocityAligned$1 = dual(3, (p, p5, p6) => appendTangentAligned$1(p, 1, p5, p6));
|
|
@@ -251,10 +251,10 @@ const appendAccelerationAligned$1 = dual(2, (p, p6) => {
|
|
|
251
251
|
const p1 = points[points.length - 3];
|
|
252
252
|
const p2 = points[points.length - 2];
|
|
253
253
|
const p3 = points[points.length - 1];
|
|
254
|
-
return append$
|
|
254
|
+
return append$9(p, make$12(2 * p3.x - p2.x, 2 * p3.y - p2.y), make$12(p1.x + 4 * (p3.x - p2.x), p1.y + 4 * (p3.y - p2.y)), p6);
|
|
255
255
|
});
|
|
256
256
|
/** @internal */
|
|
257
|
-
const toPath$
|
|
257
|
+
const toPath$10 = (p) => make$15(...toCurves(p, cubicBezier, 3));
|
|
258
258
|
/** @internal */
|
|
259
259
|
const fromRational$1 = (r) => {
|
|
260
260
|
const points = toBezierPoints(r);
|
|
@@ -285,12 +285,12 @@ const subdivide$2 = dual(2, (b, u) => {
|
|
|
285
285
|
const r1y = q1y + (q2y - q1y) * localT;
|
|
286
286
|
const sx = r0x + (r1x - r0x) * localT;
|
|
287
287
|
const sy = r0y + (r1y - r0y) * localT;
|
|
288
|
-
const q0 = make$
|
|
289
|
-
const r0 = make$
|
|
290
|
-
const sLeft = make$
|
|
291
|
-
const sRight = make$
|
|
292
|
-
const r1 = make$
|
|
293
|
-
const q2 = make$
|
|
288
|
+
const q0 = make$12(q0x, q0y);
|
|
289
|
+
const r0 = make$12(r0x, r0y);
|
|
290
|
+
const sLeft = make$12(sx, sy);
|
|
291
|
+
const sRight = make$12(sx, sy);
|
|
292
|
+
const r1 = make$12(r1x, r1y);
|
|
293
|
+
const q2 = make$12(q2x, q2y);
|
|
294
294
|
const leftPoints = [
|
|
295
295
|
...points.slice(0, i * 3 + 1),
|
|
296
296
|
q0,
|
|
@@ -308,18 +308,18 @@ const subdivide$2 = dual(2, (b, u) => {
|
|
|
308
308
|
//#endregion
|
|
309
309
|
//#region src/splines/bezier2d.ts
|
|
310
310
|
var bezier2d_exports = /* @__PURE__ */ __exportAll({
|
|
311
|
-
append: () => append$
|
|
311
|
+
append: () => append$8,
|
|
312
312
|
appendAccelerationAligned: () => appendAccelerationAligned,
|
|
313
313
|
appendCurvatureAligned: () => appendCurvatureAligned,
|
|
314
314
|
appendTangentAligned: () => appendTangentAligned,
|
|
315
315
|
appendVelocityAligned: () => appendVelocityAligned,
|
|
316
|
-
fromArray: () => fromArray$
|
|
316
|
+
fromArray: () => fromArray$9,
|
|
317
317
|
fromRational: () => fromRational,
|
|
318
|
-
fromTuples: () => fromTuples$
|
|
318
|
+
fromTuples: () => fromTuples$9,
|
|
319
319
|
isCubicBezier2d: () => isCubicBezier2d,
|
|
320
|
-
make: () => make$
|
|
320
|
+
make: () => make$9,
|
|
321
321
|
subdivide: () => subdivide$1,
|
|
322
|
-
toPath: () => toPath$
|
|
322
|
+
toPath: () => toPath$9
|
|
323
323
|
});
|
|
324
324
|
/**
|
|
325
325
|
* Creates a new `Bezier2d` instance.
|
|
@@ -331,7 +331,7 @@ var bezier2d_exports = /* @__PURE__ */ __exportAll({
|
|
|
331
331
|
* @returns A new `Bezier2d` instance.
|
|
332
332
|
* @since 1.0.0
|
|
333
333
|
*/
|
|
334
|
-
const make$
|
|
334
|
+
const make$9 = make$10;
|
|
335
335
|
/**
|
|
336
336
|
* Creates a new `Bezier2d` instance from an array of control points.
|
|
337
337
|
*
|
|
@@ -339,7 +339,7 @@ const make$7 = make$8;
|
|
|
339
339
|
* @returns A new `Bezier2d` instance.
|
|
340
340
|
* @since 1.0.0
|
|
341
341
|
*/
|
|
342
|
-
const fromArray$
|
|
342
|
+
const fromArray$9 = fromArray$10;
|
|
343
343
|
/**
|
|
344
344
|
* Creates a new `Bezier2d` from an array of `[x, y]` tuples. Convenient for
|
|
345
345
|
* data sourced from JSON, CSV, or other tuple-shaped formats.
|
|
@@ -348,7 +348,7 @@ const fromArray$7 = fromArray$8;
|
|
|
348
348
|
* @returns A new `Bezier2d` instance.
|
|
349
349
|
* @since 2.0.0
|
|
350
350
|
*/
|
|
351
|
-
const fromTuples$
|
|
351
|
+
const fromTuples$9 = fromTuples$10;
|
|
352
352
|
/**
|
|
353
353
|
* Checks if a value is a `Bezier2d`.
|
|
354
354
|
*
|
|
@@ -357,7 +357,7 @@ const fromTuples$7 = fromTuples$8;
|
|
|
357
357
|
* @since 1.0.0
|
|
358
358
|
*/
|
|
359
359
|
const isCubicBezier2d = isCubicBezier2d$1;
|
|
360
|
-
const append$
|
|
360
|
+
const append$8 = append$9;
|
|
361
361
|
const appendTangentAligned = appendTangentAligned$1;
|
|
362
362
|
const appendCurvatureAligned = appendCurvatureAligned$1;
|
|
363
363
|
const appendVelocityAligned = appendVelocityAligned$1;
|
|
@@ -369,7 +369,7 @@ const appendAccelerationAligned = appendAccelerationAligned$1;
|
|
|
369
369
|
* @returns A new `CubicPath2d` instance representing the same curve as the `Bezier2d`.
|
|
370
370
|
* @since 1.0.0
|
|
371
371
|
*/
|
|
372
|
-
const toPath$
|
|
372
|
+
const toPath$9 = toPath$10;
|
|
373
373
|
/**
|
|
374
374
|
* Attempts to lower a `RationalBezier2d` to a non-rational `Bezier2d`.
|
|
375
375
|
*
|
|
@@ -413,26 +413,26 @@ const resolveOptions = (options) => ({
|
|
|
413
413
|
alpha: options?.alpha ?? DEFAULT_ALPHA
|
|
414
414
|
});
|
|
415
415
|
/** @internal */
|
|
416
|
-
const make$
|
|
416
|
+
const make$8 = (...args) => {
|
|
417
417
|
if (isVector2(args[0])) return new Cardinal2dImpl(args, DEFAULT_TENSION, DEFAULT_ALPHA);
|
|
418
418
|
const [options, ...points] = args;
|
|
419
419
|
const { tension, alpha } = resolveOptions(options);
|
|
420
420
|
return new Cardinal2dImpl(points, tension, alpha);
|
|
421
421
|
};
|
|
422
422
|
/** @internal */
|
|
423
|
-
const fromArray$
|
|
423
|
+
const fromArray$8 = (points, options) => {
|
|
424
424
|
const { tension, alpha } = resolveOptions(options);
|
|
425
425
|
return new Cardinal2dImpl(points, tension, alpha);
|
|
426
426
|
};
|
|
427
427
|
/** @internal */
|
|
428
|
-
const fromTuples$
|
|
428
|
+
const fromTuples$8 = (tuples, options) => {
|
|
429
429
|
const { tension, alpha } = resolveOptions(options);
|
|
430
|
-
return new Cardinal2dImpl(tuples.map(([x, y]) => make$
|
|
430
|
+
return new Cardinal2dImpl(tuples.map(([x, y]) => make$12(x, y)), tension, alpha);
|
|
431
431
|
};
|
|
432
432
|
/** @internal */
|
|
433
|
-
const append$
|
|
433
|
+
const append$7 = dual((args) => isCardinal2d$1(args[0]), (p, ...points) => new Cardinal2dImpl([...p, ...points], p.tension, p.alpha));
|
|
434
434
|
/** @internal */
|
|
435
|
-
const prepend$
|
|
435
|
+
const prepend$7 = dual((args) => isCardinal2d$1(args[0]), (p, ...points) => new Cardinal2dImpl([...points, ...p], p.tension, p.alpha));
|
|
436
436
|
/** @internal */
|
|
437
437
|
const withDuplicatedEndpoints$1 = (p) => {
|
|
438
438
|
const points = p instanceof Cardinal2dImpl ? p.points : [...p];
|
|
@@ -480,13 +480,13 @@ const buildCardinalSegment = (p0, p1, p2, p3, tension, alpha) => {
|
|
|
480
480
|
const v2y = factor * (p2.y - p1.y - (p3.y - p1.y) * mid23 + (p3.y - p2.y) * trail);
|
|
481
481
|
const dx = p2.x - p1.x;
|
|
482
482
|
const dy = p2.y - p1.y;
|
|
483
|
-
return fromCoefficients(make$
|
|
483
|
+
return fromCoefficients(make$12(p1.x, p1.y), make$12(v1x, v1y), make$12(3 * dx - 2 * v1x - v2x, 3 * dy - 2 * v1y - v2y), make$12(-2 * dx + v1x + v2x, -2 * dy + v1y + v2y));
|
|
484
484
|
};
|
|
485
485
|
function* cardinalCurves(p) {
|
|
486
486
|
for (const [p0, p1, p2, p3] of toPointQuads(p, 1)) yield buildCardinalSegment(p0, p1, p2, p3, p.tension, p.alpha);
|
|
487
487
|
}
|
|
488
488
|
/** @internal */
|
|
489
|
-
const toPath$
|
|
489
|
+
const toPath$8 = (p) => make$15(...cardinalCurves(p));
|
|
490
490
|
/** @internal */
|
|
491
491
|
const toBezier$5 = (p) => {
|
|
492
492
|
const points = [];
|
|
@@ -501,26 +501,26 @@ const toBezier$5 = (p) => {
|
|
|
501
501
|
const c3x = curve.x.c3;
|
|
502
502
|
const c3y = curve.y.c3;
|
|
503
503
|
if (first) {
|
|
504
|
-
points.push(make$
|
|
504
|
+
points.push(make$12(c0x, c0y));
|
|
505
505
|
first = false;
|
|
506
506
|
}
|
|
507
|
-
points.push(make$
|
|
508
|
-
points.push(make$
|
|
509
|
-
points.push(make$
|
|
507
|
+
points.push(make$12(c0x + c1x / 3, c0y + c1y / 3));
|
|
508
|
+
points.push(make$12(c0x + 2 * c1x / 3 + c2x / 3, c0y + 2 * c1y / 3 + c2y / 3));
|
|
509
|
+
points.push(make$12(c0x + c1x + c2x + c3x, c0y + c1y + c2y + c3y));
|
|
510
510
|
}
|
|
511
|
-
return fromArray$
|
|
511
|
+
return fromArray$10(points);
|
|
512
512
|
};
|
|
513
513
|
//#endregion
|
|
514
514
|
//#region src/splines/cardinal2d.ts
|
|
515
515
|
var cardinal2d_exports = /* @__PURE__ */ __exportAll({
|
|
516
|
-
append: () => append$
|
|
517
|
-
fromArray: () => fromArray$
|
|
518
|
-
fromTuples: () => fromTuples$
|
|
516
|
+
append: () => append$6,
|
|
517
|
+
fromArray: () => fromArray$7,
|
|
518
|
+
fromTuples: () => fromTuples$7,
|
|
519
519
|
isCardinal2d: () => isCardinal2d,
|
|
520
|
-
make: () => make$
|
|
521
|
-
prepend: () => prepend$
|
|
520
|
+
make: () => make$7,
|
|
521
|
+
prepend: () => prepend$6,
|
|
522
522
|
toBezier: () => toBezier$4,
|
|
523
|
-
toPath: () => toPath$
|
|
523
|
+
toPath: () => toPath$7,
|
|
524
524
|
withAlpha: () => withAlpha,
|
|
525
525
|
withDuplicatedEndpoints: () => withDuplicatedEndpoints,
|
|
526
526
|
withInterpolatedEndpoints: () => withInterpolatedEndpoints,
|
|
@@ -536,7 +536,7 @@ var cardinal2d_exports = /* @__PURE__ */ __exportAll({
|
|
|
536
536
|
* @since 1.0.0
|
|
537
537
|
*/
|
|
538
538
|
const isCardinal2d = isCardinal2d$1;
|
|
539
|
-
const make$
|
|
539
|
+
const make$7 = make$8;
|
|
540
540
|
/**
|
|
541
541
|
* Creates a new `Cardinal2d` from an array of control points.
|
|
542
542
|
*
|
|
@@ -545,7 +545,7 @@ const make$5 = make$6;
|
|
|
545
545
|
* @returns A new `Cardinal2d` instance.
|
|
546
546
|
* @since 1.0.0
|
|
547
547
|
*/
|
|
548
|
-
const fromArray$
|
|
548
|
+
const fromArray$7 = fromArray$8;
|
|
549
549
|
/**
|
|
550
550
|
* Creates a new `Cardinal2d` from an array of `[x, y]` tuples.
|
|
551
551
|
*
|
|
@@ -554,9 +554,9 @@ const fromArray$5 = fromArray$6;
|
|
|
554
554
|
* @returns A new `Cardinal2d` instance.
|
|
555
555
|
* @since 2.0.0
|
|
556
556
|
*/
|
|
557
|
-
const fromTuples$
|
|
558
|
-
const append$
|
|
559
|
-
const prepend$
|
|
557
|
+
const fromTuples$7 = fromTuples$8;
|
|
558
|
+
const append$6 = append$7;
|
|
559
|
+
const prepend$6 = prepend$7;
|
|
560
560
|
/**
|
|
561
561
|
* Doubles the endpoints of a `Cardinal2d` spline. Tension and alpha are
|
|
562
562
|
* preserved.
|
|
@@ -595,7 +595,7 @@ const withOptions = withOptions$1;
|
|
|
595
595
|
* @returns A new `CubicPath2d` representing the spline.
|
|
596
596
|
* @since 1.0.0
|
|
597
597
|
*/
|
|
598
|
-
const toPath$
|
|
598
|
+
const toPath$7 = toPath$8;
|
|
599
599
|
/**
|
|
600
600
|
* Converts a `Cardinal2d` to a `Bezier2d`. Equivalent to {@link toPath}
|
|
601
601
|
* followed by per-segment monomial-to-Bernstein conversion — same underlying
|
|
@@ -626,40 +626,40 @@ var Hermite2dImpl = class extends Pipeable {
|
|
|
626
626
|
/** @internal */
|
|
627
627
|
const isHermite2d$1 = (p) => typeof p === "object" && p !== null && Hermite2dTypeId in p;
|
|
628
628
|
/** @internal */
|
|
629
|
-
const make$
|
|
629
|
+
const make$6 = (p0, v0, p1, v1) => new Hermite2dImpl([
|
|
630
630
|
p0,
|
|
631
631
|
v0,
|
|
632
632
|
p1,
|
|
633
633
|
v1
|
|
634
634
|
]);
|
|
635
635
|
/** @internal */
|
|
636
|
-
const fromArray$
|
|
636
|
+
const fromArray$6 = (points) => new Hermite2dImpl(points);
|
|
637
637
|
/** @internal */
|
|
638
|
-
const fromTuples$
|
|
638
|
+
const fromTuples$6 = (tuples) => new Hermite2dImpl(tuples.map(([x, y]) => make$12(x, y)));
|
|
639
639
|
/** @internal */
|
|
640
|
-
const append$
|
|
640
|
+
const append$5 = dual(3, (p, p1, v1) => {
|
|
641
641
|
return new Hermite2dImpl((p instanceof Hermite2dImpl ? p.points : Array.from(p)).concat(p1, v1));
|
|
642
642
|
});
|
|
643
643
|
/** @internal */
|
|
644
|
-
const prepend$
|
|
644
|
+
const prepend$5 = dual(3, (p, p0, v0) => {
|
|
645
645
|
const points = p instanceof Hermite2dImpl ? p.points : Array.from(p);
|
|
646
646
|
return new Hermite2dImpl([p0, v0].concat(points));
|
|
647
647
|
});
|
|
648
648
|
/** @internal */
|
|
649
|
-
const toPath$
|
|
649
|
+
const toPath$6 = (p) => make$15(...toCurves(p, cubicHermite, 2));
|
|
650
650
|
/** @internal */
|
|
651
651
|
const toBezier$3 = (p) => fromBasis(p, cubicHermite, 2);
|
|
652
652
|
//#endregion
|
|
653
653
|
//#region src/splines/hermite2d.ts
|
|
654
654
|
var hermite2d_exports = /* @__PURE__ */ __exportAll({
|
|
655
|
-
append: () => append$
|
|
656
|
-
fromArray: () => fromArray$
|
|
657
|
-
fromTuples: () => fromTuples$
|
|
655
|
+
append: () => append$4,
|
|
656
|
+
fromArray: () => fromArray$5,
|
|
657
|
+
fromTuples: () => fromTuples$5,
|
|
658
658
|
isHermite2d: () => isHermite2d,
|
|
659
|
-
make: () => make$
|
|
660
|
-
prepend: () => prepend$
|
|
659
|
+
make: () => make$5,
|
|
660
|
+
prepend: () => prepend$4,
|
|
661
661
|
toBezier: () => toBezier$2,
|
|
662
|
-
toPath: () => toPath$
|
|
662
|
+
toPath: () => toPath$5
|
|
663
663
|
});
|
|
664
664
|
/**
|
|
665
665
|
* Checks if a value is a `Hermite2d`.
|
|
@@ -679,7 +679,7 @@ const isHermite2d = isHermite2d$1;
|
|
|
679
679
|
* @returns A new `Hermite2d` instance.
|
|
680
680
|
* @since 1.0.0
|
|
681
681
|
*/
|
|
682
|
-
const make$
|
|
682
|
+
const make$5 = make$6;
|
|
683
683
|
/**
|
|
684
684
|
* Creates a new `Hermite2d` instance from an array of control points.
|
|
685
685
|
*
|
|
@@ -687,7 +687,7 @@ const make$3 = make$4;
|
|
|
687
687
|
* @returns A new `Hermite2d` instance.
|
|
688
688
|
* @since 1.0.0
|
|
689
689
|
*/
|
|
690
|
-
const fromArray$
|
|
690
|
+
const fromArray$5 = fromArray$6;
|
|
691
691
|
/**
|
|
692
692
|
* Creates a new `Hermite2d` from an array of `[x, y]` tuples, alternating
|
|
693
693
|
* `[position, velocity]` pairs.
|
|
@@ -696,9 +696,9 @@ const fromArray$3 = fromArray$4;
|
|
|
696
696
|
* @returns A new `Hermite2d` instance.
|
|
697
697
|
* @since 2.0.0
|
|
698
698
|
*/
|
|
699
|
-
const fromTuples$
|
|
700
|
-
const append$
|
|
701
|
-
const prepend$
|
|
699
|
+
const fromTuples$5 = fromTuples$6;
|
|
700
|
+
const append$4 = append$5;
|
|
701
|
+
const prepend$4 = prepend$5;
|
|
702
702
|
/**
|
|
703
703
|
* Creates a new `CubicPath2d` instance from a `Hermite2d`.
|
|
704
704
|
*
|
|
@@ -706,7 +706,7 @@ const prepend$2 = prepend$3;
|
|
|
706
706
|
* @returns A new `CubicPath2d` instance.
|
|
707
707
|
* @since 1.0.0
|
|
708
708
|
*/
|
|
709
|
-
const toPath$
|
|
709
|
+
const toPath$5 = toPath$6;
|
|
710
710
|
/**
|
|
711
711
|
* Converts a `Hermite2d` to a `Bezier2d`.
|
|
712
712
|
*
|
|
@@ -733,20 +733,20 @@ var Basis2dImpl = class extends Pipeable {
|
|
|
733
733
|
/** @internal */
|
|
734
734
|
const isBasis2d$1 = (p) => typeof p === "object" && p !== null && Basis2dTypeId in p;
|
|
735
735
|
/** @internal */
|
|
736
|
-
const make$
|
|
736
|
+
const make$4 = (p0, p1, p2, p3) => new Basis2dImpl([
|
|
737
737
|
p0,
|
|
738
738
|
p1,
|
|
739
739
|
p2,
|
|
740
740
|
p3
|
|
741
741
|
]);
|
|
742
742
|
/** @internal */
|
|
743
|
-
const fromArray$
|
|
743
|
+
const fromArray$4 = (points) => new Basis2dImpl(points);
|
|
744
744
|
/** @internal */
|
|
745
|
-
const fromTuples$
|
|
745
|
+
const fromTuples$4 = (tuples) => new Basis2dImpl(tuples.map(([x, y]) => make$12(x, y)));
|
|
746
746
|
/** @internal */
|
|
747
|
-
const append$
|
|
747
|
+
const append$3 = dual((args) => isBasis2d$1(args[0]), (p, ...points) => new Basis2dImpl([...p, ...points]));
|
|
748
748
|
/** @internal */
|
|
749
|
-
const prepend$
|
|
749
|
+
const prepend$3 = dual((args) => isBasis2d$1(args[0]), (p, ...points) => new Basis2dImpl([...points, ...p]));
|
|
750
750
|
/** @internal */
|
|
751
751
|
const withTriplicatedEndpoints$1 = (p) => {
|
|
752
752
|
const points = p instanceof Basis2dImpl ? p.points : [...p];
|
|
@@ -759,20 +759,20 @@ const withTriplicatedEndpoints$1 = (p) => {
|
|
|
759
759
|
]);
|
|
760
760
|
};
|
|
761
761
|
/** @internal */
|
|
762
|
-
const toPath$
|
|
762
|
+
const toPath$4 = (p) => make$15(...toCurves(p, cubicBasisSpline, 1));
|
|
763
763
|
/** @internal */
|
|
764
764
|
const toBezier$1 = (p) => fromBasis(p, cubicBasisSpline, 1);
|
|
765
765
|
//#endregion
|
|
766
766
|
//#region src/splines/basis2d.ts
|
|
767
767
|
var basis2d_exports = /* @__PURE__ */ __exportAll({
|
|
768
|
-
append: () => append,
|
|
769
|
-
fromArray: () => fromArray$
|
|
770
|
-
fromTuples: () => fromTuples$
|
|
768
|
+
append: () => append$2,
|
|
769
|
+
fromArray: () => fromArray$3,
|
|
770
|
+
fromTuples: () => fromTuples$3,
|
|
771
771
|
isBasis2d: () => isBasis2d,
|
|
772
|
-
make: () => make$
|
|
773
|
-
prepend: () => prepend,
|
|
772
|
+
make: () => make$3,
|
|
773
|
+
prepend: () => prepend$2,
|
|
774
774
|
toBezier: () => toBezier,
|
|
775
|
-
toPath: () => toPath$
|
|
775
|
+
toPath: () => toPath$3,
|
|
776
776
|
withTriplicatedEndpoints: () => withTriplicatedEndpoints
|
|
777
777
|
});
|
|
778
778
|
/**
|
|
@@ -793,7 +793,7 @@ const isBasis2d = isBasis2d$1;
|
|
|
793
793
|
* @returns A new `Basis2d` instance.
|
|
794
794
|
* @since 1.0.0
|
|
795
795
|
*/
|
|
796
|
-
const make$
|
|
796
|
+
const make$3 = make$4;
|
|
797
797
|
/**
|
|
798
798
|
* Creates a new `Basis2d` instance from an array of control points.
|
|
799
799
|
*
|
|
@@ -801,7 +801,7 @@ const make$1 = make$2;
|
|
|
801
801
|
* @returns A new `Basis2d` instance.
|
|
802
802
|
* @since 1.0.0
|
|
803
803
|
*/
|
|
804
|
-
const fromArray$
|
|
804
|
+
const fromArray$3 = fromArray$4;
|
|
805
805
|
/**
|
|
806
806
|
* Creates a new `Basis2d` from an array of `[x, y]` tuples.
|
|
807
807
|
*
|
|
@@ -809,9 +809,9 @@ const fromArray$1 = fromArray$2;
|
|
|
809
809
|
* @returns A new `Basis2d` instance.
|
|
810
810
|
* @since 2.0.0
|
|
811
811
|
*/
|
|
812
|
-
const fromTuples$
|
|
813
|
-
const append = append$
|
|
814
|
-
const prepend = prepend$
|
|
812
|
+
const fromTuples$3 = fromTuples$4;
|
|
813
|
+
const append$2 = append$3;
|
|
814
|
+
const prepend$2 = prepend$3;
|
|
815
815
|
/**
|
|
816
816
|
* Triplicates the endpoints of a `Basis2d`.
|
|
817
817
|
*
|
|
@@ -829,7 +829,7 @@ const withTriplicatedEndpoints = withTriplicatedEndpoints$1;
|
|
|
829
829
|
* @returns A new `Path2d` instance.
|
|
830
830
|
* @since 1.0.0
|
|
831
831
|
*/
|
|
832
|
-
const toPath$
|
|
832
|
+
const toPath$3 = toPath$4;
|
|
833
833
|
/**
|
|
834
834
|
* Converts a `Basis2d` to a `Bezier2d`.
|
|
835
835
|
*
|
|
@@ -839,6 +839,104 @@ const toPath$1 = toPath$2;
|
|
|
839
839
|
*/
|
|
840
840
|
const toBezier = toBezier$1;
|
|
841
841
|
//#endregion
|
|
842
|
+
//#region src/splines/linear2d.internal.ts
|
|
843
|
+
const Linear2dTypeId = Symbol("curvy/splines/linear2d");
|
|
844
|
+
var Linear2dImpl = class extends Pipeable {
|
|
845
|
+
[Linear2dTypeId] = Linear2dTypeId;
|
|
846
|
+
points;
|
|
847
|
+
constructor(points) {
|
|
848
|
+
invariant(points.length >= 2, "linear spline requires 2 or more points");
|
|
849
|
+
super();
|
|
850
|
+
this.points = points;
|
|
851
|
+
}
|
|
852
|
+
[Symbol.iterator]() {
|
|
853
|
+
return this.points[Symbol.iterator]();
|
|
854
|
+
}
|
|
855
|
+
};
|
|
856
|
+
/** @internal */
|
|
857
|
+
const isLinear2d$1 = (p) => typeof p === "object" && p !== null && Linear2dTypeId in p;
|
|
858
|
+
/** @internal */
|
|
859
|
+
const make$2 = (p0, p1, ...rest) => new Linear2dImpl([
|
|
860
|
+
p0,
|
|
861
|
+
p1,
|
|
862
|
+
...rest
|
|
863
|
+
]);
|
|
864
|
+
/** @internal */
|
|
865
|
+
const fromArray$2 = (points) => new Linear2dImpl(points);
|
|
866
|
+
/** @internal */
|
|
867
|
+
const fromTuples$2 = (tuples) => new Linear2dImpl(tuples.map(([x, y]) => make$12(x, y)));
|
|
868
|
+
/** @internal */
|
|
869
|
+
const append$1 = dual((args) => isLinear2d$1(args[0]), (p, ...points) => new Linear2dImpl([...p, ...points]));
|
|
870
|
+
/** @internal */
|
|
871
|
+
const prepend$1 = dual((args) => isLinear2d$1(args[0]), (p, ...points) => new Linear2dImpl([...points, ...p]));
|
|
872
|
+
/** @internal */
|
|
873
|
+
const toPath$2 = (p) => {
|
|
874
|
+
const points = p instanceof Linear2dImpl ? p.points : [...p];
|
|
875
|
+
const segments = [];
|
|
876
|
+
for (let i = 1; i < points.length; i++) segments.push(fromEndpoints(points[i - 1], points[i]));
|
|
877
|
+
return fromArray$13(segments);
|
|
878
|
+
};
|
|
879
|
+
//#endregion
|
|
880
|
+
//#region src/splines/linear2d.ts
|
|
881
|
+
var linear2d_exports = /* @__PURE__ */ __exportAll({
|
|
882
|
+
append: () => append,
|
|
883
|
+
fromArray: () => fromArray$1,
|
|
884
|
+
fromTuples: () => fromTuples$1,
|
|
885
|
+
isLinear2d: () => isLinear2d,
|
|
886
|
+
make: () => make$1,
|
|
887
|
+
prepend: () => prepend,
|
|
888
|
+
toPath: () => toPath$1
|
|
889
|
+
});
|
|
890
|
+
/**
|
|
891
|
+
* Checks if a value is a `Linear2d`.
|
|
892
|
+
*
|
|
893
|
+
* @param p - The value to check.
|
|
894
|
+
* @returns `true` if the value is a `Linear2d`, `false` otherwise.
|
|
895
|
+
* @since 2.0.0
|
|
896
|
+
*/
|
|
897
|
+
const isLinear2d = isLinear2d$1;
|
|
898
|
+
/**
|
|
899
|
+
* Creates a new `Linear2d` from 2 or more points.
|
|
900
|
+
*
|
|
901
|
+
* @param p0 - The first point.
|
|
902
|
+
* @param p1 - The second point.
|
|
903
|
+
* @param rest - Additional points.
|
|
904
|
+
* @returns A new `Linear2d` instance.
|
|
905
|
+
* @since 2.0.0
|
|
906
|
+
*/
|
|
907
|
+
const make$1 = make$2;
|
|
908
|
+
/**
|
|
909
|
+
* Creates a new `Linear2d` from an array of points. Requires at least 2
|
|
910
|
+
* points.
|
|
911
|
+
*
|
|
912
|
+
* @param points - The points.
|
|
913
|
+
* @returns A new `Linear2d` instance.
|
|
914
|
+
* @since 2.0.0
|
|
915
|
+
*/
|
|
916
|
+
const fromArray$1 = fromArray$2;
|
|
917
|
+
/**
|
|
918
|
+
* Creates a new `Linear2d` from an array of `[x, y]` tuples. Requires at
|
|
919
|
+
* least 2 tuples.
|
|
920
|
+
*
|
|
921
|
+
* @param tuples - The points as `[x, y]` tuples.
|
|
922
|
+
* @returns A new `Linear2d` instance.
|
|
923
|
+
* @since 2.0.0
|
|
924
|
+
*/
|
|
925
|
+
const fromTuples$1 = fromTuples$2;
|
|
926
|
+
const append = append$1;
|
|
927
|
+
const prepend = prepend$1;
|
|
928
|
+
/**
|
|
929
|
+
* Converts a `Linear2d` to a `LinearPath2d` by joining consecutive points
|
|
930
|
+
* with straight segments. The result is unbranded; assert
|
|
931
|
+
* `LinearPath2d.asMonotonicX` / `asMonotonicY` afterward if the underlying
|
|
932
|
+
* points warrant it.
|
|
933
|
+
*
|
|
934
|
+
* @param p - The `Linear2d` to convert.
|
|
935
|
+
* @returns A new `LinearPath2d` with one segment per consecutive point pair.
|
|
936
|
+
* @since 2.0.0
|
|
937
|
+
*/
|
|
938
|
+
const toPath$1 = toPath$2;
|
|
939
|
+
//#endregion
|
|
842
940
|
//#region src/splines/rationalBezier2d.ts
|
|
843
941
|
var rationalBezier2d_exports = /* @__PURE__ */ __exportAll({
|
|
844
942
|
fromArray: () => fromArray,
|
|
@@ -872,7 +970,7 @@ const isRationalBezier2d = isRationalBezier2d$1;
|
|
|
872
970
|
* @returns A new `RationalBezier2d` instance.
|
|
873
971
|
* @since 2.0.0
|
|
874
972
|
*/
|
|
875
|
-
const make = make$
|
|
973
|
+
const make = make$11;
|
|
876
974
|
/**
|
|
877
975
|
* Creates a new `RationalBezier2d` from an array of weighted control points.
|
|
878
976
|
*
|
|
@@ -883,7 +981,7 @@ const make = make$9;
|
|
|
883
981
|
* @returns A new `RationalBezier2d` instance.
|
|
884
982
|
* @since 2.0.0
|
|
885
983
|
*/
|
|
886
|
-
const fromArray = fromArray$
|
|
984
|
+
const fromArray = fromArray$11;
|
|
887
985
|
/**
|
|
888
986
|
* Creates a new `RationalBezier2d` from an array of `[x, y, weight]` tuples.
|
|
889
987
|
* Weight is the projective denominator at each control point — `1` everywhere
|
|
@@ -894,7 +992,7 @@ const fromArray = fromArray$9;
|
|
|
894
992
|
* @returns A new `RationalBezier2d` instance.
|
|
895
993
|
* @since 2.0.0
|
|
896
994
|
*/
|
|
897
|
-
const fromTuples = fromTuples$
|
|
995
|
+
const fromTuples = fromTuples$11;
|
|
898
996
|
/**
|
|
899
997
|
* Creates a new single-segment `RationalBezier2d` from four points with all
|
|
900
998
|
* weights equal to one.
|
|
@@ -938,9 +1036,9 @@ const fromBezier = fromBezier$1;
|
|
|
938
1036
|
* @returns A new `RationalCubicPath2d` instance representing the same curve.
|
|
939
1037
|
* @since 2.0.0
|
|
940
1038
|
*/
|
|
941
|
-
const toPath = toPath$
|
|
1039
|
+
const toPath = toPath$11;
|
|
942
1040
|
const subdivide = subdivide$3;
|
|
943
1041
|
//#endregion
|
|
944
|
-
export { basis2d_exports as Basis2d, bezier2d_exports as Bezier2d, cardinal2d_exports as Cardinal2d, hermite2d_exports as Hermite2d, rationalBezier2d_exports as RationalBezier2d };
|
|
1042
|
+
export { basis2d_exports as Basis2d, bezier2d_exports as Bezier2d, cardinal2d_exports as Cardinal2d, hermite2d_exports as Hermite2d, linear2d_exports as Linear2d, rationalBezier2d_exports as RationalBezier2d };
|
|
945
1043
|
|
|
946
1044
|
//# sourceMappingURL=index.mjs.map
|