curvy 0.3.3 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (95) hide show
  1. package/LICENSE.md +21 -0
  2. package/dist/curve/cubic2d.d.mts +27 -0
  3. package/dist/curve/cubic2d.d.ts +27 -0
  4. package/dist/curve/cubic2d.mjs +85 -0
  5. package/dist/curve/linear2d.d.mts +27 -0
  6. package/dist/curve/linear2d.d.ts +27 -0
  7. package/dist/curve/linear2d.mjs +46 -0
  8. package/dist/curve/quadratic2d.d.mts +27 -0
  9. package/dist/curve/quadratic2d.d.ts +27 -0
  10. package/dist/curve/quadratic2d.mjs +74 -0
  11. package/dist/interval.d.mts +58 -0
  12. package/dist/interval.d.ts +58 -0
  13. package/dist/interval.mjs +88 -0
  14. package/dist/matrix/matrix2x2.d.mts +49 -0
  15. package/dist/matrix/matrix2x2.d.ts +49 -0
  16. package/dist/matrix/matrix2x2.mjs +23 -0
  17. package/dist/matrix/matrix3x3.d.mts +63 -0
  18. package/dist/matrix/matrix3x3.d.ts +63 -0
  19. package/dist/matrix/matrix3x3.mjs +26 -0
  20. package/dist/matrix/matrix4x4.d.mts +72 -0
  21. package/dist/matrix/matrix4x4.d.ts +72 -0
  22. package/dist/matrix/matrix4x4.mjs +214 -0
  23. package/dist/path/cubic2d.d.mts +29 -0
  24. package/dist/path/cubic2d.d.ts +29 -0
  25. package/dist/path/cubic2d.mjs +60 -0
  26. package/dist/path/linear2d.d.mts +29 -0
  27. package/dist/path/linear2d.d.ts +29 -0
  28. package/dist/path/linear2d.mjs +54 -0
  29. package/dist/path/quadratic2d.d.mts +29 -0
  30. package/dist/path/quadratic2d.d.ts +29 -0
  31. package/dist/path/quadratic2d.mjs +60 -0
  32. package/dist/polynomial/cubic.d.mts +7 -0
  33. package/dist/polynomial/cubic.d.ts +7 -0
  34. package/dist/polynomial/cubic.mjs +139 -0
  35. package/dist/polynomial/linear.d.mts +7 -0
  36. package/dist/polynomial/linear.d.ts +7 -0
  37. package/dist/polynomial/linear.mjs +19 -0
  38. package/dist/polynomial/quadratic.d.mts +7 -0
  39. package/dist/polynomial/quadratic.d.ts +7 -0
  40. package/dist/polynomial/quadratic.mjs +22 -0
  41. package/dist/shared/curvy.BAW_cKLu.mjs +123 -0
  42. package/dist/shared/curvy.BN-oFBsc.d.mts +26 -0
  43. package/dist/shared/curvy.BN-oFBsc.d.ts +26 -0
  44. package/dist/shared/curvy.Bxxwly94.d.mts +144 -0
  45. package/dist/shared/curvy.C-sUk7ux.mjs +119 -0
  46. package/dist/shared/curvy.CLzGuqek.mjs +124 -0
  47. package/dist/shared/curvy.CO0Wclt0.d.ts +144 -0
  48. package/dist/shared/curvy.CT38g_II.d.mts +22 -0
  49. package/dist/shared/curvy.CT38g_II.d.ts +22 -0
  50. package/dist/shared/curvy.ChkqgKuv.mjs +119 -0
  51. package/dist/shared/curvy.Cty3LrOR.mjs +70 -0
  52. package/dist/shared/curvy.D7bhnwZy.mjs +52 -0
  53. package/dist/shared/curvy.DOLqYbKE.mjs +48 -0
  54. package/dist/shared/curvy.DgRsieUW.mjs +76 -0
  55. package/dist/shared/curvy.DmVFTi0N.mjs +34 -0
  56. package/dist/splines/bezier2d.d.mts +35 -0
  57. package/dist/splines/bezier2d.d.ts +35 -0
  58. package/dist/splines/bezier2d.mjs +122 -0
  59. package/dist/vector/vector2.d.mts +37 -0
  60. package/dist/vector/vector2.d.ts +37 -0
  61. package/dist/vector/vector2.mjs +16 -0
  62. package/dist/vector/vector3.d.mts +38 -0
  63. package/dist/vector/vector3.d.ts +38 -0
  64. package/dist/vector/vector3.mjs +16 -0
  65. package/dist/vector/vector4.d.mts +39 -0
  66. package/dist/vector/vector4.d.ts +39 -0
  67. package/dist/vector/vector4.mjs +16 -0
  68. package/package.json +78 -37
  69. package/dist/axis.cjs +0 -14
  70. package/dist/axis.d.cts +0 -20
  71. package/dist/axis.d.mts +0 -20
  72. package/dist/axis.d.ts +0 -20
  73. package/dist/axis.mjs +0 -3
  74. package/dist/convert.cjs +0 -74
  75. package/dist/convert.d.cts +0 -6
  76. package/dist/convert.d.mts +0 -6
  77. package/dist/convert.d.ts +0 -6
  78. package/dist/convert.mjs +0 -68
  79. package/dist/curve.cjs +0 -365
  80. package/dist/curve.d.cts +0 -20
  81. package/dist/curve.d.mts +0 -20
  82. package/dist/curve.d.ts +0 -20
  83. package/dist/curve.mjs +0 -354
  84. package/dist/shared/curvy.262f6070.cjs +0 -16
  85. package/dist/shared/curvy.7876e09e.mjs +0 -323
  86. package/dist/shared/curvy.9cd8b44c.mjs +0 -13
  87. package/dist/shared/curvy.db103082.cjs +0 -335
  88. package/dist/shared/curvy.df73166c.d.cts +0 -38
  89. package/dist/shared/curvy.df73166c.d.mts +0 -38
  90. package/dist/shared/curvy.df73166c.d.ts +0 -38
  91. package/dist/splines.cjs +0 -150
  92. package/dist/splines.d.cts +0 -27
  93. package/dist/splines.d.mts +0 -27
  94. package/dist/splines.d.ts +0 -27
  95. package/dist/splines.mjs +0 -138
