curvy 1.0.9 → 2.0.0-alpha.10

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 (204) hide show
  1. package/dist/characteristic/characteristic.d.ts +80 -0
  2. package/dist/characteristic/index.d.ts +1 -0
  3. package/dist/characteristic/index.mjs +2 -0
  4. package/dist/curve/cubic2d.d.ts +133 -27
  5. package/dist/curve/cubic2d.internal.d.ts +2 -0
  6. package/dist/curve/index.d.ts +12 -0
  7. package/dist/curve/index.mjs +2 -0
  8. package/dist/curve/linear2d.d.ts +125 -24
  9. package/dist/curve/linear2d.internal.d.ts +2 -0
  10. package/dist/curve/quadratic2d.d.ts +134 -28
  11. package/dist/curve/quadratic2d.internal.d.ts +2 -0
  12. package/dist/curve/rationalCubic2d.d.ts +241 -0
  13. package/dist/curve/rationalCubic2d.internal.d.ts +2 -0
  14. package/dist/dimensions.d.ts +23 -0
  15. package/dist/interval/index.d.ts +6 -0
  16. package/dist/interval/index.mjs +3 -0
  17. package/dist/interval/interval.d.ts +525 -0
  18. package/dist/interval/interval.internal.d.ts +1 -0
  19. package/dist/interval/interval2d.d.ts +204 -0
  20. package/dist/interval/interval2d.internal.d.ts +2 -0
  21. package/dist/length.d.ts +32 -0
  22. package/dist/matrix/index.d.ts +9 -0
  23. package/dist/matrix/index.mjs +267 -0
  24. package/dist/matrix/index.mjs.map +1 -0
  25. package/dist/matrix/matrix2x2.d.ts +44 -29
  26. package/dist/matrix/matrix2x2.internal.d.ts +2 -0
  27. package/dist/matrix/matrix3x3.d.ts +64 -38
  28. package/dist/matrix/matrix3x3.internal.d.ts +4 -0
  29. package/dist/matrix/matrix4x4.d.ts +92 -34
  30. package/dist/matrix/matrix4x4.internal.d.ts +2 -0
  31. package/dist/number.d.ts +276 -0
  32. package/dist/number.mjs +140 -0
  33. package/dist/number.mjs.map +1 -0
  34. package/dist/path/cubic2d.d.ts +192 -25
  35. package/dist/path/cubic2d.internal.d.ts +2 -0
  36. package/dist/path/index.d.ts +12 -0
  37. package/dist/path/index.mjs +734 -0
  38. package/dist/path/index.mjs.map +1 -0
  39. package/dist/path/linear2d.d.ts +175 -25
  40. package/dist/path/linear2d.internal.d.ts +2 -0
  41. package/dist/path/quadratic2d.d.ts +165 -26
  42. package/dist/path/quadratic2d.internal.d.ts +2 -0
  43. package/dist/path/rationalCubic2d.d.ts +116 -0
  44. package/dist/path/rationalCubic2d.internal.d.ts +2 -0
  45. package/dist/path/traits.d.ts +95 -0
  46. package/dist/polynomial/cubic.d.ts +377 -7
  47. package/dist/polynomial/cubic.internal.circular.d.ts +2 -0
  48. package/dist/polynomial/cubic.internal.d.ts +1 -0
  49. package/dist/polynomial/index.d.ts +9 -0
  50. package/dist/polynomial/index.mjs +3 -0
  51. package/dist/polynomial/linear.d.ts +317 -7
  52. package/dist/polynomial/linear.internal.d.ts +2 -0
  53. package/dist/polynomial/monotonicity.d.ts +3 -0
  54. package/dist/polynomial/quadratic.d.ts +371 -7
  55. package/dist/polynomial/quadratic.internal.circular.d.ts +2 -0
  56. package/dist/polynomial/quadratic.internal.d.ts +1 -0
  57. package/dist/polynomial/traits.d.ts +56 -0
  58. package/dist/shared/characteristic-B0VEB_OA.mjs +104 -0
  59. package/dist/shared/characteristic-B0VEB_OA.mjs.map +1 -0
  60. package/dist/shared/chunk-25Hzd3z8.mjs +13 -0
  61. package/dist/shared/cubic-NEn7E6V_.mjs +575 -0
  62. package/dist/shared/cubic-NEn7E6V_.mjs.map +1 -0
  63. package/dist/shared/interval-CqC3ZIqj.mjs +460 -0
  64. package/dist/shared/interval-CqC3ZIqj.mjs.map +1 -0
  65. package/dist/shared/interval2d-C0eduE-V.mjs +149 -0
  66. package/dist/shared/interval2d-C0eduE-V.mjs.map +1 -0
  67. package/dist/shared/matrix4x4-BWmf4lZM.mjs +499 -0
  68. package/dist/shared/matrix4x4-BWmf4lZM.mjs.map +1 -0
  69. package/dist/shared/quadratic-Dlxqo2V1.mjs +348 -0
  70. package/dist/shared/quadratic-Dlxqo2V1.mjs.map +1 -0
  71. package/dist/shared/rationalCubic2d-3S5K69Jy.mjs +909 -0
  72. package/dist/shared/rationalCubic2d-3S5K69Jy.mjs.map +1 -0
  73. package/dist/shared/rationalCubic2d-CJY-feGw.mjs +508 -0
  74. package/dist/shared/rationalCubic2d-CJY-feGw.mjs.map +1 -0
  75. package/dist/shared/solution-UKGK826h.mjs +352 -0
  76. package/dist/shared/solution-UKGK826h.mjs.map +1 -0
  77. package/dist/shared/vector2-CSkaMXvp.mjs +205 -0
  78. package/dist/shared/vector2-CSkaMXvp.mjs.map +1 -0
  79. package/dist/shared/vector2.internal-DP1nTBdS.mjs +141 -0
  80. package/dist/shared/vector2.internal-DP1nTBdS.mjs.map +1 -0
  81. package/dist/shared/vector3-CR2LPV03.mjs +226 -0
  82. package/dist/shared/vector3-CR2LPV03.mjs.map +1 -0
  83. package/dist/shared/vector4-PO_7EYd-.mjs +171 -0
  84. package/dist/shared/vector4-PO_7EYd-.mjs.map +1 -0
  85. package/dist/shared/vector4.internal-BJ1QN2Ck.mjs +246 -0
  86. package/dist/shared/vector4.internal-BJ1QN2Ck.mjs.map +1 -0
  87. package/dist/solution/index.d.ts +1 -0
  88. package/dist/solution/index.mjs +2 -0
  89. package/dist/solution/solution.d.ts +264 -0
  90. package/dist/solution/solution.internal.d.ts +2 -0
  91. package/dist/splines/basis2d.d.ts +26 -38
  92. package/dist/splines/basis2d.internal.d.ts +2 -0
  93. package/dist/splines/bezier2d.d.ts +61 -45
  94. package/dist/splines/bezier2d.internal.d.ts +2 -0
  95. package/dist/splines/cardinal2d.d.ts +179 -88
  96. package/dist/splines/cardinal2d.internal.d.ts +2 -0
  97. package/dist/splines/hermite2d.d.ts +25 -36
  98. package/dist/splines/hermite2d.internal.d.ts +2 -0
  99. package/dist/splines/index.d.ts +15 -0
  100. package/dist/splines/index.mjs +946 -0
  101. package/dist/splines/index.mjs.map +1 -0
  102. package/dist/splines/rationalBezier2d.d.ts +144 -0
  103. package/dist/splines/rationalBezier2d.internal.d.ts +2 -0
  104. package/dist/splines/util.d.ts +5 -0
  105. package/dist/utils.d.ts +54 -186
  106. package/dist/utils.mjs +88 -52
  107. package/dist/utils.mjs.map +1 -1
  108. package/dist/vector/index.d.ts +9 -0
  109. package/dist/vector/index.mjs +4 -0
  110. package/dist/vector/vector2.d.ts +238 -33
  111. package/dist/vector/vector2.internal.d.ts +4 -0
  112. package/dist/vector/vector3.d.ts +198 -41
  113. package/dist/vector/vector3.internal.d.ts +2 -0
  114. package/dist/vector/vector4.d.ts +260 -23
  115. package/dist/vector/vector4.internal.d.ts +2 -0
  116. package/package.json +48 -91
  117. package/dist/curve/cubic2d.d.mts +0 -109
  118. package/dist/curve/cubic2d.mjs +0 -80
  119. package/dist/curve/cubic2d.mjs.map +0 -1
  120. package/dist/curve/linear2d.d.mts +0 -94
  121. package/dist/curve/linear2d.mjs +0 -46
  122. package/dist/curve/linear2d.mjs.map +0 -1
  123. package/dist/curve/quadratic2d.d.mts +0 -117
  124. package/dist/curve/quadratic2d.mjs +0 -82
  125. package/dist/curve/quadratic2d.mjs.map +0 -1
  126. package/dist/interval.d.mts +0 -251
  127. package/dist/interval.d.ts +0 -251
  128. package/dist/interval.mjs +0 -86
  129. package/dist/interval.mjs.map +0 -1
  130. package/dist/matrix/matrix2x2.d.mts +0 -320
  131. package/dist/matrix/matrix2x2.mjs +0 -25
  132. package/dist/matrix/matrix2x2.mjs.map +0 -1
  133. package/dist/matrix/matrix3x3.d.mts +0 -370
  134. package/dist/matrix/matrix3x3.mjs +0 -28
  135. package/dist/matrix/matrix3x3.mjs.map +0 -1
  136. package/dist/matrix/matrix4x4.d.mts +0 -381
  137. package/dist/matrix/matrix4x4.mjs +0 -178
  138. package/dist/matrix/matrix4x4.mjs.map +0 -1
  139. package/dist/path/cubic2d.d.mts +0 -95
  140. package/dist/path/cubic2d.mjs +0 -60
  141. package/dist/path/cubic2d.mjs.map +0 -1
  142. package/dist/path/linear2d.d.mts +0 -95
  143. package/dist/path/linear2d.mjs +0 -53
  144. package/dist/path/linear2d.mjs.map +0 -1
  145. package/dist/path/quadratic2d.d.mts +0 -95
  146. package/dist/path/quadratic2d.mjs +0 -57
  147. package/dist/path/quadratic2d.mjs.map +0 -1
  148. package/dist/pipe.d.mts +0 -58
  149. package/dist/pipe.d.ts +0 -58
  150. package/dist/pipe.mjs +0 -92
  151. package/dist/pipe.mjs.map +0 -1
  152. package/dist/polynomial/cubic.d.mts +0 -7
  153. package/dist/polynomial/cubic.mjs +0 -133
  154. package/dist/polynomial/cubic.mjs.map +0 -1
  155. package/dist/polynomial/linear.d.mts +0 -7
  156. package/dist/polynomial/linear.mjs +0 -24
  157. package/dist/polynomial/linear.mjs.map +0 -1
  158. package/dist/polynomial/quadratic.d.mts +0 -7
  159. package/dist/polynomial/quadratic.mjs +0 -27
  160. package/dist/polynomial/quadratic.mjs.map +0 -1
  161. package/dist/shared/curvy.Bf5TIk31.d.mts +0 -22
  162. package/dist/shared/curvy.Bf5TIk31.d.ts +0 -22
  163. package/dist/shared/curvy.BkkW8Tx9.mjs +0 -102
  164. package/dist/shared/curvy.BkkW8Tx9.mjs.map +0 -1
  165. package/dist/shared/curvy.BxdGW9he.mjs +0 -116
  166. package/dist/shared/curvy.BxdGW9he.mjs.map +0 -1
  167. package/dist/shared/curvy.C_sCeg9J.mjs +0 -66
  168. package/dist/shared/curvy.C_sCeg9J.mjs.map +0 -1
  169. package/dist/shared/curvy.Cg8lZVUz.d.ts +0 -688
  170. package/dist/shared/curvy.DCt1gGII.mjs +0 -147
  171. package/dist/shared/curvy.DCt1gGII.mjs.map +0 -1
  172. package/dist/shared/curvy.DJ4xO0al.mjs +0 -63
  173. package/dist/shared/curvy.DJ4xO0al.mjs.map +0 -1
  174. package/dist/shared/curvy.DmVFTi0N.mjs +0 -35
  175. package/dist/shared/curvy.DmVFTi0N.mjs.map +0 -1
  176. package/dist/shared/curvy.FDaj5rlj.d.mts +0 -688
  177. package/dist/shared/curvy.lktriTpx.mjs +0 -101
  178. package/dist/shared/curvy.lktriTpx.mjs.map +0 -1
  179. package/dist/shared/curvy.mLFprrGm.mjs +0 -85
  180. package/dist/shared/curvy.mLFprrGm.mjs.map +0 -1
  181. package/dist/shared/curvy.r6f1j287.mjs +0 -76
  182. package/dist/shared/curvy.r6f1j287.mjs.map +0 -1
  183. package/dist/splines/basis2d.d.mts +0 -130
  184. package/dist/splines/basis2d.mjs +0 -90
  185. package/dist/splines/basis2d.mjs.map +0 -1
  186. package/dist/splines/bezier2d.d.mts +0 -182
  187. package/dist/splines/bezier2d.mjs +0 -23
  188. package/dist/splines/bezier2d.mjs.map +0 -1
  189. package/dist/splines/cardinal2d.d.mts +0 -178
  190. package/dist/splines/cardinal2d.mjs +0 -114
  191. package/dist/splines/cardinal2d.mjs.map +0 -1
  192. package/dist/splines/hermite2d.d.mts +0 -124
  193. package/dist/splines/hermite2d.mjs +0 -63
  194. package/dist/splines/hermite2d.mjs.map +0 -1
  195. package/dist/utils.d.mts +0 -205
  196. package/dist/vector/vector2.d.mts +0 -324
  197. package/dist/vector/vector2.mjs +0 -30
  198. package/dist/vector/vector2.mjs.map +0 -1
  199. package/dist/vector/vector3.d.mts +0 -417
  200. package/dist/vector/vector3.mjs +0 -38
  201. package/dist/vector/vector3.mjs.map +0 -1
  202. package/dist/vector/vector4.d.mts +0 -205
  203. package/dist/vector/vector4.mjs +0 -20
  204. package/dist/vector/vector4.mjs.map +0 -1
