curvy 1.0.8 → 2.0.0-alpha.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.
- package/dist/characteristic/index.d.mts +88 -0
- package/dist/characteristic/index.mjs +2 -0
- package/dist/curve/index.d.mts +2 -0
- package/dist/curve/index.mjs +2 -0
- package/dist/interval/index.d.mts +2 -0
- package/dist/interval/index.mjs +2 -0
- package/dist/matrix/index.d.mts +2 -0
- package/dist/matrix/index.mjs +267 -0
- package/dist/matrix/index.mjs.map +1 -0
- package/dist/number.d.mts +280 -0
- package/dist/number.mjs +140 -0
- package/dist/number.mjs.map +1 -0
- package/dist/path/index.d.mts +241 -0
- package/dist/path/index.mjs +292 -0
- package/dist/path/index.mjs.map +1 -0
- package/dist/polynomial/index.d.mts +2 -0
- package/dist/polynomial/index.mjs +3 -0
- package/dist/shared/characteristic-BGRxcxUH.mjs +104 -0
- package/dist/shared/characteristic-BGRxcxUH.mjs.map +1 -0
- package/dist/shared/chunk-25Hzd3z8.mjs +13 -0
- package/dist/shared/cubic-CYYEUHNm.mjs +479 -0
- package/dist/shared/cubic-CYYEUHNm.mjs.map +1 -0
- package/dist/shared/cubic-Dfn6DB02.d.mts +1099 -0
- package/dist/shared/interval-CCEqzPgA.mjs +376 -0
- package/dist/shared/interval-CCEqzPgA.mjs.map +1 -0
- package/dist/shared/interval-hQDiKqj0.d.mts +494 -0
- package/dist/shared/matrix4x4-Bt_DBlP0.d.mts +1182 -0
- package/dist/shared/matrix4x4-Ck2WROK-.mjs +440 -0
- package/dist/shared/matrix4x4-Ck2WROK-.mjs.map +1 -0
- package/dist/shared/quadratic-DEhuAKuE.mjs +330 -0
- package/dist/shared/quadratic-DEhuAKuE.mjs.map +1 -0
- package/dist/shared/rationalCubic2d-BPLohNuI.d.mts +787 -0
- package/dist/shared/rationalCubic2d-CP4oGpnk.mjs +658 -0
- package/dist/shared/rationalCubic2d-CP4oGpnk.mjs.map +1 -0
- package/dist/shared/rationalCubic2d-CXa7Yren.mjs +278 -0
- package/dist/shared/rationalCubic2d-CXa7Yren.mjs.map +1 -0
- package/dist/shared/rationalCubic2d-D_-XWxcm.d.mts +297 -0
- package/dist/shared/solution-BjoW7ov4.d.mts +251 -0
- package/dist/shared/solution-CbSWzXCn.mjs +306 -0
- package/dist/shared/solution-CbSWzXCn.mjs.map +1 -0
- package/dist/{pipe.d.mts → shared/utils-DqTGyXrP.d.mts} +44 -26
- package/dist/shared/vector2-CL1HDdPr.mjs +187 -0
- package/dist/shared/vector2-CL1HDdPr.mjs.map +1 -0
- package/dist/shared/vector2-TV0UnlxY.d.mts +1168 -0
- package/dist/shared/vector2.internal-DU_E808S.mjs +97 -0
- package/dist/shared/vector2.internal-DU_E808S.mjs.map +1 -0
- package/dist/shared/vector3-D-tv_aKL.mjs +204 -0
- package/dist/shared/vector3-D-tv_aKL.mjs.map +1 -0
- package/dist/shared/vector4-5KbjoHVj.mjs +109 -0
- package/dist/shared/vector4-5KbjoHVj.mjs.map +1 -0
- package/dist/shared/vector4.internal-5XcaX12X.mjs +163 -0
- package/dist/shared/vector4.internal-5XcaX12X.mjs.map +1 -0
- package/dist/solution/index.d.mts +2 -0
- package/dist/solution/index.mjs +2 -0
- package/dist/splines/index.d.mts +701 -0
- package/dist/splines/index.mjs +734 -0
- package/dist/splines/index.mjs.map +1 -0
- package/dist/utils.d.mts +2 -27
- package/dist/utils.mjs +88 -43
- package/dist/utils.mjs.map +1 -0
- package/dist/vector/index.d.mts +2 -0
- package/dist/vector/index.mjs +4 -0
- package/package.json +49 -92
- package/dist/curve/cubic2d.d.mts +0 -31
- package/dist/curve/cubic2d.d.ts +0 -31
- package/dist/curve/cubic2d.mjs +0 -97
- package/dist/curve/linear2d.d.mts +0 -28
- package/dist/curve/linear2d.d.ts +0 -28
- package/dist/curve/linear2d.mjs +0 -49
- package/dist/curve/quadratic2d.d.mts +0 -33
- package/dist/curve/quadratic2d.d.ts +0 -33
- package/dist/curve/quadratic2d.mjs +0 -87
- package/dist/interval.d.mts +0 -58
- package/dist/interval.d.ts +0 -58
- package/dist/interval.mjs +0 -89
- package/dist/matrix/matrix2x2.d.mts +0 -49
- package/dist/matrix/matrix2x2.d.ts +0 -49
- package/dist/matrix/matrix2x2.mjs +0 -24
- package/dist/matrix/matrix3x3.d.mts +0 -63
- package/dist/matrix/matrix3x3.d.ts +0 -63
- package/dist/matrix/matrix3x3.mjs +0 -27
- package/dist/matrix/matrix4x4.d.mts +0 -72
- package/dist/matrix/matrix4x4.d.ts +0 -72
- package/dist/matrix/matrix4x4.mjs +0 -215
- package/dist/path/cubic2d.d.mts +0 -29
- package/dist/path/cubic2d.d.ts +0 -29
- package/dist/path/cubic2d.mjs +0 -62
- package/dist/path/linear2d.d.mts +0 -29
- package/dist/path/linear2d.d.ts +0 -29
- package/dist/path/linear2d.mjs +0 -55
- package/dist/path/quadratic2d.d.mts +0 -30
- package/dist/path/quadratic2d.d.ts +0 -30
- package/dist/path/quadratic2d.mjs +0 -61
- package/dist/pipe.d.ts +0 -58
- package/dist/pipe.mjs +0 -91
- package/dist/polynomial/cubic.d.mts +0 -7
- package/dist/polynomial/cubic.d.ts +0 -7
- package/dist/polynomial/cubic.mjs +0 -148
- package/dist/polynomial/linear.d.mts +0 -7
- package/dist/polynomial/linear.d.ts +0 -7
- package/dist/polynomial/linear.mjs +0 -23
- package/dist/polynomial/quadratic.d.mts +0 -7
- package/dist/polynomial/quadratic.d.ts +0 -7
- package/dist/polynomial/quadratic.mjs +0 -24
- package/dist/shared/curvy.BDhiZ7He.mjs +0 -80
- package/dist/shared/curvy.BZ_mTkJe.mjs +0 -60
- package/dist/shared/curvy.Bf5TIk31.d.mts +0 -22
- package/dist/shared/curvy.Bf5TIk31.d.ts +0 -22
- package/dist/shared/curvy.BsHoYJNv.d.ts +0 -155
- package/dist/shared/curvy.BzVmUIKm.mjs +0 -131
- package/dist/shared/curvy.C2XGH0R0.mjs +0 -75
- package/dist/shared/curvy.CE4X6_Is.mjs +0 -181
- package/dist/shared/curvy.Cps2R_RU.mjs +0 -120
- package/dist/shared/curvy.Cv-wIzDr.mjs +0 -124
- package/dist/shared/curvy.DmVFTi0N.mjs +0 -34
- package/dist/shared/curvy.NsmY7zcr.d.mts +0 -155
- package/dist/shared/curvy.wYJQhFW-.mjs +0 -87
- package/dist/splines/basis2d.d.mts +0 -38
- package/dist/splines/basis2d.d.ts +0 -38
- package/dist/splines/basis2d.mjs +0 -89
- package/dist/splines/bezier2d.d.mts +0 -48
- package/dist/splines/bezier2d.d.ts +0 -48
- package/dist/splines/bezier2d.mjs +0 -22
- package/dist/splines/cardinal2d.d.mts +0 -49
- package/dist/splines/cardinal2d.d.ts +0 -49
- package/dist/splines/cardinal2d.mjs +0 -123
- package/dist/splines/hermite2d.d.mts +0 -33
- package/dist/splines/hermite2d.d.ts +0 -33
- package/dist/splines/hermite2d.mjs +0 -77
- package/dist/utils.d.ts +0 -27
- package/dist/vector/vector2.d.mts +0 -66
- package/dist/vector/vector2.d.ts +0 -66
- package/dist/vector/vector2.mjs +0 -28
- package/dist/vector/vector3.d.mts +0 -77
- package/dist/vector/vector3.d.ts +0 -77
- package/dist/vector/vector3.mjs +0 -32
- package/dist/vector/vector4.d.mts +0 -43
- package/dist/vector/vector4.d.ts +0 -43
- package/dist/vector/vector4.mjs +0 -18
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
import { t as Vector2 } from "./vector2-TV0UnlxY.mjs";
|
|
2
|
+
import { t as Pipeable } from "./utils-DqTGyXrP.mjs";
|
|
3
|
+
import { r as CubicCurve2d, t as RationalCubicCurve2d } from "./rationalCubic2d-BPLohNuI.mjs";
|
|
4
|
+
|
|
5
|
+
//#region src/path/traits.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* Trait brands for paths.
|
|
8
|
+
*
|
|
9
|
+
* Brands are phantom types — they exist only at the type level and carry no
|
|
10
|
+
* runtime data. Refiners (`isContinuous`) and assertions (`asContinuous`) on
|
|
11
|
+
* each path module attach these brands to the path's `Trait` parameter at the
|
|
12
|
+
* type level.
|
|
13
|
+
*
|
|
14
|
+
* @since 2.0.0
|
|
15
|
+
*/
|
|
16
|
+
declare const ContinuousId: unique symbol;
|
|
17
|
+
/**
|
|
18
|
+
* Brand for paths whose adjacent curves connect at their join points (G⁰
|
|
19
|
+
* continuity). Calling `toPathData` on a `Continuous` path skips the
|
|
20
|
+
* per-segment discontinuity check and emits a single `M` followed by drawing
|
|
21
|
+
* commands.
|
|
22
|
+
*
|
|
23
|
+
* @since 2.0.0
|
|
24
|
+
*/
|
|
25
|
+
type Continuous = {
|
|
26
|
+
readonly [ContinuousId]: 'continuous';
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Phantom property key used by path interfaces to hold their `Trait` type
|
|
30
|
+
* parameter. The runtime object never has a value at this key.
|
|
31
|
+
*
|
|
32
|
+
* @since 2.0.0
|
|
33
|
+
*/
|
|
34
|
+
declare const PathTraits: unique symbol;
|
|
35
|
+
type PathTraits = typeof PathTraits;
|
|
36
|
+
//#endregion
|
|
37
|
+
//#region src/path/cubic2d.internal.d.ts
|
|
38
|
+
declare const CubicPath2dTypeId: unique symbol;
|
|
39
|
+
type CubicPath2dTypeId = typeof CubicPath2dTypeId;
|
|
40
|
+
declare namespace cubic2d_d_exports {
|
|
41
|
+
export { Continuous, CubicPath2d, append$1 as append, asContinuous, fromArray$1 as fromArray, isContinuous, isCubicPath2d, length, make$1 as make, solve$1 as solve, solveByDistance, toPathData };
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* A cubic path in 2D space.
|
|
45
|
+
*
|
|
46
|
+
* All fields are readonly and immutable, and all operations create new instances.
|
|
47
|
+
*
|
|
48
|
+
* The `Trait` type parameter accumulates trait brands as the path is refined
|
|
49
|
+
* via `isContinuous` / `asContinuous`.
|
|
50
|
+
*
|
|
51
|
+
* @since 1.0.0
|
|
52
|
+
*/
|
|
53
|
+
interface CubicPath2d<out Trait = unknown> extends Pipeable, Iterable<CubicCurve2d> {
|
|
54
|
+
readonly [CubicPath2dTypeId]: CubicPath2dTypeId;
|
|
55
|
+
readonly [PathTraits]: Trait;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Creates a new `CubicPath2d` instance from a sequence of curves.
|
|
59
|
+
*
|
|
60
|
+
* @param curves - The curves to create the path from.
|
|
61
|
+
* @returns A new `CubicPath2d` instance.
|
|
62
|
+
* @since 2.0.0
|
|
63
|
+
*/
|
|
64
|
+
declare const make$1: (...curves: ReadonlyArray<CubicCurve2d>) => CubicPath2d;
|
|
65
|
+
/**
|
|
66
|
+
* Creates a new `CubicPath2d` instance from an array of curves.
|
|
67
|
+
*
|
|
68
|
+
* @param curves - The curves to create the path from.
|
|
69
|
+
* @returns A new `CubicPath2d` instance.
|
|
70
|
+
* @since 2.0.0
|
|
71
|
+
*/
|
|
72
|
+
declare const fromArray$1: (curves: ReadonlyArray<CubicCurve2d>) => CubicPath2d;
|
|
73
|
+
/**
|
|
74
|
+
* Checks if a value is a `CubicPath2d`.
|
|
75
|
+
*
|
|
76
|
+
* @param p - The value to check.
|
|
77
|
+
* @returns `true` if the value is a `CubicPath2d`, `false` otherwise.
|
|
78
|
+
* @since 1.0.0
|
|
79
|
+
*/
|
|
80
|
+
declare const isCubicPath2d: (p: unknown) => p is CubicPath2d;
|
|
81
|
+
declare const append$1: {
|
|
82
|
+
/**
|
|
83
|
+
* Appends a cubic curve to a cubic path.
|
|
84
|
+
*
|
|
85
|
+
* @param c - The cubic curve to append.
|
|
86
|
+
* @returns A function that takes a cubic path and returns a new cubic path.
|
|
87
|
+
* @since 1.0.0
|
|
88
|
+
*/
|
|
89
|
+
(c: CubicCurve2d): (p: CubicPath2d) => CubicPath2d;
|
|
90
|
+
/**
|
|
91
|
+
* Appends a cubic curve to a cubic path.
|
|
92
|
+
*
|
|
93
|
+
* @param p - The cubic path to append to.
|
|
94
|
+
* @param c - The cubic curve to append.
|
|
95
|
+
* @returns A new cubic path.
|
|
96
|
+
* @since 1.0.0
|
|
97
|
+
*/
|
|
98
|
+
(p: CubicPath2d, c: CubicCurve2d): CubicPath2d;
|
|
99
|
+
};
|
|
100
|
+
/**
|
|
101
|
+
* Calculates the length of a cubic path.
|
|
102
|
+
*
|
|
103
|
+
* @param p - The cubic path to calculate the length of.
|
|
104
|
+
* @returns The length of the cubic path.
|
|
105
|
+
* @since 1.0.0
|
|
106
|
+
*/
|
|
107
|
+
declare const length: (p: CubicPath2d) => number;
|
|
108
|
+
declare const solve$1: {
|
|
109
|
+
/**
|
|
110
|
+
* Solves a cubic path for a given parameter.
|
|
111
|
+
*
|
|
112
|
+
* @param u - The parameter to solve for.
|
|
113
|
+
* @returns A function that takes a cubic path and returns the solved vector.
|
|
114
|
+
* @since 1.0.0
|
|
115
|
+
*/
|
|
116
|
+
(u: number): (p: CubicPath2d) => Vector2;
|
|
117
|
+
/**
|
|
118
|
+
* Solves a cubic path for a given parameter.
|
|
119
|
+
*
|
|
120
|
+
* @param p - The cubic path to solve.
|
|
121
|
+
* @param u - The parameter to solve for.
|
|
122
|
+
* @returns The solved vector.
|
|
123
|
+
* @since 1.0.0
|
|
124
|
+
*/
|
|
125
|
+
(p: CubicPath2d, u: number): Vector2;
|
|
126
|
+
};
|
|
127
|
+
/**
|
|
128
|
+
* Serializes a cubic path as an SVG path data string (the value of a `<path>`
|
|
129
|
+
* element's `d` attribute), using `M` and `C` commands. Discontinuities between
|
|
130
|
+
* curves emit a fresh `M` command.
|
|
131
|
+
*
|
|
132
|
+
* @param p - The cubic path to serialize.
|
|
133
|
+
* @returns The SVG path data string.
|
|
134
|
+
* @since 2.0.0
|
|
135
|
+
*/
|
|
136
|
+
declare const toPathData: (p: CubicPath2d) => string;
|
|
137
|
+
/**
|
|
138
|
+
* Type-narrowing predicate: refines `CubicPath2d<T>` to
|
|
139
|
+
* `CubicPath2d<T & Continuous>` when adjacent curves connect.
|
|
140
|
+
*
|
|
141
|
+
* @since 2.0.0
|
|
142
|
+
*/
|
|
143
|
+
declare const isContinuous: <T>(p: CubicPath2d<T>) => p is CubicPath2d<T & Continuous>;
|
|
144
|
+
/**
|
|
145
|
+
* Asserts that the cubic path is continuous, throwing on failure.
|
|
146
|
+
*
|
|
147
|
+
* @since 2.0.0
|
|
148
|
+
*/
|
|
149
|
+
declare const asContinuous: <T>(p: CubicPath2d<T>) => CubicPath2d<T & Continuous>;
|
|
150
|
+
declare const solveByDistance: {
|
|
151
|
+
/**
|
|
152
|
+
* Solves a cubic path by normalized arc length. Unlike {@link solve}, which
|
|
153
|
+
* is parameterized by curve `u`, this samples points at constant speed along
|
|
154
|
+
* the path — `s = 0.5` returns the point exactly halfway along the curve by
|
|
155
|
+
* arc length, regardless of how the underlying parameterization stretches.
|
|
156
|
+
*
|
|
157
|
+
* Cumulative segment lengths are cached by path identity so repeated calls
|
|
158
|
+
* with the same path are fast.
|
|
159
|
+
*
|
|
160
|
+
* @param p - The cubic path to sample.
|
|
161
|
+
* @param s - Normalized arc length in `[0, 1]`. Values outside the range are
|
|
162
|
+
* clamped to path endpoints.
|
|
163
|
+
* @returns The point on the path at the given normalized arc length.
|
|
164
|
+
* @since 1.1.0
|
|
165
|
+
*/
|
|
166
|
+
(p: CubicPath2d, s: number): Vector2;
|
|
167
|
+
/**
|
|
168
|
+
* Solves a cubic path by normalized arc length.
|
|
169
|
+
*
|
|
170
|
+
* @param s - Normalized arc length in `[0, 1]`.
|
|
171
|
+
* @returns A function that takes a cubic path and returns the point at that
|
|
172
|
+
* arc length.
|
|
173
|
+
* @since 1.1.0
|
|
174
|
+
*/
|
|
175
|
+
(s: number): (p: CubicPath2d) => Vector2;
|
|
176
|
+
};
|
|
177
|
+
//#endregion
|
|
178
|
+
//#region src/path/rationalCubic2d.internal.d.ts
|
|
179
|
+
declare const RationalCubicPath2dTypeId: unique symbol;
|
|
180
|
+
type RationalCubicPath2dTypeId = typeof RationalCubicPath2dTypeId;
|
|
181
|
+
declare namespace rationalCubic2d_d_exports {
|
|
182
|
+
export { RationalCubicPath2d, append, approximateAsCubicPath, fromArray, isRationalCubicPath2d, make, solve };
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* A rational cubic path in 2D space.
|
|
186
|
+
*
|
|
187
|
+
* Holds a non-empty sequence of `RationalCubicCurve2d` segments; iteration
|
|
188
|
+
* yields the segments in order. The path parameter `u ∈ [0, 1]` is mapped
|
|
189
|
+
* uniformly across segments — `u = 0` is the start of the first segment,
|
|
190
|
+
* `u = 1` is the end of the last segment, and intermediate values pick a
|
|
191
|
+
* segment by index and a local parameter within it.
|
|
192
|
+
*
|
|
193
|
+
* Counterpart to `CubicPath2d` for curves whose evaluation includes the
|
|
194
|
+
* homogeneous-to-plane projection.
|
|
195
|
+
*
|
|
196
|
+
* All fields are readonly and immutable, and all operations create new instances.
|
|
197
|
+
*
|
|
198
|
+
* @since 2.1.0
|
|
199
|
+
*/
|
|
200
|
+
interface RationalCubicPath2d extends Pipeable, Iterable<RationalCubicCurve2d> {
|
|
201
|
+
readonly [RationalCubicPath2dTypeId]: RationalCubicPath2dTypeId;
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Checks if a value is a `RationalCubicPath2d`.
|
|
205
|
+
*
|
|
206
|
+
* @param p - The value to check.
|
|
207
|
+
* @returns `true` if the value is a `RationalCubicPath2d`, `false` otherwise.
|
|
208
|
+
* @since 2.1.0
|
|
209
|
+
*/
|
|
210
|
+
declare const isRationalCubicPath2d: (p: unknown) => p is RationalCubicPath2d;
|
|
211
|
+
/**
|
|
212
|
+
* Creates a new `RationalCubicPath2d` from a sequence of curves.
|
|
213
|
+
*
|
|
214
|
+
* @param curves - The curves to create the path from.
|
|
215
|
+
* @returns A new `RationalCubicPath2d` instance.
|
|
216
|
+
* @since 2.1.0
|
|
217
|
+
*/
|
|
218
|
+
declare const make: (...curves: ReadonlyArray<RationalCubicCurve2d>) => RationalCubicPath2d;
|
|
219
|
+
/**
|
|
220
|
+
* Creates a new `RationalCubicPath2d` from an array of curves.
|
|
221
|
+
*
|
|
222
|
+
* @param curves - The curves to create the path from.
|
|
223
|
+
* @returns A new `RationalCubicPath2d` instance.
|
|
224
|
+
* @since 2.1.0
|
|
225
|
+
*/
|
|
226
|
+
declare const fromArray: (curves: ReadonlyArray<RationalCubicCurve2d>) => RationalCubicPath2d;
|
|
227
|
+
declare const append: {
|
|
228
|
+
/**
|
|
229
|
+
* Appends a curve to a `RationalCubicPath2d`.
|
|
230
|
+
*
|
|
231
|
+
* @param c - The curve to append.
|
|
232
|
+
* @returns A function that takes a path and returns a new path with the appended curve.
|
|
233
|
+
* @since 2.1.0
|
|
234
|
+
*/
|
|
235
|
+
(c: RationalCubicCurve2d): (p: RationalCubicPath2d) => RationalCubicPath2d;
|
|
236
|
+
/**
|
|
237
|
+
* Appends a curve to a `RationalCubicPath2d`.
|
|
238
|
+
*
|
|
239
|
+
* @param p - The path to append to.
|
|
240
|
+
* @param c - The curve to append.
|
|
241
|
+
* @returns A new path with the appended curve.
|
|
242
|
+
* @since 2.1.0
|
|
243
|
+
*/
|
|
244
|
+
(p: RationalCubicPath2d, c: RationalCubicCurve2d): RationalCubicPath2d;
|
|
245
|
+
};
|
|
246
|
+
declare const solve: {
|
|
247
|
+
/**
|
|
248
|
+
* Evaluates the rational cubic path at parameter `u ∈ [0, 1]`.
|
|
249
|
+
*
|
|
250
|
+
* Picks the segment containing `u` (uniform mapping across segments) and
|
|
251
|
+
* delegates to `RationalCubicCurve2d.solve` on that segment with the local
|
|
252
|
+
* parameter.
|
|
253
|
+
*
|
|
254
|
+
* @param p - The path to evaluate.
|
|
255
|
+
* @param u - The path parameter in `[0, 1]`.
|
|
256
|
+
* @returns The point on the path at parameter `u`.
|
|
257
|
+
* @since 2.1.0
|
|
258
|
+
*/
|
|
259
|
+
(p: RationalCubicPath2d, u: number): Vector2;
|
|
260
|
+
/**
|
|
261
|
+
* Evaluates the rational cubic path at parameter `u ∈ [0, 1]`.
|
|
262
|
+
*
|
|
263
|
+
* @param u - The path parameter in `[0, 1]`.
|
|
264
|
+
* @returns A function that takes a path and returns the point at `u`.
|
|
265
|
+
* @since 2.1.0
|
|
266
|
+
*/
|
|
267
|
+
(u: number): (p: RationalCubicPath2d) => Vector2;
|
|
268
|
+
};
|
|
269
|
+
declare const approximateAsCubicPath: {
|
|
270
|
+
/**
|
|
271
|
+
* Approximates the rational cubic path as a `CubicPath2d` via per-segment
|
|
272
|
+
* recursive subdivision. Each input segment is split until its midpoint
|
|
273
|
+
* deviates from a polynomial-cubic candidate by at most `tolerance`; the
|
|
274
|
+
* surviving candidates are concatenated into a new path.
|
|
275
|
+
*
|
|
276
|
+
* Lossy in general — only exact when every input segment has uniform
|
|
277
|
+
* weights, in which case segment count is preserved. Tighter tolerance
|
|
278
|
+
* produces more segments.
|
|
279
|
+
*
|
|
280
|
+
* @param p - The rational cubic path to approximate.
|
|
281
|
+
* @param tolerance - Maximum allowed midpoint deviation per segment; must be positive.
|
|
282
|
+
* @returns A new `CubicPath2d` approximating the input.
|
|
283
|
+
* @since 2.1.0
|
|
284
|
+
*/
|
|
285
|
+
(p: RationalCubicPath2d, tolerance: number): CubicPath2d;
|
|
286
|
+
/**
|
|
287
|
+
* Approximates the rational cubic path as a `CubicPath2d`.
|
|
288
|
+
*
|
|
289
|
+
* @param tolerance - Maximum allowed midpoint deviation per segment; must be positive.
|
|
290
|
+
* @returns A function that takes a rational path and returns its approximation.
|
|
291
|
+
* @since 2.1.0
|
|
292
|
+
*/
|
|
293
|
+
(tolerance: number): (p: RationalCubicPath2d) => CubicPath2d;
|
|
294
|
+
};
|
|
295
|
+
//#endregion
|
|
296
|
+
export { Continuous as a, cubic2d_d_exports as i, rationalCubic2d_d_exports as n, PathTraits as o, CubicPath2d as r, RationalCubicPath2d as t };
|
|
297
|
+
//# sourceMappingURL=rationalCubic2d-D_-XWxcm.d.mts.map
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
import { t as Pipeable } from "./utils-DqTGyXrP.mjs";
|
|
2
|
+
import { t as Interval } from "./interval-hQDiKqj0.mjs";
|
|
3
|
+
|
|
4
|
+
//#region src/solution/solution.d.ts
|
|
5
|
+
declare namespace solution_d_exports {
|
|
6
|
+
export { AtMostOne, AtMostThree, AtMostTwo, None, One, Solution, Some, Three, Two, clip, filter, fromArray, isNone, isSome, last, map, match, max, min, none, one, three, two, unsafeLast, unsafeMax, unsafeMin, valueOrUndefined };
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* A `Solution<T>` represents the result of an operation that may produce
|
|
10
|
+
* between zero and three values of `T`. It generalizes the zoo of "0 or 1",
|
|
11
|
+
* "0 to 2", "0 to 3" return shapes used throughout curvy under one type, and
|
|
12
|
+
* provides a small namespace of operations (`value`, `last`, `min`, `max`,
|
|
13
|
+
* `filter`, `map`, `match`, …) for working with the result.
|
|
14
|
+
*
|
|
15
|
+
* Each variant carries a `_tag` discriminator and a `length` field, is
|
|
16
|
+
* iterable via `Symbol.iterator` (so existing `for..of` and spread patterns
|
|
17
|
+
* keep working), and is `Pipeable` (so a `Solution` value can be the head of
|
|
18
|
+
* a `pipe` chain).
|
|
19
|
+
*
|
|
20
|
+
* Variant-specific accessors:
|
|
21
|
+
* - `One<T>`, `Two<T>`, and `Three<T>` all expose `.value: T` (the first /
|
|
22
|
+
* primary value).
|
|
23
|
+
* - `Two<T>` and `Three<T>` additionally expose `.values: readonly [T, ...]`
|
|
24
|
+
* for explicit positional access.
|
|
25
|
+
*
|
|
26
|
+
* Operations that return narrower cardinalities (e.g. inverse-solving a
|
|
27
|
+
* monotonic polynomial) use the `AtMost{One,Two,Three}` aliases to express
|
|
28
|
+
* "this could be empty, but it'll have at most N values."
|
|
29
|
+
*
|
|
30
|
+
* @since 2.0.0
|
|
31
|
+
*/
|
|
32
|
+
type Solution<T> = None | One<T> | Two<T> | Three<T>;
|
|
33
|
+
/**
|
|
34
|
+
* The empty solution.
|
|
35
|
+
*
|
|
36
|
+
* @since 2.0.0
|
|
37
|
+
*/
|
|
38
|
+
interface None extends Pipeable, Iterable<never> {
|
|
39
|
+
readonly _tag: 'none';
|
|
40
|
+
readonly length: 0;
|
|
41
|
+
}
|
|
42
|
+
/** @since 2.0.0 */
|
|
43
|
+
interface One<T> extends Pipeable, Iterable<T> {
|
|
44
|
+
readonly _tag: 'one';
|
|
45
|
+
readonly length: 1;
|
|
46
|
+
readonly value: T;
|
|
47
|
+
}
|
|
48
|
+
/** @since 2.0.0 */
|
|
49
|
+
interface Two<T> extends Pipeable, Iterable<T> {
|
|
50
|
+
readonly _tag: 'two';
|
|
51
|
+
readonly length: 2;
|
|
52
|
+
readonly value: T;
|
|
53
|
+
readonly values: readonly [T, T];
|
|
54
|
+
}
|
|
55
|
+
/** @since 2.0.0 */
|
|
56
|
+
interface Three<T> extends Pipeable, Iterable<T> {
|
|
57
|
+
readonly _tag: 'three';
|
|
58
|
+
readonly length: 3;
|
|
59
|
+
readonly value: T;
|
|
60
|
+
readonly values: readonly [T, T, T];
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Any non-empty solution. All `Some<T>` values expose `.value: T` directly —
|
|
64
|
+
* no narrowing required to read the primary value.
|
|
65
|
+
*
|
|
66
|
+
* @since 2.0.0
|
|
67
|
+
*/
|
|
68
|
+
type Some<T> = One<T> | Two<T> | Three<T>;
|
|
69
|
+
/**
|
|
70
|
+
* `None | One<T>` — return type of operations that produce at most one value
|
|
71
|
+
* (e.g. inverse-solving a strictly monotonic polynomial).
|
|
72
|
+
*
|
|
73
|
+
* @since 2.0.0
|
|
74
|
+
*/
|
|
75
|
+
type AtMostOne<T> = None | One<T>;
|
|
76
|
+
/**
|
|
77
|
+
* `None | One<T> | Two<T>` — return type of operations that produce at most
|
|
78
|
+
* two values (e.g. inverse-solving an unrestricted quadratic polynomial).
|
|
79
|
+
*
|
|
80
|
+
* @since 2.0.0
|
|
81
|
+
*/
|
|
82
|
+
type AtMostTwo<T> = None | One<T> | Two<T>;
|
|
83
|
+
/**
|
|
84
|
+
* `None | One<T> | Two<T> | Three<T>` — equivalent to `Solution<T>`.
|
|
85
|
+
*
|
|
86
|
+
* @since 2.0.0
|
|
87
|
+
*/
|
|
88
|
+
type AtMostThree<T> = Solution<T>;
|
|
89
|
+
/**
|
|
90
|
+
* The empty solution. Reused across calls — never reallocated.
|
|
91
|
+
*
|
|
92
|
+
* @since 2.0.0
|
|
93
|
+
*/
|
|
94
|
+
declare const none: None;
|
|
95
|
+
/**
|
|
96
|
+
* Constructs a single-value solution.
|
|
97
|
+
*
|
|
98
|
+
* @since 2.0.0
|
|
99
|
+
*/
|
|
100
|
+
declare const one: <T>(value: T) => One<T>;
|
|
101
|
+
/**
|
|
102
|
+
* Constructs a two-value solution.
|
|
103
|
+
*
|
|
104
|
+
* @since 2.0.0
|
|
105
|
+
*/
|
|
106
|
+
declare const two: <T>(a: T, b: T) => Two<T>;
|
|
107
|
+
/**
|
|
108
|
+
* Constructs a three-value solution.
|
|
109
|
+
*
|
|
110
|
+
* @since 2.0.0
|
|
111
|
+
*/
|
|
112
|
+
declare const three: <T>(a: T, b: T, c: T) => Three<T>;
|
|
113
|
+
/**
|
|
114
|
+
* Constructs a `Solution<T>` from a runtime array. Throws if the array has
|
|
115
|
+
* more than three elements.
|
|
116
|
+
*
|
|
117
|
+
* @since 2.0.0
|
|
118
|
+
*/
|
|
119
|
+
declare const fromArray: <T>(arr: ReadonlyArray<T>) => Solution<T>;
|
|
120
|
+
/**
|
|
121
|
+
* Type-narrowing predicate: refines `Solution<T>` to `None`.
|
|
122
|
+
*
|
|
123
|
+
* @since 2.0.0
|
|
124
|
+
*/
|
|
125
|
+
declare const isNone: <T>(s: Solution<T>) => s is None;
|
|
126
|
+
/**
|
|
127
|
+
* Type-narrowing predicate: refines `Solution<T>` to `Some<T>` (non-empty).
|
|
128
|
+
* After narrowing, `.value` is directly accessible without further checks.
|
|
129
|
+
*
|
|
130
|
+
* @since 2.0.0
|
|
131
|
+
*/
|
|
132
|
+
declare const isSome: <T>(s: Solution<T>) => s is Some<T>;
|
|
133
|
+
/**
|
|
134
|
+
* Returns the primary (first) value if the solution is non-empty, or
|
|
135
|
+
* `undefined` if empty. Pair with `.value` access on `Some<T>`-narrowed
|
|
136
|
+
* inputs to avoid the `undefined` possibility.
|
|
137
|
+
*
|
|
138
|
+
* @since 2.0.0
|
|
139
|
+
*/
|
|
140
|
+
declare const valueOrUndefined: <T>(s: Solution<T>) => T | undefined;
|
|
141
|
+
/**
|
|
142
|
+
* Returns the last value in the solution, or `undefined` if empty. When
|
|
143
|
+
* called on a `Some<T>`, the result is guaranteed to be `T`.
|
|
144
|
+
*
|
|
145
|
+
* @since 2.0.0
|
|
146
|
+
*/
|
|
147
|
+
declare const last: {
|
|
148
|
+
<T>(s: Some<T>): T;
|
|
149
|
+
<T>(s: Solution<T>): T | undefined;
|
|
150
|
+
};
|
|
151
|
+
/**
|
|
152
|
+
* Returns the smallest numeric value in the solution, or `undefined` if empty.
|
|
153
|
+
* When called on a `Some<number>`, the result is guaranteed to be `number`.
|
|
154
|
+
*
|
|
155
|
+
* @since 2.0.0
|
|
156
|
+
*/
|
|
157
|
+
declare const min: {
|
|
158
|
+
(s: Some<number>): number;
|
|
159
|
+
(s: Solution<number>): number | undefined;
|
|
160
|
+
};
|
|
161
|
+
/**
|
|
162
|
+
* Returns the largest numeric value in the solution, or `undefined` if empty.
|
|
163
|
+
* When called on a `Some<number>`, the result is guaranteed to be `number`.
|
|
164
|
+
*
|
|
165
|
+
* @since 2.0.0
|
|
166
|
+
*/
|
|
167
|
+
declare const max: {
|
|
168
|
+
(s: Some<number>): number;
|
|
169
|
+
(s: Solution<number>): number | undefined;
|
|
170
|
+
};
|
|
171
|
+
/**
|
|
172
|
+
* Returns the last value in the solution. Throws if empty.
|
|
173
|
+
*
|
|
174
|
+
* @since 2.0.0
|
|
175
|
+
*/
|
|
176
|
+
declare const unsafeLast: <T>(s: Solution<T>) => T;
|
|
177
|
+
/**
|
|
178
|
+
* Returns the smallest numeric value in the solution. Throws on empty.
|
|
179
|
+
*
|
|
180
|
+
* @since 2.0.0
|
|
181
|
+
*/
|
|
182
|
+
declare const unsafeMin: (s: Solution<number>) => number;
|
|
183
|
+
/**
|
|
184
|
+
* Returns the largest numeric value in the solution. Throws on empty.
|
|
185
|
+
*
|
|
186
|
+
* @since 2.0.0
|
|
187
|
+
*/
|
|
188
|
+
declare const unsafeMax: (s: Solution<number>) => number;
|
|
189
|
+
/**
|
|
190
|
+
* Filters the solution by a predicate. Result cardinality is at most that of
|
|
191
|
+
* the input.
|
|
192
|
+
*
|
|
193
|
+
* @since 2.0.0
|
|
194
|
+
*/
|
|
195
|
+
declare const filter: <T>(s: Solution<T>, predicate: (v: T) => boolean) => Solution<T>;
|
|
196
|
+
/**
|
|
197
|
+
* Restricts the solution to values contained within an interval. Endpoint
|
|
198
|
+
* inclusivity follows the interval's `kind` — pass an open variant (e.g.
|
|
199
|
+
* `Interval.makeOpen(0, 1)` or `Interval.unitOpen`) for strict containment.
|
|
200
|
+
*
|
|
201
|
+
* @param s - The solution to clip.
|
|
202
|
+
* @param i - The interval to retain values within.
|
|
203
|
+
* @since 2.0.0
|
|
204
|
+
*/
|
|
205
|
+
declare const clip: {
|
|
206
|
+
(i: Interval): (s: Solution<number>) => Solution<number>;
|
|
207
|
+
(s: Solution<number>, i: Interval): Solution<number>;
|
|
208
|
+
};
|
|
209
|
+
/**
|
|
210
|
+
* Maps every value in the solution to a new value. Result cardinality matches
|
|
211
|
+
* the input.
|
|
212
|
+
*
|
|
213
|
+
* @since 2.0.0
|
|
214
|
+
*/
|
|
215
|
+
declare const map: {
|
|
216
|
+
<A, B>(s: Solution<A>, f: (v: A) => B): Solution<B>;
|
|
217
|
+
<A, B>(f: (v: A) => B): (s: Solution<A>) => Solution<B>;
|
|
218
|
+
};
|
|
219
|
+
type SomeOf<S> = S extends None ? never : S;
|
|
220
|
+
/**
|
|
221
|
+
* Pattern matches on a solution, calling `onNone` for the empty case and
|
|
222
|
+
* `onSome` for any non-empty case. The `onSome` parameter is typed against
|
|
223
|
+
* the input's narrowed shape — for an `AtMostOne<T>` input, `onSome` receives
|
|
224
|
+
* `One<T>` and can read `.value` directly.
|
|
225
|
+
*
|
|
226
|
+
* @example
|
|
227
|
+
* ```ts
|
|
228
|
+
* const result = polynomial.pipe(
|
|
229
|
+
* LinearPolynomial.solveInverse(0),
|
|
230
|
+
* Solution.match({
|
|
231
|
+
* onNone: () => null,
|
|
232
|
+
* onSome: ({ value }) => Math.abs(value),
|
|
233
|
+
* }),
|
|
234
|
+
* )
|
|
235
|
+
* ```
|
|
236
|
+
*
|
|
237
|
+
* @since 2.0.0
|
|
238
|
+
*/
|
|
239
|
+
declare const match: {
|
|
240
|
+
<S extends Solution<unknown>, A, B>(self: S, matcher: {
|
|
241
|
+
readonly onNone: () => A;
|
|
242
|
+
readonly onSome: (s: SomeOf<S>) => B;
|
|
243
|
+
}): A | B;
|
|
244
|
+
<S extends Solution<unknown>, A, B>(matcher: {
|
|
245
|
+
readonly onNone: () => A;
|
|
246
|
+
readonly onSome: (s: SomeOf<S>) => B;
|
|
247
|
+
}): (self: S) => A | B;
|
|
248
|
+
};
|
|
249
|
+
//#endregion
|
|
250
|
+
export { solution_d_exports as a, One as i, AtMostThree as n, AtMostTwo as r, AtMostOne as t };
|
|
251
|
+
//# sourceMappingURL=solution-BjoW7ov4.d.mts.map
|