@@ -0,0 +1,119 @@
1
+ const dual = (arity, body) => {
2
+ if (typeof arity === "function") {
3
+ return function(...args) {
4
+ if (arity(args)) {
5
+ return body.apply(this, args);
6
+ }
7
+ return (self) => body(self, ...args);
8
+ };
9
+ }
10
+ switch (arity) {
11
+ case 0:
12
+ case 1:
13
+ throw new RangeError(`Invalid arity ${arity}`);
14
+ case 2:
15
+ return (...args) => {
16
+ const [a, b] = args;
17
+ if (args.length >= 2) {
18
+ return body(a, b);
19
+ }
20
+ return (self) => body(self, a);
21
+ };
22
+ case 3:
23
+ return (...args) => {
24
+ const [a, b, c] = args;
25
+ if (args.length >= 3) {
26
+ return body(a, b, c);
27
+ }
28
+ return (self) => body(self, a, b);
29
+ };
30
+ case 4:
31
+ return (...args) => {
32
+ const [a, b, c, d] = args;
33
+ if (args.length >= 4) {
34
+ return body(a, b, c, d);
35
+ }
36
+ return (self) => body(self, a, b, c);
37
+ };
38
+ case 5:
39
+ return (...args) => {
40
+ const [a, b, c, d, e] = args;
41
+ if (args.length >= 5) {
42
+ return body(a, b, c, d, e);
43
+ }
44
+ return (self) => body(self, a, b, c, d);
45
+ };
46
+ default:
47
+ return function(...args) {
48
+ if (args.length >= arity) {
49
+ return body.apply(this, args);
50
+ }
51
+ return (self) => body(self, ...args);
52
+ };
53
+ }
54
+ };
55
+ function pipe(...args) {
56
+ const [a, ab, bc, cd, de, ef, fg, gh, hi] = args;
57
+ switch (args.length) {
58
+ case 1:
59
+ return a;
60
+ case 2:
61
+ return ab(a);
62
+ case 3:
63
+ return bc(ab(a));
64
+ case 4:
65
+ return cd(bc(ab(a)));
66
+ case 5:
67
+ return de(cd(bc(ab(a))));
68
+ case 6:
69
+ return ef(de(cd(bc(ab(a)))));
70
+ case 7:
71
+ return fg(ef(de(cd(bc(ab(a))))));
72
+ case 8:
73
+ return gh(fg(ef(de(cd(bc(ab(a)))))));
74
+ case 9:
75
+ return hi(gh(fg(ef(de(cd(bc(ab(a))))))));
76
+ default: {
77
+ let ret = args[0];
78
+ for (let i = 1; i < args.length; i++) {
79
+ ret = args[i](ret);
80
+ }
81
+ return ret;
82
+ }
83
+ }
84
+ }
85
+
86
+ class Pipeable {
87
+ pipe(...args) {
88
+ return pipe(this, ...args);
89
+ }
90
+ }
91
+
92
+ const PRECISION = 8;
93
+ function round(value, precision = PRECISION) {
94
+ const scale = 10 ** precision;
95
+ const result = Math.round(value * scale) / scale;
96
+ if (result === 0) {
97
+ return 0;
98
+ }
99
+ return result;
100
+ }
101
+ dual(
102
+ 5,
103
+ (x, x1, x2, y1, y2) => {
104
+ return y1 + (x - x1) / (x2 - x1) * (y2 - y1);
105
+ }
106
+ );
107
+ dual(3, (value, min, max) => {
108
+ return value < min ? min : value > max ? max : value;
109
+ });
110
+ dual(4, (value, min, max, onClip) => {
111
+ return value < min ? onClip : value > max ? onClip : value;
112
+ });
113
+ function invariant(condition, message) {
114
+ if (!condition) {
115
+ throw new Error(message);
116
+ }
117
+ }
118
+
119
+ export { Pipeable as P, PRECISION as a, dual as d, invariant as i, round as r };
@@ -0,0 +1,70 @@
1
+ import { d as dual, r as round, P as Pipeable } from './curvy.ChkqgKuv.mjs';
2
+
3
+ const Vector4TypeId = Symbol.for("curvy/vector4");
4
+ class Vector4Impl extends Pipeable {
5
+ [Vector4TypeId] = Vector4TypeId;
6
+ x;
7
+ y;
8
+ z;
9
+ w;
10
+ constructor(v0 = 0, v1 = 0, v2 = 0, v3 = 0) {
11
+ super();
12
+ this.x = round(v0);
13
+ this.y = round(v1);
14
+ this.z = round(v2);
15
+ this.w = round(v3);
16
+ }
17
+ get [0]() {
18
+ return this.x;
19
+ }
20
+ get [1]() {
21
+ return this.y;
22
+ }
23
+ get [2]() {
24
+ return this.z;
25
+ }
26
+ get [3]() {
27
+ return this.w;
28
+ }
29
+ get [Symbol.toStringTag]() {
30
+ return `Vector4(${this.x}, ${this.y}, ${this.z}, ${this.w})`;
31
+ }
32
+ get [Symbol.for("nodejs.util.inspect.custom")]() {
33
+ return this[Symbol.toStringTag];
34
+ }
35
+ }
36
+ const isVector4 = (v) => typeof v === "object" && v !== null && Vector4TypeId in v;
37
+ const make = (v0, v1 = v0, v2 = v1, v3 = v2) => new Vector4Impl(v0, v1, v2, v3);
38
+ const magnitude = (vector) => round(Math.hypot(vector.x, vector.y, vector.z, vector.w));
39
+ const normalize = (vector) => {
40
+ const m = magnitude(vector);
41
+ return make(vector.x / m, vector.y / m, vector.z / m, vector.w / m);
42
+ };
43
+ const dot = dual(
44
+ 2,
45
+ (a, b) => round(a.x * b.x + a.y * b.y + a.z * b.z + a.w * b.w)
46
+ );
47
+ const components = (v) => [v.x, v.y, v.z, v.w];
48
+ const softmax = (v) => {
49
+ const max = Math.max(v.x, v.y, v.z, v.w);
50
+ const v0 = Math.exp(v.x - max);
51
+ const v1 = Math.exp(v.y - max);
52
+ const v2 = Math.exp(v.z - max);
53
+ const v3 = Math.exp(v.w - max);
54
+ const sum = v0 + v1 + v2 + v3;
55
+ return make(v0 / sum, v1 / sum, v2 / sum, v3 / sum);
56
+ };
57
+ const add = dual(
58
+ 2,
59
+ (a, b) => make(a.x + b.x, a.y + b.y, a.z + b.z, a.w + b.w)
60
+ );
61
+ const subtract = dual(
62
+ 2,
63
+ (a, b) => make(a.x - b.x, a.y - b.y, a.z - b.z, a.w - b.w)
64
+ );
65
+ const hadamard = dual(
66
+ 2,
67
+ (a, b) => make(a.x * b.x, a.y * b.y, a.z * b.z, a.w * b.w)
68
+ );
69
+
70
+ export { magnitude as a, add as b, components as c, dot as d, subtract as e, hadamard as h, isVector4 as i, make as m, normalize as n, softmax as s };
@@ -0,0 +1,52 @@
1
+ import { d as dual, r as round, P as Pipeable } from './curvy.ChkqgKuv.mjs';
2
+
3
+ const Vector3TypeId = Symbol.for("curvy/vector3");
4
+ class Vector3Impl extends Pipeable {
5
+ [Vector3TypeId] = Vector3TypeId;
6
+ x;
7
+ y;
8
+ z;
9
+ constructor(v0 = 0, v1 = 0, v2 = 0) {
10
+ super();
11
+ this.x = round(v0);
12
+ this.y = round(v1);
13
+ this.z = round(v2);
14
+ }
15
+ get [0]() {
16
+ return this.x;
17
+ }
18
+ get [1]() {
19
+ return this.y;
20
+ }
21
+ get [2]() {
22
+ return this.z;
23
+ }
24
+ get [Symbol.toStringTag]() {
25
+ return `Vector3(${this.x}, ${this.y}, ${this.z})`;
26
+ }
27
+ get [Symbol.for("nodejs.util.inspect.custom")]() {
28
+ return this[Symbol.toStringTag];
29
+ }
30
+ }
31
+ const isVector3 = (v) => typeof v === "object" && v !== null && Vector3TypeId in v;
32
+ const magnitude = (vector) => round(Math.hypot(vector.x, vector.y, vector.z));
33
+ const normalize = (vector) => {
34
+ const m = magnitude(vector);
35
+ return make(vector.x / m, vector.y / m, vector.z / m);
36
+ };
37
+ const dot = dual(2, (a, b) => round(a.x * b.x + a.y * b.y + a.z * b.z));
38
+ const components = (v) => [v.x, v.y, v.z];
39
+ const softmax = (v) => {
40
+ const max = Math.max(v.x, v.y, v.z);
41
+ const v0 = Math.exp(v.x - max);
42
+ const v1 = Math.exp(v.y - max);
43
+ const v2 = Math.exp(v.z - max);
44
+ const sum = v0 + v1 + v2;
45
+ return make(v0 / sum, v1 / sum, v2 / sum);
46
+ };
47
+ const make = (v0, v1 = v0, v2 = v1) => new Vector3Impl(v0, v1, v2);
48
+ const add = dual(2, (a, b) => make(a.x + b.x, a.y + b.y, a.z + b.z));
49
+ const subtract = dual(2, (a, b) => make(a.x - b.x, a.y - b.y, a.z - b.z));
50
+ const hadamard = dual(2, (a, b) => make(a.x * b.x, a.y * b.y, a.z * b.z));
51
+
52
+ export { magnitude as a, add as b, components as c, dot as d, subtract as e, hadamard as h, isVector3 as i, make as m, normalize as n, softmax as s };
@@ -0,0 +1,48 @@
1
+ import { d as dual, a as PRECISION, r as round, P as Pipeable } from './curvy.ChkqgKuv.mjs';
2
+
3
+ const Vector2TypeId = Symbol.for("curvy/vector2");
4
+ class Vector2Impl extends Pipeable {
5
+ [Vector2TypeId] = Vector2TypeId;
6
+ x;
7
+ y;
8
+ precision;
9
+ constructor(v0 = 0, v1 = 0, precision = PRECISION) {
10
+ super();
11
+ this.x = round(v0, precision);
12
+ this.y = round(v1, precision);
13
+ this.precision = precision;
14
+ }
15
+ get [0]() {
16
+ return this.x;
17
+ }
18
+ get [1]() {
19
+ return this.y;
20
+ }
21
+ get [Symbol.toStringTag]() {
22
+ return `Vector2(${this.x}, ${this.y})`;
23
+ }
24
+ get [Symbol.for("nodejs.util.inspect.custom")]() {
25
+ return this[Symbol.toStringTag];
26
+ }
27
+ }
28
+ const isVector2 = (v) => typeof v === "object" && v !== null && Vector2TypeId in v;
29
+ const make = (v0, v1 = v0, precision = PRECISION) => new Vector2Impl(v0, v1, precision);
30
+ const components = (v) => [v.x, v.y];
31
+ const magnitude = (vector) => round(Math.hypot(vector.x, vector.y));
32
+ const normalize = (vector) => {
33
+ const m = magnitude(vector);
34
+ return make(vector.x / m, vector.y / m);
35
+ };
36
+ const dot = dual(2, (a, b) => round(a.x * b.x + a.y * b.y));
37
+ const softmax = (v) => {
38
+ const max = Math.max(v.x, v.y);
39
+ const v0 = Math.exp(v.x - max);
40
+ const v1 = Math.exp(v.y - max);
41
+ const sum = v0 + v1;
42
+ return make(v0 / sum, v1 / sum);
43
+ };
44
+ const add = dual(2, (a, b) => make(a.x + b.x, a.y + b.y));
45
+ const subtract = dual(2, (a, b) => make(a.x - b.x, a.y - b.y));
46
+ const hadamard = dual(2, (a, b) => make(a.x * b.x, a.y * b.y));
47
+
48
+ export { magnitude as a, add as b, components as c, dot as d, subtract as e, hadamard as h, isVector2 as i, make as m, normalize as n, softmax as s };
@@ -0,0 +1,76 @@
1
+ import { P as Pipeable, r as round, d as dual } from './curvy.ChkqgKuv.mjs';
2
+ import { make as make$1, size } from '../interval.mjs';
3
+
4
+ const QuadraticPolynomialTypeId = Symbol.for(
5
+ "curvy/polynomial/quadratic"
6
+ );
7
+ class QuadraticPolynomialImpl extends Pipeable {
8
+ [QuadraticPolynomialTypeId] = QuadraticPolynomialTypeId;
9
+ c0;
10
+ c1;
11
+ c2;
12
+ constructor(c0 = 0, c1 = 0, c2 = 0) {
13
+ super();
14
+ this.c0 = round(c0);
15
+ this.c1 = round(c1);
16
+ this.c2 = round(c2);
17
+ }
18
+ }
19
+
20
+ const LinearPolynomialTypeId = Symbol.for("curvy/linear");
21
+ class LinearPolynomialImpl extends Pipeable {
22
+ [LinearPolynomialTypeId] = LinearPolynomialTypeId;
23
+ c0;
24
+ c1;
25
+ constructor(c0 = 0, c1 = 0) {
26
+ super();
27
+ this.c0 = round(c0);
28
+ this.c1 = round(c1);
29
+ }
30
+ }
31
+ const isLinearPolynomial = (v) => typeof v === "object" && v !== null && LinearPolynomialTypeId in v;
32
+ const make = (c0 = 0, c1 = 0) => new LinearPolynomialImpl(c0, c1);
33
+ const fromVector = (v) => new LinearPolynomialImpl(v.x, v.y);
34
+ const solve = dual(2, (p, x) => round(p.c0 + x * p.c1));
35
+ const toSolver = (p) => (x) => solve(p, x);
36
+ const solveInverse = dual(2, (p, y) => {
37
+ if (p.c1 === 0) {
38
+ return null;
39
+ }
40
+ return round((y - p.c0) / p.c1);
41
+ });
42
+ const toInverseSolver = (p) => (y) => solveInverse(p, y);
43
+ const monotonicity = (p) => p.c1 === 0 ? "constant" : p.c1 > 0 ? "increasing" : "decreasing";
44
+ const antiderivative = dual(
45
+ (args) => isLinearPolynomial(args[0]),
46
+ (p, integrationConstant = 0) => new QuadraticPolynomialImpl(integrationConstant, p.c0, p.c1 / 2)
47
+ );
48
+ const domain = dual(2, (p, range2) => {
49
+ if (p.c1 === 0) {
50
+ if (range2.start === p.c0 && range2.end === p.c0) {
51
+ return make$1(Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY);
52
+ }
53
+ return null;
54
+ }
55
+ const start = solveInverse(p, range2.start);
56
+ const end = solveInverse(p, range2.end);
57
+ if (start === null || end === null) {
58
+ return null;
59
+ }
60
+ return make$1(start, end);
61
+ });
62
+ const range = dual(
63
+ 2,
64
+ (p, domain2) => make$1(solve(p, domain2.start), solve(p, domain2.end))
65
+ );
66
+ const length = dual(2, (p, domain2) => {
67
+ if (size(domain2) === 0) {
68
+ return 0;
69
+ }
70
+ if (p.c1 === 0) {
71
+ return round(size(domain2));
72
+ }
73
+ return round(Math.sqrt(1 + p.c1 ** 2) * size(domain2));
74
+ });
75
+
76
+ export { QuadraticPolynomialImpl as Q, make as a, QuadraticPolynomialTypeId as b, solve as c, toInverseSolver as d, antiderivative as e, fromVector as f, domain as g, isLinearPolynomial as i, length as l, monotonicity as m, range as r, solveInverse as s, toSolver as t };
@@ -0,0 +1,34 @@
1
+ const GL32_X0 = 0.9972638618494816;
2
+ const GL32_X1 = 0.9856115115452684;
3
+ const GL32_X2 = 0.9647622555875064;
4
+ const GL32_X3 = 0.9349060759377397;
5
+ const GL32_X4 = 0.8963211557660521;
6
+ const GL32_X5 = 0.84936761373257;
7
+ const GL32_X6 = 0.7944837959679424;
8
+ const GL32_X7 = 0.7321821187402897;
9
+ const GL32_X8 = 0.6630442669302152;
10
+ const GL32_X9 = 0.5877157572407623;
11
+ const GL32_X10 = 0.5068999089322294;
12
+ const GL32_X11 = 0.42135127613063533;
13
+ const GL32_X12 = 0.33186860228212767;
14
+ const GL32_X13 = 0.23928736225213706;
15
+ const GL32_X14 = 0.1444719615827965;
16
+ const GL32_X15 = 0.04830766568773831;
17
+ const GL32_W0 = 0.007018610009470136;
18
+ const GL32_W1 = 0.01627439473090571;
19
+ const GL32_W2 = 0.02539206530926214;
20
+ const GL32_W3 = 0.03427386291302141;
21
+ const GL32_W4 = 0.042835898022226704;
22
+ const GL32_W5 = 0.050998059262376154;
23
+ const GL32_W6 = 0.05868409347853558;
24
+ const GL32_W7 = 0.06582222277636195;
25
+ const GL32_W8 = 0.07234579410884862;
26
+ const GL32_W9 = 0.07819389578707044;
27
+ const GL32_W10 = 0.08331192422694672;
28
+ const GL32_W11 = 0.08765209300440374;
29
+ const GL32_W12 = 0.0911738786957639;
30
+ const GL32_W13 = 0.09384439908080454;
31
+ const GL32_W14 = 0.09563872007927485;
32
+ const GL32_W15 = 0.09654008851472785;
33
+
34
+ export { GL32_X13 as A, GL32_W14 as B, GL32_X14 as C, GL32_W15 as D, GL32_X15 as E, GL32_W0 as G, GL32_X0 as a, GL32_W1 as b, GL32_X1 as c, GL32_W2 as d, GL32_X2 as e, GL32_W3 as f, GL32_X3 as g, GL32_W4 as h, GL32_X4 as i, GL32_W5 as j, GL32_X5 as k, GL32_W6 as l, GL32_X6 as m, GL32_W7 as n, GL32_X7 as o, GL32_W8 as p, GL32_X8 as q, GL32_W9 as r, GL32_X9 as s, GL32_W10 as t, GL32_X10 as u, GL32_W11 as v, GL32_X11 as w, GL32_W12 as x, GL32_X12 as y, GL32_W13 as z };
@@ -0,0 +1,35 @@
1
+ import { P as Pipeable } from '../shared/curvy.BN-oFBsc.mjs';
2
+ import { CubicPath2d } from '../path/cubic2d.mjs';
3
+ import { Vector2 } from '../vector/vector2.mjs';
4
+ import '../curve/cubic2d.mjs';
5
+ import '../shared/curvy.CT38g_II.mjs';
6
+ import '../interval.mjs';
7
+ import '../shared/curvy.Bxxwly94.mjs';
8
+ import '../vector/vector3.mjs';
9
+ import '../vector/vector4.mjs';
10
+
11
+ declare const Bezier2dTypeId: unique symbol;
12
+ type Bezier2dTypeId = typeof Bezier2dTypeId;
13
+
14
+ interface Bezier2d extends Pipeable {
15
+ readonly [Bezier2dTypeId]: Bezier2dTypeId;
16
+ [Symbol.iterator](): IterableIterator<Vector2>;
17
+ }
18
+ declare const make: (p0: Vector2, p1: Vector2, p2: Vector2, p3: Vector2) => Bezier2d;
19
+ declare const fromArray: (points: ReadonlyArray<Vector2>) => Bezier2d;
20
+ declare const isCubicBezier2d: (p: unknown) => p is Bezier2d;
21
+ declare const append: {
22
+ (p1: Vector2, p2: Vector2, p3: Vector2): (p: Bezier2d) => Bezier2d;
23
+ (p: Bezier2d, p1: Vector2, p2: Vector2, p3: Vector2): Bezier2d;
24
+ };
25
+ declare const appendAligned: {
26
+ (ratio: number, p2: Vector2, p3: Vector2): (p: Bezier2d) => Bezier2d;
27
+ (p: Bezier2d, ratio: number, p2: Vector2, p3: Vector2): Bezier2d;
28
+ };
29
+ declare const appendMirrored: {
30
+ (p2: Vector2, p3: Vector2): (p: Bezier2d) => Bezier2d;
31
+ (p: Bezier2d, p2: Vector2, p3: Vector2): Bezier2d;
32
+ };
33
+ declare const toPath: (p: Bezier2d) => CubicPath2d;
34
+
35
+ export { type Bezier2d, append, appendAligned, appendMirrored, fromArray, isCubicBezier2d, make, toPath };
@@ -0,0 +1,35 @@
1
+ import { P as Pipeable } from '../shared/curvy.BN-oFBsc.js';
2
+ import { CubicPath2d } from '../path/cubic2d.js';
3
+ import { Vector2 } from '../vector/vector2.js';
4
+ import '../curve/cubic2d.js';
5
+ import '../shared/curvy.CT38g_II.js';
6
+ import '../interval.js';
7
+ import '../shared/curvy.CO0Wclt0.js';
8
+ import '../vector/vector3.js';
9
+ import '../vector/vector4.js';
10
+
11
+ declare const Bezier2dTypeId: unique symbol;
12
+ type Bezier2dTypeId = typeof Bezier2dTypeId;
13
+
14
+ interface Bezier2d extends Pipeable {
15
+ readonly [Bezier2dTypeId]: Bezier2dTypeId;
16
+ [Symbol.iterator](): IterableIterator<Vector2>;
17
+ }
18
+ declare const make: (p0: Vector2, p1: Vector2, p2: Vector2, p3: Vector2) => Bezier2d;
19
+ declare const fromArray: (points: ReadonlyArray<Vector2>) => Bezier2d;
20
+ declare const isCubicBezier2d: (p: unknown) => p is Bezier2d;
21
+ declare const append: {
22
+ (p1: Vector2, p2: Vector2, p3: Vector2): (p: Bezier2d) => Bezier2d;
23
+ (p: Bezier2d, p1: Vector2, p2: Vector2, p3: Vector2): Bezier2d;
24
+ };
25
+ declare const appendAligned: {
26
+ (ratio: number, p2: Vector2, p3: Vector2): (p: Bezier2d) => Bezier2d;
27
+ (p: Bezier2d, ratio: number, p2: Vector2, p3: Vector2): Bezier2d;
28
+ };
29
+ declare const appendMirrored: {
30
+ (p2: Vector2, p3: Vector2): (p: Bezier2d) => Bezier2d;
31
+ (p: Bezier2d, p2: Vector2, p3: Vector2): Bezier2d;
32
+ };
33
+ declare const toPath: (p: Bezier2d) => CubicPath2d;
34
+
35
+ export { type Bezier2d, append, appendAligned, appendMirrored, fromArray, isCubicBezier2d, make, toPath };
@@ -0,0 +1,122 @@
1
+ import { fromPolynomials } from '../curve/cubic2d.mjs';
2
+ import { d as dual, P as Pipeable, i as invariant } from '../shared/curvy.ChkqgKuv.mjs';
3
+ import { make as make$2, vectorProductLeft } from '../matrix/matrix4x4.mjs';
4
+ import { fromCurves } from '../path/cubic2d.mjs';
5
+ import { fromVector } from '../polynomial/cubic.mjs';
6
+ import { make as make$3 } from '../vector/vector2.mjs';
7
+ import { make as make$4 } from '../vector/vector4.mjs';
8
+ import '../interval.mjs';
9
+ import '../shared/curvy.DmVFTi0N.mjs';
10
+ import '../polynomial/quadratic.mjs';
11
+ import '../shared/curvy.CLzGuqek.mjs';
12
+ import '../shared/curvy.DgRsieUW.mjs';
13
+ import '../curve/quadratic2d.mjs';
14
+ import '../polynomial/linear.mjs';
15
+ import '../curve/linear2d.mjs';
16
+ import '../shared/curvy.C-sUk7ux.mjs';
17
+ import '../shared/curvy.DOLqYbKE.mjs';
18
+ import '../shared/curvy.Cty3LrOR.mjs';
19
+ import '../shared/curvy.BAW_cKLu.mjs';
20
+ import '../shared/curvy.D7bhnwZy.mjs';
21
+
22
+ const characteristic = make$2(
23
+ 1,
24
+ 0,
25
+ 0,
26
+ 0,
27
+ -3,
28
+ 3,
29
+ 0,
30
+ 0,
31
+ 3,
32
+ -6,
33
+ 3,
34
+ 0,
35
+ -1,
36
+ 3,
37
+ -3,
38
+ 1
39
+ );
40
+ const Bezier2dTypeId = Symbol("curvy/splines/points");
41
+ class Bezier2dImpl extends Pipeable {
42
+ [Bezier2dTypeId] = Bezier2dTypeId;
43
+ points;
44
+ constructor(points) {
45
+ invariant(points.length >= 4, "cubic splines requires 4 or more points");
46
+ invariant(
47
+ points.length % 3 === 1,
48
+ "cubic splines requires (n * 3) + 1 points"
49
+ );
50
+ super();
51
+ this.points = points;
52
+ }
53
+ [Symbol.iterator]() {
54
+ return this.points[Symbol.iterator]();
55
+ }
56
+ }
57
+ const isCubicBezier2d$1 = (p) => typeof p === "object" && p !== null && Bezier2dTypeId in p;
58
+ const make$1 = (p0, p1, p2, p3) => new Bezier2dImpl([p0, p1, p2, p3]);
59
+ const fromArray$1 = (points) => new Bezier2dImpl(points);
60
+ const append$1 = dual(
61
+ 4,
62
+ (p, p1, p2, p3) => new Bezier2dImpl(
63
+ (p instanceof Bezier2dImpl ? p.points : Array.from(p)).concat(p1, p2, p3)
64
+ )
65
+ );
66
+ const appendAligned$1 = dual(4, (p, ratio, p5, p6) => {
67
+ const points = p instanceof Bezier2dImpl ? p.points : Array.from(p);
68
+ const p2 = points[points.length - 2];
69
+ const p3 = points[points.length - 1];
70
+ const p4 = make$3((1 + ratio) * p3.x - p2.x, (1 + ratio) * p3.y - p2.y);
71
+ return append$1(p, p4, p5, p6);
72
+ });
73
+ const appendMirrored$1 = dual(
74
+ 3,
75
+ (p, p5, p6) => appendAligned$1(p, 1, p5, p6)
76
+ );
77
+ function* toCurves(points) {
78
+ let p0;
79
+ let p1;
80
+ let p2;
81
+ let p3;
82
+ for (const point of points) {
83
+ if (p0 === void 0) {
84
+ p0 = point;
85
+ } else if (p1 === void 0) {
86
+ p1 = point;
87
+ } else if (p2 === void 0) {
88
+ p2 = point;
89
+ } else if (p3 === void 0) {
90
+ p3 = point;
91
+ yield fromPolynomials(
92
+ fromVector(
93
+ vectorProductLeft(
94
+ characteristic,
95
+ make$4(p0.x, p1.x, p2.x, p3.x)
96
+ )
97
+ ),
98
+ fromVector(
99
+ vectorProductLeft(
100
+ characteristic,
101
+ make$4(p0.y, p1.y, p2.y, p3.y)
102
+ )
103
+ )
104
+ );
105
+ p0 = p3;
106
+ p1 = void 0;
107
+ p2 = void 0;
108
+ p3 = void 0;
109
+ }
110
+ }
111
+ }
112
+ const toPath$1 = (p) => fromCurves(...toCurves(p));
113
+
114
+ const make = make$1;
115
+ const fromArray = fromArray$1;
116
+ const isCubicBezier2d = isCubicBezier2d$1;
117
+ const append = append$1;
118
+ const appendAligned = appendAligned$1;
119
+ const appendMirrored = appendMirrored$1;
120
+ const toPath = toPath$1;
121
+
122
+ export { append, appendAligned, appendMirrored, fromArray, isCubicBezier2d, make, toPath };
@@ -0,0 +1,37 @@
1
+ import { e as TwoDimensional } from '../shared/curvy.CT38g_II.mjs';
2
+ import { P as Pipeable } from '../shared/curvy.BN-oFBsc.mjs';
3
+
4
+ declare const Vector2TypeId: unique symbol;
5
+ type Vector2TypeId = typeof Vector2TypeId;
6
+
7
+ interface Vector2 extends Pipeable, TwoDimensional<number> {
8
+ readonly [Vector2TypeId]: Vector2TypeId;
9
+ }
10
+ declare const isVector2: (v: unknown) => v is Vector2;
11
+ declare const make: {
12
+ (xy: number): Vector2;
13
+ (x: number, y: number): Vector2;
14
+ };
15
+ declare const magnitude: (vector: Vector2) => number;
16
+ declare const normalize: (vector: Vector2) => Vector2;
17
+ declare const dot: {
18
+ (a: Vector2, b: Vector2): number;
19
+ (b: Vector2): (a: Vector2) => number;
20
+ };
21
+ declare const components: (v: Vector2) => [number, number];
22
+ declare const softmax: (v: Vector2) => Vector2;
23
+ declare const zero: Vector2;
24
+ declare const add: {
25
+ (a: Vector2, b: Vector2): Vector2;
26
+ (b: Vector2): (a: Vector2) => Vector2;
27
+ };
28
+ declare const subtract: {
29
+ (a: Vector2, b: Vector2): Vector2;
30
+ (b: Vector2): (a: Vector2) => Vector2;
31
+ };
32
+ declare const hadamard: {
33
+ (a: Vector2, b: Vector2): Vector2;
34
+ (b: Vector2): (a: Vector2) => Vector2;
35
+ };
36
+
37
+ export { type Vector2, add, components, dot, hadamard, isVector2, magnitude, make, normalize, softmax, subtract, zero };
@@ -0,0 +1,37 @@
1
+ import { e as TwoDimensional } from '../shared/curvy.CT38g_II.js';
2
+ import { P as Pipeable } from '../shared/curvy.BN-oFBsc.js';
3
+
4
+ declare const Vector2TypeId: unique symbol;
5
+ type Vector2TypeId = typeof Vector2TypeId;
6
+
7
+ interface Vector2 extends Pipeable, TwoDimensional<number> {
8
+ readonly [Vector2TypeId]: Vector2TypeId;
9
+ }
10
+ declare const isVector2: (v: unknown) => v is Vector2;
11
+ declare const make: {
12
+ (xy: number): Vector2;
13
+ (x: number, y: number): Vector2;
14
+ };
15
+ declare const magnitude: (vector: Vector2) => number;
16
+ declare const normalize: (vector: Vector2) => Vector2;
17
+ declare const dot: {
18
+ (a: Vector2, b: Vector2): number;
19
+ (b: Vector2): (a: Vector2) => number;
20
+ };
21
+ declare const components: (v: Vector2) => [number, number];
22
+ declare const softmax: (v: Vector2) => Vector2;
23
+ declare const zero: Vector2;
24
+ declare const add: {
25
+ (a: Vector2, b: Vector2): Vector2;
26
+ (b: Vector2): (a: Vector2) => Vector2;
27
+ };
28
+ declare const subtract: {
29
+ (a: Vector2, b: Vector2): Vector2;
30
+ (b: Vector2): (a: Vector2) => Vector2;
31
+ };
32
+ declare const hadamard: {
33
+ (a: Vector2, b: Vector2): Vector2;
34
+ (b: Vector2): (a: Vector2) => Vector2;
35
+ };
36
+
37
+ export { type Vector2, add, components, dot, hadamard, isVector2, magnitude, make, normalize, softmax, subtract, zero };
@@ -0,0 +1,16 @@
1
+ import { i as isVector2$1, m as make$1, a as magnitude$1, n as normalize$1, d as dot$1, c as components$1, s as softmax$1, b as add$1, e as subtract$1, h as hadamard$1 } from '../shared/curvy.DOLqYbKE.mjs';
2
+ import '../shared/curvy.ChkqgKuv.mjs';
3
+
4
+ const isVector2 = isVector2$1;
5
+ const make = make$1;
6
+ const magnitude = magnitude$1;
7
+ const normalize = normalize$1;
8
+ const dot = dot$1;
9
+ const components = components$1;
10
+ const softmax = softmax$1;
11
+ const zero = make(0);
12
+ const add = add$1;
13
+ const subtract = subtract$1;
14
+ const hadamard = hadamard$1;
15
+
16
+ export { add, components, dot, hadamard, isVector2, magnitude, make, normalize, softmax, subtract, zero };