@@ -0,0 +1,734 @@
1
+ import { t as __exportAll } from "../shared/chunk-25Hzd3z8.mjs";
2
+ import { Pipeable, dual, invariant } from "../utils.mjs";
3
+ import { epsEquals } from "../number.mjs";
4
+ import { p as unit } from "../shared/interval-CqC3ZIqj.mjs";
5
+ import { o as none } from "../shared/solution-UKGK826h.mjs";
6
+ import { d as isIncreasing, n as isDecreasing$1, r as isIncreasing$1, u as isDecreasing } from "../shared/quadratic-Dlxqo2V1.mjs";
7
+ import { a as union } from "../shared/interval2d-C0eduE-V.mjs";
8
+ import { C as solve$4, T as solveAtY$4, _ as solve$5, b as boundingBox$4, h as length$5, m as boundingBox$5, v as solveAtX$5, w as solveAtX$4, x as length$4, y as solveAtY$5 } from "../shared/rationalCubic2d-3S5K69Jy.mjs";
9
+ import { n as rationalCubic2d_exports, r as cubic2d_exports } from "../shared/rationalCubic2d-CJY-feGw.mjs";
10
+ //#region src/path/linear2d.internal.ts
11
+ const LinearPath2dTypeId = Symbol("curvy/path/linear2d");
12
+ /** @internal */
13
+ var LinearPath2dImpl = class extends Pipeable {
14
+ [LinearPath2dTypeId] = LinearPath2dTypeId;
15
+ curves;
16
+ constructor(curves) {
17
+ super();
18
+ this.curves = curves;
19
+ }
20
+ [Symbol.iterator]() {
21
+ return this.curves[Symbol.iterator]();
22
+ }
23
+ };
24
+ /** @internal */
25
+ const isLinearPath2d$1 = (p) => typeof p === "object" && p !== null && LinearPath2dTypeId in p;
26
+ /** @internal */
27
+ const make$3 = (...curves) => new LinearPath2dImpl(curves);
28
+ /** @internal */
29
+ const fromArray$3 = (curves) => new LinearPath2dImpl(curves);
30
+ /** @internal */
31
+ const append$3 = dual(2, (p, c) => fromArray$3([...p, c]));
32
+ /** @internal */
33
+ const length$3 = (p) => {
34
+ let total = 0;
35
+ for (const curve of p) total += length$4(curve, unit);
36
+ return total;
37
+ };
38
+ /** @internal */
39
+ const solve$3 = dual(2, (p, u) => {
40
+ const curves = p instanceof LinearPath2dImpl ? p.curves : [...p];
41
+ if (u === 1) return solve$4(curves.at(-1), 1);
42
+ const t = u * curves.length;
43
+ const i = Math.floor(t);
44
+ const curve = curves[i];
45
+ return solve$4(curve, t - i);
46
+ });
47
+ /** @internal */
48
+ const toPathData$3 = (p) => {
49
+ let result = "";
50
+ let prevEndX = NaN;
51
+ let prevEndY = NaN;
52
+ for (const curve of p) {
53
+ const startX = curve.x.c0;
54
+ const startY = curve.y.c0;
55
+ const endX = curve.x.c0 + curve.x.c1;
56
+ const endY = curve.y.c0 + curve.y.c1;
57
+ if (!epsEquals(startX, prevEndX) || !epsEquals(startY, prevEndY)) result += ` M ${startX},${startY}`;
58
+ result += ` L ${endX},${endY}`;
59
+ prevEndX = endX;
60
+ prevEndY = endY;
61
+ }
62
+ return result.slice(1);
63
+ };
64
+ /** @internal */
65
+ const isContinuous$3 = (p) => {
66
+ let prevEndX = NaN;
67
+ let prevEndY = NaN;
68
+ let first = true;
69
+ for (const curve of p) {
70
+ const startX = curve.x.c0;
71
+ const startY = curve.y.c0;
72
+ if (!first && (!epsEquals(startX, prevEndX) || !epsEquals(startY, prevEndY))) return false;
73
+ prevEndX = curve.x.c0 + curve.x.c1;
74
+ prevEndY = curve.y.c0 + curve.y.c1;
75
+ first = false;
76
+ }
77
+ return true;
78
+ };
79
+ /** @internal */
80
+ const asContinuous$3 = (p) => {
81
+ invariant(isContinuous$3(p), "linear path is not continuous");
82
+ return p;
83
+ };
84
+ /** @internal */
85
+ const isIncreasingX$3 = (p) => {
86
+ let prevEnd = Number.NEGATIVE_INFINITY;
87
+ for (const c of p) {
88
+ if (!isIncreasing(c.x)) return false;
89
+ if (c.x.c0 < prevEnd - 1e-10) return false;
90
+ prevEnd = c.x.c0 + c.x.c1;
91
+ }
92
+ return true;
93
+ };
94
+ /** @internal */
95
+ const isDecreasingX$3 = (p) => {
96
+ let prevEnd = Number.POSITIVE_INFINITY;
97
+ for (const c of p) {
98
+ if (!isDecreasing(c.x)) return false;
99
+ if (c.x.c0 > prevEnd + 1e-10) return false;
100
+ prevEnd = c.x.c0 + c.x.c1;
101
+ }
102
+ return true;
103
+ };
104
+ /** @internal */
105
+ const isMonotonicX$3 = (p) => isIncreasingX$3(p) || isDecreasingX$3(p);
106
+ /** @internal */
107
+ const isIncreasingY$3 = (p) => {
108
+ let prevEnd = Number.NEGATIVE_INFINITY;
109
+ for (const c of p) {
110
+ if (!isIncreasing(c.y)) return false;
111
+ if (c.y.c0 < prevEnd - 1e-10) return false;
112
+ prevEnd = c.y.c0 + c.y.c1;
113
+ }
114
+ return true;
115
+ };
116
+ /** @internal */
117
+ const isDecreasingY$3 = (p) => {
118
+ let prevEnd = Number.POSITIVE_INFINITY;
119
+ for (const c of p) {
120
+ if (!isDecreasing(c.y)) return false;
121
+ if (c.y.c0 > prevEnd + 1e-10) return false;
122
+ prevEnd = c.y.c0 + c.y.c1;
123
+ }
124
+ return true;
125
+ };
126
+ /** @internal */
127
+ const isMonotonicY$3 = (p) => isIncreasingY$3(p) || isDecreasingY$3(p);
128
+ /** @internal */
129
+ const asIncreasingX$3 = (p) => {
130
+ invariant(isIncreasingX$3(p), "linear path is not increasing in x");
131
+ return p;
132
+ };
133
+ /** @internal */
134
+ const asDecreasingX$3 = (p) => {
135
+ invariant(isDecreasingX$3(p), "linear path is not decreasing in x");
136
+ return p;
137
+ };
138
+ /** @internal */
139
+ const asMonotonicX$3 = (p) => {
140
+ invariant(isMonotonicX$3(p), "linear path is not monotonic in x");
141
+ return p;
142
+ };
143
+ /** @internal */
144
+ const asIncreasingY$3 = (p) => {
145
+ invariant(isIncreasingY$3(p), "linear path is not increasing in y");
146
+ return p;
147
+ };
148
+ /** @internal */
149
+ const asDecreasingY$3 = (p) => {
150
+ invariant(isDecreasingY$3(p), "linear path is not decreasing in y");
151
+ return p;
152
+ };
153
+ /** @internal */
154
+ const asMonotonicY$3 = (p) => {
155
+ invariant(isMonotonicY$3(p), "linear path is not monotonic in y");
156
+ return p;
157
+ };
158
+ /** @internal */
159
+ const solveAtX$3 = dual(2, (p, x) => {
160
+ for (const c of p) {
161
+ const sx = c.x.c0;
162
+ const ex = c.x.c0 + c.x.c1;
163
+ const lo = Math.min(sx, ex);
164
+ const hi = Math.max(sx, ex);
165
+ if (x >= lo - 1e-10 && x <= hi + 1e-10) return solveAtX$4(c, x);
166
+ }
167
+ return none;
168
+ });
169
+ /** @internal */
170
+ const solveAtY$3 = dual(2, (p, y) => {
171
+ for (const c of p) {
172
+ const sy = c.y.c0;
173
+ const ey = c.y.c0 + c.y.c1;
174
+ const lo = Math.min(sy, ey);
175
+ const hi = Math.max(sy, ey);
176
+ if (y >= lo - 1e-10 && y <= hi + 1e-10) return solveAtY$4(c, y);
177
+ }
178
+ return none;
179
+ });
180
+ /** @internal */
181
+ const boundingBox$3 = (p) => {
182
+ const iter = p[Symbol.iterator]();
183
+ let acc = boundingBox$4(iter.next().value);
184
+ for (let next = iter.next(); !next.done; next = iter.next()) acc = union(acc, boundingBox$4(next.value));
185
+ return acc;
186
+ };
187
+ //#endregion
188
+ //#region src/path/linear2d.ts
189
+ var linear2d_exports = /* @__PURE__ */ __exportAll({
190
+ append: () => append$2,
191
+ asContinuous: () => asContinuous$2,
192
+ asDecreasingX: () => asDecreasingX$2,
193
+ asDecreasingY: () => asDecreasingY$2,
194
+ asIncreasingX: () => asIncreasingX$2,
195
+ asIncreasingY: () => asIncreasingY$2,
196
+ asMonotonicX: () => asMonotonicX$2,
197
+ asMonotonicY: () => asMonotonicY$2,
198
+ boundingBox: () => boundingBox$2,
199
+ fromArray: () => fromArray$2,
200
+ isContinuous: () => isContinuous$2,
201
+ isDecreasingX: () => isDecreasingX$2,
202
+ isDecreasingY: () => isDecreasingY$2,
203
+ isIncreasingX: () => isIncreasingX$2,
204
+ isIncreasingY: () => isIncreasingY$2,
205
+ isLinearPath2d: () => isLinearPath2d,
206
+ isMonotonicX: () => isMonotonicX$2,
207
+ isMonotonicY: () => isMonotonicY$2,
208
+ length: () => length$2,
209
+ make: () => make$2,
210
+ solve: () => solve$2,
211
+ solveAtX: () => solveAtX$2,
212
+ solveAtY: () => solveAtY$2,
213
+ toPathData: () => toPathData$2
214
+ });
215
+ /**
216
+ * Creates a new `LinearPath2d` instance from a sequence of curves.
217
+ *
218
+ * @param curves - The curves to create the path from.
219
+ * @returns A new `LinearPath2d` instance.
220
+ * @since 2.0.0
221
+ */
222
+ const make$2 = make$3;
223
+ /**
224
+ * Creates a new `LinearPath2d` instance from an array of curves.
225
+ *
226
+ * @param curves - The curves to create the path from.
227
+ * @returns A new `LinearPath2d` instance.
228
+ * @since 2.0.0
229
+ */
230
+ const fromArray$2 = fromArray$3;
231
+ /**
232
+ * Checks if a value is a `LinearPath2d`.
233
+ *
234
+ * @param p - The value to check.
235
+ * @returns `true` if the value is a `LinearPath2d`, `false` otherwise.
236
+ * @since 1.0.0
237
+ */
238
+ const isLinearPath2d = isLinearPath2d$1;
239
+ const append$2 = append$3;
240
+ /**
241
+ * Calculates the length of a linear path.
242
+ *
243
+ * @param p - The linear path to calculate the length of.
244
+ * @returns The length of the linear path.
245
+ * @since 1.0.0
246
+ */
247
+ const length$2 = length$3;
248
+ const solve$2 = solve$3;
249
+ /**
250
+ * Serializes a linear path as an SVG path data string (the value of a `<path>`
251
+ * element's `d` attribute), using `M` and `L` commands. Discontinuities between
252
+ * curves emit a fresh `M` command.
253
+ *
254
+ * @param p - The linear path to serialize.
255
+ * @returns The SVG path data string.
256
+ * @since 2.0.0
257
+ */
258
+ const toPathData$2 = toPathData$3;
259
+ /**
260
+ * Type-narrowing predicate: refines `LinearPath2d<T>` to
261
+ * `LinearPath2d<T & Continuous>` when adjacent curves connect at their join
262
+ * points.
263
+ *
264
+ * @param p - The linear path to check.
265
+ * @returns `true` when the path is continuous (G⁰).
266
+ * @since 2.0.0
267
+ */
268
+ const isContinuous$2 = isContinuous$3;
269
+ /**
270
+ * Asserts that the linear path is continuous, throwing on failure.
271
+ *
272
+ * @param p - The linear path to assert against.
273
+ * @returns The same path, typed with the `Continuous` brand.
274
+ * @throws When the path has a discontinuity between adjacent curves.
275
+ * @since 2.0.0
276
+ */
277
+ const asContinuous$2 = asContinuous$3;
278
+ /**
279
+ * Type-narrowing predicate: refines `LinearPath2d<T>` to
280
+ * `LinearPath2d<T & IncreasingX>` when every segment's x-polynomial is
281
+ * strictly increasing and adjacent segments' x-ranges don't overlap.
282
+ *
283
+ * @since 2.0.0
284
+ */
285
+ const isIncreasingX$2 = isIncreasingX$3;
286
+ /**
287
+ * Type-narrowing predicate: refines `LinearPath2d<T>` to
288
+ * `LinearPath2d<T & DecreasingX>` when every segment's x-polynomial is
289
+ * strictly decreasing and adjacent segments' x-ranges don't overlap.
290
+ *
291
+ * @since 2.0.0
292
+ */
293
+ const isDecreasingX$2 = isDecreasingX$3;
294
+ /**
295
+ * Type-narrowing predicate: refines `LinearPath2d<T>` to
296
+ * `LinearPath2d<T & MonotonicX>` when the path is either increasing or
297
+ * decreasing in x along its full parameter domain.
298
+ *
299
+ * @since 2.0.0
300
+ */
301
+ const isMonotonicX$2 = isMonotonicX$3;
302
+ /**
303
+ * Type-narrowing predicate: refines `LinearPath2d<T>` to
304
+ * `LinearPath2d<T & IncreasingY>`. The y-axis analog of {@link isIncreasingX}.
305
+ *
306
+ * @since 2.0.0
307
+ */
308
+ const isIncreasingY$2 = isIncreasingY$3;
309
+ /**
310
+ * Type-narrowing predicate: refines `LinearPath2d<T>` to
311
+ * `LinearPath2d<T & DecreasingY>`. The y-axis analog of {@link isDecreasingX}.
312
+ *
313
+ * @since 2.0.0
314
+ */
315
+ const isDecreasingY$2 = isDecreasingY$3;
316
+ /**
317
+ * Type-narrowing predicate: refines `LinearPath2d<T>` to
318
+ * `LinearPath2d<T & MonotonicY>`. The y-axis analog of {@link isMonotonicX}.
319
+ *
320
+ * @since 2.0.0
321
+ */
322
+ const isMonotonicY$2 = isMonotonicY$3;
323
+ /**
324
+ * Asserts that the path is strictly increasing in x, throwing on failure.
325
+ *
326
+ * @since 2.0.0
327
+ */
328
+ const asIncreasingX$2 = asIncreasingX$3;
329
+ /**
330
+ * Asserts that the path is strictly decreasing in x, throwing on failure.
331
+ *
332
+ * @since 2.0.0
333
+ */
334
+ const asDecreasingX$2 = asDecreasingX$3;
335
+ /**
336
+ * Asserts that the path is monotonic in x, throwing on failure.
337
+ *
338
+ * @since 2.0.0
339
+ */
340
+ const asMonotonicX$2 = asMonotonicX$3;
341
+ /**
342
+ * Asserts that the path is strictly increasing in y, throwing on failure.
343
+ *
344
+ * @since 2.0.0
345
+ */
346
+ const asIncreasingY$2 = asIncreasingY$3;
347
+ /**
348
+ * Asserts that the path is strictly decreasing in y, throwing on failure.
349
+ *
350
+ * @since 2.0.0
351
+ */
352
+ const asDecreasingY$2 = asDecreasingY$3;
353
+ /**
354
+ * Asserts that the path is monotonic in y, throwing on failure.
355
+ *
356
+ * @since 2.0.0
357
+ */
358
+ const asMonotonicY$2 = asMonotonicY$3;
359
+ const solveAtX$2 = solveAtX$3;
360
+ const solveAtY$2 = solveAtY$3;
361
+ /**
362
+ * Computes the axis-aligned bounding box of the path — the smallest closed
363
+ * `Box2d` enclosing every segment.
364
+ *
365
+ * @param p - The linear path.
366
+ * @returns A closed `Box2d` enclosing the path.
367
+ * @since 2.0.0
368
+ */
369
+ const boundingBox$2 = boundingBox$3;
370
+ //#endregion
371
+ //#region src/path/quadratic2d.internal.ts
372
+ const QuadraticPath2dTypeId = Symbol("curvy/path/quadratic2d");
373
+ /** @internal */
374
+ var QuadraticPath2dImpl = class extends Pipeable {
375
+ [QuadraticPath2dTypeId] = QuadraticPath2dTypeId;
376
+ curves;
377
+ constructor(curves) {
378
+ super();
379
+ this.curves = curves;
380
+ }
381
+ [Symbol.iterator]() {
382
+ return this.curves[Symbol.iterator]();
383
+ }
384
+ };
385
+ /** @internal */
386
+ const isQuadraticPath2d$1 = (p) => typeof p === "object" && p !== null && QuadraticPath2dTypeId in p;
387
+ /** @internal */
388
+ const make$1 = (...curves) => new QuadraticPath2dImpl(curves);
389
+ /** @internal */
390
+ const fromArray$1 = (curves) => new QuadraticPath2dImpl(curves);
391
+ /** @internal */
392
+ const append$1 = dual(2, (p, c) => fromArray$1([...p, c]));
393
+ /** @internal */
394
+ const length$1 = (p) => {
395
+ let total = 0;
396
+ for (const curve of p) total += length$5(curve, unit);
397
+ return total;
398
+ };
399
+ /** @internal */
400
+ const solve$1 = dual(2, (p, u) => {
401
+ const curves = p instanceof QuadraticPath2dImpl ? p.curves : [...p];
402
+ if (u === 1) return solve$5(curves.at(-1), 1);
403
+ const t = u * curves.length;
404
+ const i = Math.floor(t);
405
+ const curve = curves[i];
406
+ return solve$5(curve, t - i);
407
+ });
408
+ /** @internal */
409
+ const toPathData$1 = (p) => {
410
+ let result = "";
411
+ let prevEndX = NaN;
412
+ let prevEndY = NaN;
413
+ for (const curve of p) {
414
+ const c0x = curve.x.c0;
415
+ const c0y = curve.y.c0;
416
+ const c1x = curve.x.c1;
417
+ const c1y = curve.y.c1;
418
+ const c2x = curve.x.c2;
419
+ const c2y = curve.y.c2;
420
+ const startX = c0x;
421
+ const startY = c0y;
422
+ const ctrlX = c0x + c1x / 2;
423
+ const ctrlY = c0y + c1y / 2;
424
+ const endX = c0x + c1x + c2x;
425
+ const endY = c0y + c1y + c2y;
426
+ if (!epsEquals(startX, prevEndX) || !epsEquals(startY, prevEndY)) result += ` M ${startX},${startY}`;
427
+ result += ` Q ${ctrlX},${ctrlY} ${endX},${endY}`;
428
+ prevEndX = endX;
429
+ prevEndY = endY;
430
+ }
431
+ return result.slice(1);
432
+ };
433
+ /** @internal */
434
+ const isContinuous$1 = (p) => {
435
+ let prevEndX = NaN;
436
+ let prevEndY = NaN;
437
+ let first = true;
438
+ for (const curve of p) {
439
+ const startX = curve.x.c0;
440
+ const startY = curve.y.c0;
441
+ if (!first && (!epsEquals(startX, prevEndX) || !epsEquals(startY, prevEndY))) return false;
442
+ prevEndX = curve.x.c0 + curve.x.c1 + curve.x.c2;
443
+ prevEndY = curve.y.c0 + curve.y.c1 + curve.y.c2;
444
+ first = false;
445
+ }
446
+ return true;
447
+ };
448
+ /** @internal */
449
+ const asContinuous$1 = (p) => {
450
+ invariant(isContinuous$1(p), "quadratic path is not continuous");
451
+ return p;
452
+ };
453
+ /** @internal */
454
+ const isIncreasingX$1 = (p) => {
455
+ let prevEnd = Number.NEGATIVE_INFINITY;
456
+ for (const c of p) {
457
+ if (!isIncreasing$1(c.x, unit)) return false;
458
+ if (c.x.c0 < prevEnd - 1e-10) return false;
459
+ prevEnd = c.x.c0 + c.x.c1 + c.x.c2;
460
+ }
461
+ return true;
462
+ };
463
+ /** @internal */
464
+ const isDecreasingX$1 = (p) => {
465
+ let prevEnd = Number.POSITIVE_INFINITY;
466
+ for (const c of p) {
467
+ if (!isDecreasing$1(c.x, unit)) return false;
468
+ if (c.x.c0 > prevEnd + 1e-10) return false;
469
+ prevEnd = c.x.c0 + c.x.c1 + c.x.c2;
470
+ }
471
+ return true;
472
+ };
473
+ /** @internal */
474
+ const isMonotonicX$1 = (p) => isIncreasingX$1(p) || isDecreasingX$1(p);
475
+ /** @internal */
476
+ const isIncreasingY$1 = (p) => {
477
+ let prevEnd = Number.NEGATIVE_INFINITY;
478
+ for (const c of p) {
479
+ if (!isIncreasing$1(c.y, unit)) return false;
480
+ if (c.y.c0 < prevEnd - 1e-10) return false;
481
+ prevEnd = c.y.c0 + c.y.c1 + c.y.c2;
482
+ }
483
+ return true;
484
+ };
485
+ /** @internal */
486
+ const isDecreasingY$1 = (p) => {
487
+ let prevEnd = Number.POSITIVE_INFINITY;
488
+ for (const c of p) {
489
+ if (!isDecreasing$1(c.y, unit)) return false;
490
+ if (c.y.c0 > prevEnd + 1e-10) return false;
491
+ prevEnd = c.y.c0 + c.y.c1 + c.y.c2;
492
+ }
493
+ return true;
494
+ };
495
+ /** @internal */
496
+ const isMonotonicY$1 = (p) => isIncreasingY$1(p) || isDecreasingY$1(p);
497
+ /** @internal */
498
+ const asIncreasingX$1 = (p) => {
499
+ invariant(isIncreasingX$1(p), "quadratic path is not increasing in x");
500
+ return p;
501
+ };
502
+ /** @internal */
503
+ const asDecreasingX$1 = (p) => {
504
+ invariant(isDecreasingX$1(p), "quadratic path is not decreasing in x");
505
+ return p;
506
+ };
507
+ /** @internal */
508
+ const asMonotonicX$1 = (p) => {
509
+ invariant(isMonotonicX$1(p), "quadratic path is not monotonic in x");
510
+ return p;
511
+ };
512
+ /** @internal */
513
+ const asIncreasingY$1 = (p) => {
514
+ invariant(isIncreasingY$1(p), "quadratic path is not increasing in y");
515
+ return p;
516
+ };
517
+ /** @internal */
518
+ const asDecreasingY$1 = (p) => {
519
+ invariant(isDecreasingY$1(p), "quadratic path is not decreasing in y");
520
+ return p;
521
+ };
522
+ /** @internal */
523
+ const asMonotonicY$1 = (p) => {
524
+ invariant(isMonotonicY$1(p), "quadratic path is not monotonic in y");
525
+ return p;
526
+ };
527
+ /** @internal */
528
+ const solveAtX$1 = dual(2, (p, x) => {
529
+ for (const c of p) {
530
+ const sx = c.x.c0;
531
+ const ex = c.x.c0 + c.x.c1 + c.x.c2;
532
+ const lo = Math.min(sx, ex);
533
+ const hi = Math.max(sx, ex);
534
+ if (x >= lo - 1e-10 && x <= hi + 1e-10) return solveAtX$5(c, x);
535
+ }
536
+ return none;
537
+ });
538
+ /** @internal */
539
+ const solveAtY$1 = dual(2, (p, y) => {
540
+ for (const c of p) {
541
+ const sy = c.y.c0;
542
+ const ey = c.y.c0 + c.y.c1 + c.y.c2;
543
+ const lo = Math.min(sy, ey);
544
+ const hi = Math.max(sy, ey);
545
+ if (y >= lo - 1e-10 && y <= hi + 1e-10) return solveAtY$5(c, y);
546
+ }
547
+ return none;
548
+ });
549
+ /** @internal */
550
+ const boundingBox$1 = (p) => {
551
+ const iter = p[Symbol.iterator]();
552
+ let acc = boundingBox$5(iter.next().value);
553
+ for (let next = iter.next(); !next.done; next = iter.next()) acc = union(acc, boundingBox$5(next.value));
554
+ return acc;
555
+ };
556
+ //#endregion
557
+ //#region src/path/quadratic2d.ts
558
+ var quadratic2d_exports = /* @__PURE__ */ __exportAll({
559
+ append: () => append,
560
+ asContinuous: () => asContinuous,
561
+ asDecreasingX: () => asDecreasingX,
562
+ asDecreasingY: () => asDecreasingY,
563
+ asIncreasingX: () => asIncreasingX,
564
+ asIncreasingY: () => asIncreasingY,
565
+ asMonotonicX: () => asMonotonicX,
566
+ asMonotonicY: () => asMonotonicY,
567
+ boundingBox: () => boundingBox,
568
+ fromArray: () => fromArray,
569
+ isContinuous: () => isContinuous,
570
+ isDecreasingX: () => isDecreasingX,
571
+ isDecreasingY: () => isDecreasingY,
572
+ isIncreasingX: () => isIncreasingX,
573
+ isIncreasingY: () => isIncreasingY,
574
+ isMonotonicX: () => isMonotonicX,
575
+ isMonotonicY: () => isMonotonicY,
576
+ isQuadraticPath2d: () => isQuadraticPath2d,
577
+ length: () => length,
578
+ make: () => make,
579
+ solve: () => solve,
580
+ solveAtX: () => solveAtX,
581
+ solveAtY: () => solveAtY,
582
+ toPathData: () => toPathData
583
+ });
584
+ /**
585
+ * Creates a new `QuadraticPath2d` instance from a sequence of curves.
586
+ *
587
+ * @param curves - The curves to create the path from.
588
+ * @returns A new `QuadraticPath2d` instance.
589
+ * @since 2.0.0
590
+ */
591
+ const make = make$1;
592
+ /**
593
+ * Creates a new `QuadraticPath2d` instance from an array of curves.
594
+ *
595
+ * @param curves - The curves to create the path from.
596
+ * @returns A new `QuadraticPath2d` instance.
597
+ * @since 2.0.0
598
+ */
599
+ const fromArray = fromArray$1;
600
+ /**
601
+ * Checks if a value is a `QuadraticPath2d`.
602
+ *
603
+ * @param p - The value to check.
604
+ * @returns `true` if the value is a `QuadraticPath2d`, `false` otherwise.
605
+ * @since 1.0.0
606
+ */
607
+ const isQuadraticPath2d = isQuadraticPath2d$1;
608
+ const append = append$1;
609
+ /**
610
+ * Calculates the length of a quadratic path.
611
+ *
612
+ * @param p - The quadratic path to calculate the length of.
613
+ * @returns The length of the path.
614
+ */
615
+ const length = length$1;
616
+ const solve = solve$1;
617
+ /**
618
+ * Serializes a quadratic path as an SVG path data string (the value of a
619
+ * `<path>` element's `d` attribute), using `M` and `Q` commands. Discontinuities
620
+ * between curves emit a fresh `M` command.
621
+ *
622
+ * @param p - The quadratic path to serialize.
623
+ * @returns The SVG path data string.
624
+ * @since 2.0.0
625
+ */
626
+ const toPathData = toPathData$1;
627
+ /**
628
+ * Type-narrowing predicate: refines `QuadraticPath2d<T>` to
629
+ * `QuadraticPath2d<T & Continuous>` when adjacent curves connect.
630
+ *
631
+ * @since 2.0.0
632
+ */
633
+ const isContinuous = isContinuous$1;
634
+ /**
635
+ * Asserts that the quadratic path is continuous, throwing on failure.
636
+ *
637
+ * @since 2.0.0
638
+ */
639
+ const asContinuous = asContinuous$1;
640
+ /**
641
+ * Type-narrowing predicate: refines `QuadraticPath2d<T>` to
642
+ * `QuadraticPath2d<T & IncreasingX>` when every segment's x-polynomial is
643
+ * strictly increasing on `[0, 1]` and adjacent segments' x-ranges don't
644
+ * overlap.
645
+ *
646
+ * @since 2.0.0
647
+ */
648
+ const isIncreasingX = isIncreasingX$1;
649
+ /**
650
+ * Type-narrowing predicate: refines `QuadraticPath2d<T>` to
651
+ * `QuadraticPath2d<T & DecreasingX>`.
652
+ *
653
+ * @since 2.0.0
654
+ */
655
+ const isDecreasingX = isDecreasingX$1;
656
+ /**
657
+ * Type-narrowing predicate: refines `QuadraticPath2d<T>` to
658
+ * `QuadraticPath2d<T & MonotonicX>`.
659
+ *
660
+ * @since 2.0.0
661
+ */
662
+ const isMonotonicX = isMonotonicX$1;
663
+ /**
664
+ * Type-narrowing predicate: refines `QuadraticPath2d<T>` to
665
+ * `QuadraticPath2d<T & IncreasingY>`.
666
+ *
667
+ * @since 2.0.0
668
+ */
669
+ const isIncreasingY = isIncreasingY$1;
670
+ /**
671
+ * Type-narrowing predicate: refines `QuadraticPath2d<T>` to
672
+ * `QuadraticPath2d<T & DecreasingY>`.
673
+ *
674
+ * @since 2.0.0
675
+ */
676
+ const isDecreasingY = isDecreasingY$1;
677
+ /**
678
+ * Type-narrowing predicate: refines `QuadraticPath2d<T>` to
679
+ * `QuadraticPath2d<T & MonotonicY>`.
680
+ *
681
+ * @since 2.0.0
682
+ */
683
+ const isMonotonicY = isMonotonicY$1;
684
+ /**
685
+ * Asserts that the path is strictly increasing in x, throwing on failure.
686
+ *
687
+ * @since 2.0.0
688
+ */
689
+ const asIncreasingX = asIncreasingX$1;
690
+ /**
691
+ * Asserts that the path is strictly decreasing in x, throwing on failure.
692
+ *
693
+ * @since 2.0.0
694
+ */
695
+ const asDecreasingX = asDecreasingX$1;
696
+ /**
697
+ * Asserts that the path is monotonic in x, throwing on failure.
698
+ *
699
+ * @since 2.0.0
700
+ */
701
+ const asMonotonicX = asMonotonicX$1;
702
+ /**
703
+ * Asserts that the path is strictly increasing in y, throwing on failure.
704
+ *
705
+ * @since 2.0.0
706
+ */
707
+ const asIncreasingY = asIncreasingY$1;
708
+ /**
709
+ * Asserts that the path is strictly decreasing in y, throwing on failure.
710
+ *
711
+ * @since 2.0.0
712
+ */
713
+ const asDecreasingY = asDecreasingY$1;
714
+ /**
715
+ * Asserts that the path is monotonic in y, throwing on failure.
716
+ *
717
+ * @since 2.0.0
718
+ */
719
+ const asMonotonicY = asMonotonicY$1;
720
+ const solveAtX = solveAtX$1;
721
+ const solveAtY = solveAtY$1;
722
+ /**
723
+ * Computes the axis-aligned bounding box of the path — the smallest closed
724
+ * `Box2d` enclosing every segment.
725
+ *
726
+ * @param p - The quadratic path.
727
+ * @returns A closed `Box2d` enclosing the path.
728
+ * @since 2.0.0
729
+ */
730
+ const boundingBox = boundingBox$1;
731
+ //#endregion
732
+ export { cubic2d_exports as CubicPath2d, linear2d_exports as LinearPath2d, quadratic2d_exports as QuadraticPath2d, rationalCubic2d_exports as RationalCubicPath2d };
733
+
734
+ //# sourceMappingURL=index.mjs.map