curvy 2.0.0-alpha.6 → 2.0.0-alpha.7
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 → characteristic.d.ts} +9 -17
- package/dist/characteristic/index.d.ts +1 -0
- package/dist/characteristic/index.mjs +1 -1
- package/dist/curve/cubic2d.d.ts +215 -0
- package/dist/curve/cubic2d.internal.d.ts +2 -0
- package/dist/curve/index.d.ts +12 -0
- package/dist/curve/index.mjs +1 -1
- package/dist/curve/linear2d.d.ts +195 -0
- package/dist/curve/linear2d.internal.d.ts +2 -0
- package/dist/curve/quadratic2d.d.ts +223 -0
- package/dist/curve/quadratic2d.internal.d.ts +2 -0
- package/dist/curve/rationalCubic2d.d.ts +241 -0
- package/dist/curve/rationalCubic2d.internal.d.ts +2 -0
- package/dist/dimensions.d.ts +23 -0
- package/dist/interval/index.d.ts +6 -0
- package/dist/interval/index.mjs +2 -2
- package/dist/interval/interval.d.ts +525 -0
- package/dist/interval/interval.internal.d.ts +1 -0
- package/dist/interval/interval2d.d.ts +204 -0
- package/dist/interval/interval2d.internal.d.ts +2 -0
- package/dist/length.d.ts +32 -0
- package/dist/matrix/index.d.ts +9 -0
- package/dist/matrix/index.mjs +1 -1
- package/dist/matrix/index.mjs.map +1 -1
- package/dist/matrix/matrix2x2.d.ts +335 -0
- package/dist/matrix/matrix2x2.internal.d.ts +2 -0
- package/dist/matrix/matrix3x3.d.ts +396 -0
- package/dist/matrix/matrix3x3.internal.d.ts +4 -0
- package/dist/matrix/matrix4x4.d.ts +439 -0
- package/dist/matrix/matrix4x4.internal.d.ts +2 -0
- package/dist/number.d.ts +276 -0
- package/dist/number.mjs.map +1 -1
- package/dist/path/cubic2d.d.ts +262 -0
- package/dist/path/cubic2d.internal.d.ts +2 -0
- package/dist/path/index.d.ts +12 -0
- package/dist/path/index.mjs +413 -4
- package/dist/path/index.mjs.map +1 -1
- package/dist/path/linear2d.d.ts +245 -0
- package/dist/path/linear2d.internal.d.ts +2 -0
- package/dist/path/quadratic2d.d.ts +234 -0
- package/dist/path/quadratic2d.internal.d.ts +2 -0
- package/dist/path/rationalCubic2d.d.ts +116 -0
- package/dist/path/rationalCubic2d.internal.d.ts +2 -0
- package/dist/path/traits.d.ts +95 -0
- package/dist/polynomial/cubic.d.ts +377 -0
- package/dist/polynomial/cubic.internal.circular.d.ts +2 -0
- package/dist/polynomial/cubic.internal.d.ts +1 -0
- package/dist/polynomial/index.d.ts +9 -0
- package/dist/polynomial/index.mjs +2 -2
- package/dist/polynomial/linear.d.ts +317 -0
- package/dist/polynomial/linear.internal.d.ts +2 -0
- package/dist/polynomial/monotonicity.d.ts +3 -0
- package/dist/polynomial/quadratic.d.ts +371 -0
- package/dist/polynomial/quadratic.internal.circular.d.ts +2 -0
- package/dist/polynomial/quadratic.internal.d.ts +1 -0
- package/dist/polynomial/traits.d.ts +56 -0
- package/dist/shared/{characteristic-DLlhja-I.mjs → characteristic-D9yZWCym.mjs} +3 -3
- package/dist/shared/characteristic-D9yZWCym.mjs.map +1 -0
- package/dist/shared/{cubic-CMonq6bg.mjs → cubic-BK8xjSkd.mjs} +79 -4
- package/dist/shared/cubic-BK8xjSkd.mjs.map +1 -0
- package/dist/shared/{interval-X1EYuf-T.mjs → interval-CqC3ZIqj.mjs} +40 -1
- package/dist/shared/interval-CqC3ZIqj.mjs.map +1 -0
- package/dist/shared/{interval2d-ca0J1NMr.mjs → interval2d-BMDmeL1M.mjs} +45 -4
- package/dist/shared/interval2d-BMDmeL1M.mjs.map +1 -0
- package/dist/shared/{matrix4x4-Ck2WROK-.mjs → matrix4x4-qyRufxfs.mjs} +62 -3
- package/dist/shared/matrix4x4-qyRufxfs.mjs.map +1 -0
- package/dist/shared/{quadratic-DyeMtvET.mjs → quadratic-CWXIRh42.mjs} +2 -2
- package/dist/shared/quadratic-CWXIRh42.mjs.map +1 -0
- package/dist/shared/{rationalCubic2d-Vw4qGPZj.mjs → rationalCubic2d-BZvT9s5N.mjs} +218 -5
- package/dist/shared/rationalCubic2d-BZvT9s5N.mjs.map +1 -0
- package/dist/shared/{rationalCubic2d-D658ltUM.mjs → rationalCubic2d-DaFTrUXw.mjs} +250 -36
- package/dist/shared/rationalCubic2d-DaFTrUXw.mjs.map +1 -0
- package/dist/shared/{solution-3TDATEMn.mjs → solution-UKGK826h.mjs} +22 -2
- package/dist/shared/solution-UKGK826h.mjs.map +1 -0
- package/dist/shared/{vector2-CCuJx1rX.mjs → vector2-CWU3cPB2.mjs} +12 -2
- package/dist/shared/vector2-CWU3cPB2.mjs.map +1 -0
- package/dist/shared/{vector2.internal-DU_E808S.mjs → vector2.internal-BL8hFl1c.mjs} +31 -2
- package/dist/shared/vector2.internal-BL8hFl1c.mjs.map +1 -0
- package/dist/shared/{vector3-C-qgKAjR.mjs → vector3-DmMm6pX8.mjs} +12 -2
- package/dist/shared/vector3-DmMm6pX8.mjs.map +1 -0
- package/dist/shared/{vector4-BhOKDhD5.mjs → vector4-oqPPp45j.mjs} +12 -2
- package/dist/shared/vector4-oqPPp45j.mjs.map +1 -0
- package/dist/shared/{vector4.internal-5XcaX12X.mjs → vector4.internal-BnnTjVIr.mjs} +45 -2
- package/dist/shared/vector4.internal-BnnTjVIr.mjs.map +1 -0
- package/dist/solution/index.d.ts +1 -0
- package/dist/solution/index.mjs +1 -1
- package/dist/{shared/solution-Cf_zoKFU.d.mts → solution/solution.d.ts} +64 -71
- package/dist/solution/solution.internal.d.ts +2 -0
- package/dist/splines/basis2d.d.ts +118 -0
- package/dist/splines/basis2d.internal.d.ts +2 -0
- package/dist/splines/bezier2d.d.ts +198 -0
- package/dist/splines/bezier2d.internal.d.ts +2 -0
- package/dist/splines/cardinal2d.d.ts +269 -0
- package/dist/splines/cardinal2d.internal.d.ts +2 -0
- package/dist/splines/hermite2d.d.ts +113 -0
- package/dist/splines/hermite2d.internal.d.ts +2 -0
- package/dist/splines/index.d.ts +15 -0
- package/dist/splines/index.mjs +62 -8
- package/dist/splines/index.mjs.map +1 -1
- package/dist/splines/rationalBezier2d.d.ts +144 -0
- package/dist/splines/rationalBezier2d.internal.d.ts +2 -0
- package/dist/splines/util.d.ts +5 -0
- package/dist/utils.d.ts +73 -0
- package/dist/vector/index.d.ts +9 -0
- package/dist/vector/index.mjs +3 -3
- package/dist/vector/vector2.d.ts +449 -0
- package/dist/vector/vector2.internal.d.ts +4 -0
- package/dist/vector/vector3.d.ts +454 -0
- package/dist/vector/vector3.internal.d.ts +2 -0
- package/dist/vector/vector4.d.ts +258 -0
- package/dist/vector/vector4.internal.d.ts +2 -0
- package/package.json +13 -13
- package/dist/curve/index.d.mts +0 -2
- package/dist/interval/index.d.mts +0 -3
- package/dist/matrix/index.d.mts +0 -2
- package/dist/number.d.mts +0 -280
- package/dist/path/index.d.mts +0 -261
- package/dist/polynomial/index.d.mts +0 -2
- package/dist/shared/characteristic-DLlhja-I.mjs.map +0 -1
- package/dist/shared/cubic-C3ZMAoGj.d.mts +0 -1124
- package/dist/shared/cubic-CMonq6bg.mjs.map +0 -1
- package/dist/shared/interval-CSntLeSX.d.mts +0 -533
- package/dist/shared/interval-X1EYuf-T.mjs.map +0 -1
- package/dist/shared/interval2d-D42_0ka1.d.mts +0 -172
- package/dist/shared/interval2d-ca0J1NMr.mjs.map +0 -1
- package/dist/shared/matrix4x4-Ck2WROK-.mjs.map +0 -1
- package/dist/shared/matrix4x4-gy9ejrX2.d.mts +0 -1183
- package/dist/shared/quadratic-DyeMtvET.mjs.map +0 -1
- package/dist/shared/rationalCubic2d-C1RBShBF.d.mts +0 -818
- package/dist/shared/rationalCubic2d-D658ltUM.mjs.map +0 -1
- package/dist/shared/rationalCubic2d-DFFvp5S1.d.mts +0 -308
- package/dist/shared/rationalCubic2d-Vw4qGPZj.mjs.map +0 -1
- package/dist/shared/solution-3TDATEMn.mjs.map +0 -1
- package/dist/shared/utils-MCckigYk.d.mts +0 -76
- package/dist/shared/vector2-5GyA0jBj.d.mts +0 -470
- package/dist/shared/vector2-CCuJx1rX.mjs.map +0 -1
- package/dist/shared/vector2.internal-DU_E808S.mjs.map +0 -1
- package/dist/shared/vector3-BfOPFZEn.d.mts +0 -703
- package/dist/shared/vector3-C-qgKAjR.mjs.map +0 -1
- package/dist/shared/vector4-BhOKDhD5.mjs.map +0 -1
- package/dist/shared/vector4.internal-5XcaX12X.mjs.map +0 -1
- package/dist/solution/index.d.mts +0 -2
- package/dist/splines/index.d.mts +0 -858
- package/dist/utils.d.mts +0 -2
- package/dist/vector/index.d.mts +0 -3
|
@@ -0,0 +1,525 @@
|
|
|
1
|
+
import type { Pipeable } from '../utils.ts';
|
|
2
|
+
/**
|
|
3
|
+
* The structural minimum: any value with numeric `start` and `end` fields.
|
|
4
|
+
*
|
|
5
|
+
* Operations that don't read endpoint inclusivity (e.g. `lerp`, `normalize`,
|
|
6
|
+
* `remap`, `size`) accept `Bounds` so the signature itself documents what
|
|
7
|
+
* the operation depends on.
|
|
8
|
+
*
|
|
9
|
+
* @since 2.0.0
|
|
10
|
+
*/
|
|
11
|
+
export interface Bounds {
|
|
12
|
+
readonly start: number;
|
|
13
|
+
readonly end: number;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* A mathematical interval. Discriminated union of four variants by endpoint
|
|
17
|
+
* inclusivity: `Closed`, `OpenStart`, `OpenEnd`, `Open`. Operations that
|
|
18
|
+
* depend on inclusivity (e.g. `contains`, `filter`, `equals`) dispatch on
|
|
19
|
+
* the `kind` field; operations that don't accept the broader `Bounds` type.
|
|
20
|
+
*
|
|
21
|
+
* All fields are readonly and immutable, and all operations create new instances.
|
|
22
|
+
*
|
|
23
|
+
* @since 1.0.0
|
|
24
|
+
*/
|
|
25
|
+
export type Interval = Closed | OpenStart | OpenEnd | Open;
|
|
26
|
+
/**
|
|
27
|
+
* `[start, end]` — both endpoints included.
|
|
28
|
+
*
|
|
29
|
+
* @since 2.0.0
|
|
30
|
+
*/
|
|
31
|
+
export interface Closed extends Pipeable, Bounds {
|
|
32
|
+
readonly kind: 'closed';
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* `(start, end]` — start excluded, end included.
|
|
36
|
+
*
|
|
37
|
+
* @since 2.0.0
|
|
38
|
+
*/
|
|
39
|
+
export interface OpenStart extends Pipeable, Bounds {
|
|
40
|
+
readonly kind: 'open-start';
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* `[start, end)` — start included, end excluded.
|
|
44
|
+
*
|
|
45
|
+
* @since 2.0.0
|
|
46
|
+
*/
|
|
47
|
+
export interface OpenEnd extends Pipeable, Bounds {
|
|
48
|
+
readonly kind: 'open-end';
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* `(start, end)` — both endpoints excluded.
|
|
52
|
+
*
|
|
53
|
+
* @since 2.0.0
|
|
54
|
+
*/
|
|
55
|
+
export interface Open extends Pipeable, Bounds {
|
|
56
|
+
readonly kind: 'open';
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Checks if a value is an `Interval`.
|
|
60
|
+
*
|
|
61
|
+
* @param v - The value to check.
|
|
62
|
+
* @returns `true` if the value is an `Interval`, `false` otherwise.
|
|
63
|
+
* @since 1.0.0
|
|
64
|
+
*/
|
|
65
|
+
export declare const isInterval: (v: unknown) => v is Interval;
|
|
66
|
+
export declare const equals: {
|
|
67
|
+
/**
|
|
68
|
+
* Checks if two `Interval` instances are approximately equal within the
|
|
69
|
+
* default absolute tolerance ({@link EPSILON}).
|
|
70
|
+
*
|
|
71
|
+
* Both endpoints AND the kind must match — a `Closed` and an `OpenStart` with
|
|
72
|
+
* the same numeric endpoints are not equal. Use `aligned` for the looser
|
|
73
|
+
* "same numeric range" check.
|
|
74
|
+
*
|
|
75
|
+
* @param a - The first interval.
|
|
76
|
+
* @param b - The second interval.
|
|
77
|
+
* @returns `true` when both intervals share a kind and both endpoints are within tolerance.
|
|
78
|
+
* @since 1.1.0
|
|
79
|
+
*/
|
|
80
|
+
(a: Interval, b: Interval): boolean;
|
|
81
|
+
/**
|
|
82
|
+
* Checks if two `Interval` instances are approximately equal within the
|
|
83
|
+
* default absolute tolerance ({@link EPSILON}).
|
|
84
|
+
*
|
|
85
|
+
* @param b - The second interval.
|
|
86
|
+
* @returns A function that takes the first interval and returns the comparison result.
|
|
87
|
+
* @since 1.1.0
|
|
88
|
+
*/
|
|
89
|
+
(b: Interval): (a: Interval) => boolean;
|
|
90
|
+
};
|
|
91
|
+
export declare const aligned: {
|
|
92
|
+
/**
|
|
93
|
+
* Checks if two values share the same numeric range, ignoring endpoint
|
|
94
|
+
* inclusivity. Accepts any `Bounds`-shaped value.
|
|
95
|
+
*
|
|
96
|
+
* @param a - The first bounds.
|
|
97
|
+
* @param b - The second bounds.
|
|
98
|
+
* @returns `true` when both endpoints are within the default tolerance ({@link EPSILON}).
|
|
99
|
+
* @since 2.0.0
|
|
100
|
+
*/
|
|
101
|
+
(a: Bounds, b: Bounds): boolean;
|
|
102
|
+
/**
|
|
103
|
+
* @param b - The second bounds.
|
|
104
|
+
* @returns A function that takes the first bounds and returns the comparison result.
|
|
105
|
+
* @since 2.0.0
|
|
106
|
+
*/
|
|
107
|
+
(b: Bounds): (a: Bounds) => boolean;
|
|
108
|
+
};
|
|
109
|
+
export declare const make: {
|
|
110
|
+
/**
|
|
111
|
+
* Creates a new closed `Interval` instance.
|
|
112
|
+
*
|
|
113
|
+
* @param point - The point of the interval.
|
|
114
|
+
* @returns A new `Closed` interval `[point, point]`.
|
|
115
|
+
* @since 1.0.0
|
|
116
|
+
*/
|
|
117
|
+
(point: number): Closed;
|
|
118
|
+
/**
|
|
119
|
+
* Creates a new closed `Interval` instance.
|
|
120
|
+
*
|
|
121
|
+
* @param start - The start of the interval.
|
|
122
|
+
* @param end - The end of the interval.
|
|
123
|
+
* @returns A new `Closed` interval `[start, end]`.
|
|
124
|
+
* @since 1.0.0
|
|
125
|
+
*/
|
|
126
|
+
(start: number, end: number): Closed;
|
|
127
|
+
};
|
|
128
|
+
export declare const makeOpenStart: {
|
|
129
|
+
/**
|
|
130
|
+
* Creates a new left-open `Interval` instance.
|
|
131
|
+
*
|
|
132
|
+
* @param point - The point of the interval.
|
|
133
|
+
* @returns A new `OpenStart` interval `(point, point]` (degenerate, empty).
|
|
134
|
+
* @since 2.0.0
|
|
135
|
+
*/
|
|
136
|
+
(point: number): OpenStart;
|
|
137
|
+
/**
|
|
138
|
+
* Creates a new left-open `Interval` instance.
|
|
139
|
+
*
|
|
140
|
+
* @param start - The start of the interval (excluded).
|
|
141
|
+
* @param end - The end of the interval (included).
|
|
142
|
+
* @returns A new `OpenStart` interval `(start, end]`.
|
|
143
|
+
* @since 2.0.0
|
|
144
|
+
*/
|
|
145
|
+
(start: number, end: number): OpenStart;
|
|
146
|
+
};
|
|
147
|
+
export declare const makeOpenEnd: {
|
|
148
|
+
/**
|
|
149
|
+
* Creates a new right-open `Interval` instance.
|
|
150
|
+
*
|
|
151
|
+
* @param point - The point of the interval.
|
|
152
|
+
* @returns A new `OpenEnd` interval `[point, point)` (degenerate, empty).
|
|
153
|
+
* @since 2.0.0
|
|
154
|
+
*/
|
|
155
|
+
(point: number): OpenEnd;
|
|
156
|
+
/**
|
|
157
|
+
* Creates a new right-open `Interval` instance.
|
|
158
|
+
*
|
|
159
|
+
* @param start - The start of the interval (included).
|
|
160
|
+
* @param end - The end of the interval (excluded).
|
|
161
|
+
* @returns A new `OpenEnd` interval `[start, end)`.
|
|
162
|
+
* @since 2.0.0
|
|
163
|
+
*/
|
|
164
|
+
(start: number, end: number): OpenEnd;
|
|
165
|
+
};
|
|
166
|
+
export declare const makeOpen: {
|
|
167
|
+
/**
|
|
168
|
+
* Creates a new fully open `Interval` instance.
|
|
169
|
+
*
|
|
170
|
+
* @param point - The point of the interval.
|
|
171
|
+
* @returns A new `Open` interval `(point, point)` (degenerate, empty).
|
|
172
|
+
* @since 2.0.0
|
|
173
|
+
*/
|
|
174
|
+
(point: number): Open;
|
|
175
|
+
/**
|
|
176
|
+
* Creates a new fully open `Interval` instance.
|
|
177
|
+
*
|
|
178
|
+
* @param start - The start of the interval (excluded).
|
|
179
|
+
* @param end - The end of the interval (excluded).
|
|
180
|
+
* @returns A new `Open` interval `(start, end)`.
|
|
181
|
+
* @since 2.0.0
|
|
182
|
+
*/
|
|
183
|
+
(start: number, end: number): Open;
|
|
184
|
+
};
|
|
185
|
+
export declare const fromSize: {
|
|
186
|
+
/**
|
|
187
|
+
* Creates a new closed `Interval` instance from a size.
|
|
188
|
+
*
|
|
189
|
+
* @param size - The size of the interval.
|
|
190
|
+
* @returns A new `Closed` interval `[0, size]`.
|
|
191
|
+
* @since 1.0.0
|
|
192
|
+
*/
|
|
193
|
+
(size: number): Closed;
|
|
194
|
+
/**
|
|
195
|
+
* Creates a new closed `Interval` instance from a size.
|
|
196
|
+
*
|
|
197
|
+
* @param start - The start of the interval.
|
|
198
|
+
* @param size - The size of the interval.
|
|
199
|
+
* @returns A new `Closed` interval `[start, start + size]`.
|
|
200
|
+
* @since 1.0.0
|
|
201
|
+
*/
|
|
202
|
+
(start: number, size: number): Closed;
|
|
203
|
+
};
|
|
204
|
+
/**
|
|
205
|
+
* Creates a new closed `Interval` from a minimum and maximum value, in any order.
|
|
206
|
+
*
|
|
207
|
+
* @param values - The values to take the min and max of.
|
|
208
|
+
* @returns A new `Closed` interval `[min(values), max(values)]`.
|
|
209
|
+
* @since 1.0.0
|
|
210
|
+
*/
|
|
211
|
+
export declare const fromMinMax: (...values: ReadonlyArray<number>) => Closed;
|
|
212
|
+
/**
|
|
213
|
+
* Calculates the size of an interval.
|
|
214
|
+
*
|
|
215
|
+
* Kind-agnostic — `size` of `[0, 1]` and `(0, 1)` are both `1`.
|
|
216
|
+
*
|
|
217
|
+
* @param i - The bounds to calculate the size of.
|
|
218
|
+
* @returns The size of the bounds.
|
|
219
|
+
* @since 1.0.0
|
|
220
|
+
*/
|
|
221
|
+
export declare const size: (i: Bounds) => number;
|
|
222
|
+
export declare const contains: {
|
|
223
|
+
/**
|
|
224
|
+
* Checks if a value is contained within an interval. Endpoint inclusivity
|
|
225
|
+
* follows the interval's `kind`.
|
|
226
|
+
*
|
|
227
|
+
* @param interval - The interval to check.
|
|
228
|
+
* @param value - The value to check.
|
|
229
|
+
* @returns `true` if the value is contained within the interval, `false` otherwise.
|
|
230
|
+
* @since 1.0.0
|
|
231
|
+
*/
|
|
232
|
+
(interval: Interval, value: number): boolean;
|
|
233
|
+
/**
|
|
234
|
+
* Checks if a value is contained within an interval. Endpoint inclusivity
|
|
235
|
+
* follows the interval's `kind`.
|
|
236
|
+
*
|
|
237
|
+
* @param value - The value to check.
|
|
238
|
+
* @returns A function that takes an interval and returns `true` if the value is contained within the interval, `false` otherwise.
|
|
239
|
+
* @since 1.0.0
|
|
240
|
+
*/
|
|
241
|
+
(value: number): (interval: Interval) => boolean;
|
|
242
|
+
};
|
|
243
|
+
export declare const containsInterval: {
|
|
244
|
+
/**
|
|
245
|
+
* Checks if `inner` is a subset of `outer` — every point of `inner` is also
|
|
246
|
+
* in `outer`. Respects endpoint inclusivity on both sides: a closed inner
|
|
247
|
+
* endpoint must be inside (or on a closed boundary of) the outer, while an
|
|
248
|
+
* open inner endpoint can sit exactly on an open outer boundary.
|
|
249
|
+
*
|
|
250
|
+
* @param outer - The enclosing interval.
|
|
251
|
+
* @param inner - The candidate inner interval.
|
|
252
|
+
* @returns `true` when `inner` is a subset of `outer`.
|
|
253
|
+
* @since 2.0.0
|
|
254
|
+
*/
|
|
255
|
+
(outer: Interval, inner: Interval): boolean;
|
|
256
|
+
/**
|
|
257
|
+
* @param inner - The candidate inner interval.
|
|
258
|
+
* @returns A function that takes the outer interval and returns the containment result.
|
|
259
|
+
* @since 2.0.0
|
|
260
|
+
*/
|
|
261
|
+
(inner: Interval): (outer: Interval) => boolean;
|
|
262
|
+
};
|
|
263
|
+
export declare const union: {
|
|
264
|
+
/**
|
|
265
|
+
* Returns the smallest interval enclosing both inputs. Each endpoint's
|
|
266
|
+
* inclusivity follows the input that contributed it; when both endpoints
|
|
267
|
+
* tie, the result is closed at that point if either input includes it.
|
|
268
|
+
*
|
|
269
|
+
* @param a - The first interval.
|
|
270
|
+
* @param b - The second interval.
|
|
271
|
+
* @returns A new interval enclosing both inputs.
|
|
272
|
+
* @since 2.0.0
|
|
273
|
+
*/
|
|
274
|
+
(a: Interval, b: Interval): Interval;
|
|
275
|
+
/**
|
|
276
|
+
* @param b - The second interval.
|
|
277
|
+
* @returns A function that takes the first interval and returns the union.
|
|
278
|
+
* @since 2.0.0
|
|
279
|
+
*/
|
|
280
|
+
(b: Interval): (a: Interval) => Interval;
|
|
281
|
+
};
|
|
282
|
+
export declare const filter: {
|
|
283
|
+
/**
|
|
284
|
+
* Filters an array of values to those contained within an interval.
|
|
285
|
+
* Endpoint inclusivity follows the interval's `kind`.
|
|
286
|
+
*
|
|
287
|
+
* @param interval - The interval to filter the values to.
|
|
288
|
+
* @param value - The values to filter.
|
|
289
|
+
* @returns The filtered values.
|
|
290
|
+
* @since 1.0.0
|
|
291
|
+
*/
|
|
292
|
+
<V extends ReadonlyArray<number>>(interval: Interval, value: V): V;
|
|
293
|
+
/**
|
|
294
|
+
* Filters an array of values to those contained within an interval.
|
|
295
|
+
*
|
|
296
|
+
* @param value - The values to filter.
|
|
297
|
+
* @returns A function that takes an interval and returns the filtered values.
|
|
298
|
+
* @since 1.0.0
|
|
299
|
+
*/
|
|
300
|
+
<V extends ReadonlyArray<number>>(value: V): (interval: Interval) => V;
|
|
301
|
+
};
|
|
302
|
+
export declare const clamp: {
|
|
303
|
+
/**
|
|
304
|
+
* Clamps a value to be within bounds. Kind-agnostic — clamps to the numeric
|
|
305
|
+
* range regardless of endpoint inclusivity.
|
|
306
|
+
*
|
|
307
|
+
* @param interval - The bounds to clamp the value to.
|
|
308
|
+
* @param value - The value to clamp.
|
|
309
|
+
* @returns The clamped value.
|
|
310
|
+
* @since 1.0.0
|
|
311
|
+
*/
|
|
312
|
+
(interval: Bounds, value: number): number;
|
|
313
|
+
/**
|
|
314
|
+
* Clamps a value to be within bounds. Kind-agnostic.
|
|
315
|
+
*
|
|
316
|
+
* @param value - The value to clamp.
|
|
317
|
+
* @returns A function that takes bounds and returns the clamped value.
|
|
318
|
+
* @since 1.0.0
|
|
319
|
+
*/
|
|
320
|
+
(value: number): (interval: Bounds) => number;
|
|
321
|
+
/**
|
|
322
|
+
* Clamps an array of values to be within bounds. Kind-agnostic.
|
|
323
|
+
*
|
|
324
|
+
* @param interval - The bounds to clamp the values to.
|
|
325
|
+
* @param value - The values to clamp.
|
|
326
|
+
* @returns The clamped values.
|
|
327
|
+
* @since 1.0.0
|
|
328
|
+
*/
|
|
329
|
+
(interval: Bounds, value: ReadonlyArray<number>): ReadonlyArray<number>;
|
|
330
|
+
/**
|
|
331
|
+
* Clamps an array of values to be within bounds. Kind-agnostic.
|
|
332
|
+
*
|
|
333
|
+
* @param value - The values to clamp.
|
|
334
|
+
* @returns A function that takes bounds and returns the clamped values.
|
|
335
|
+
* @since 1.0.0
|
|
336
|
+
*/
|
|
337
|
+
(value: ReadonlyArray<number>): (interval: Bounds) => ReadonlyArray<number>;
|
|
338
|
+
};
|
|
339
|
+
/**
|
|
340
|
+
* Returns an interval with the start endpoint open. Preserves the end endpoint's inclusivity.
|
|
341
|
+
*
|
|
342
|
+
* @since 2.0.0
|
|
343
|
+
*/
|
|
344
|
+
export declare const toStartOpen: {
|
|
345
|
+
(i: Closed | OpenStart): OpenStart;
|
|
346
|
+
(i: OpenEnd | Open): Open;
|
|
347
|
+
};
|
|
348
|
+
/**
|
|
349
|
+
* Returns an interval with the start endpoint closed. Preserves the end endpoint's inclusivity.
|
|
350
|
+
*
|
|
351
|
+
* @since 2.0.0
|
|
352
|
+
*/
|
|
353
|
+
export declare const toStartClosed: {
|
|
354
|
+
(i: Closed | OpenEnd): Closed;
|
|
355
|
+
(i: OpenStart | Open): OpenEnd;
|
|
356
|
+
};
|
|
357
|
+
/**
|
|
358
|
+
* Returns an interval with the end endpoint open. Preserves the start endpoint's inclusivity.
|
|
359
|
+
*
|
|
360
|
+
* @since 2.0.0
|
|
361
|
+
*/
|
|
362
|
+
export declare const toEndOpen: {
|
|
363
|
+
(i: Closed | OpenEnd): OpenEnd;
|
|
364
|
+
(i: OpenStart | Open): Open;
|
|
365
|
+
};
|
|
366
|
+
/**
|
|
367
|
+
* Returns an interval with the end endpoint closed. Preserves the start endpoint's inclusivity.
|
|
368
|
+
*
|
|
369
|
+
* @since 2.0.0
|
|
370
|
+
*/
|
|
371
|
+
export declare const toEndClosed: {
|
|
372
|
+
(i: Closed | OpenEnd): Closed;
|
|
373
|
+
(i: OpenStart | Open): OpenStart;
|
|
374
|
+
};
|
|
375
|
+
/**
|
|
376
|
+
* Returns a closed interval over the same numeric range.
|
|
377
|
+
*
|
|
378
|
+
* @since 2.0.0
|
|
379
|
+
*/
|
|
380
|
+
export declare const toClosed: (i: Interval) => Closed;
|
|
381
|
+
/**
|
|
382
|
+
* Returns a fully open interval over the same numeric range.
|
|
383
|
+
*
|
|
384
|
+
* @since 2.0.0
|
|
385
|
+
*/
|
|
386
|
+
export declare const toOpen: (i: Interval) => Open;
|
|
387
|
+
/**
|
|
388
|
+
* Type-narrowing predicate: refines `Interval` to `Closed`.
|
|
389
|
+
*
|
|
390
|
+
* @since 2.0.0
|
|
391
|
+
*/
|
|
392
|
+
export declare const isClosed: (i: Interval) => i is Closed;
|
|
393
|
+
/**
|
|
394
|
+
* Type-narrowing predicate: refines `Interval` to `Open`.
|
|
395
|
+
*
|
|
396
|
+
* @since 2.0.0
|
|
397
|
+
*/
|
|
398
|
+
export declare const isOpen: (i: Interval) => i is Open;
|
|
399
|
+
/**
|
|
400
|
+
* Type-narrowing predicate: refines `Interval` to `OpenStart`.
|
|
401
|
+
*
|
|
402
|
+
* @since 2.0.0
|
|
403
|
+
*/
|
|
404
|
+
export declare const isOpenStart: (i: Interval) => i is OpenStart;
|
|
405
|
+
/**
|
|
406
|
+
* Type-narrowing predicate: refines `Interval` to `OpenEnd`.
|
|
407
|
+
*
|
|
408
|
+
* @since 2.0.0
|
|
409
|
+
*/
|
|
410
|
+
export declare const isOpenEnd: (i: Interval) => i is OpenEnd;
|
|
411
|
+
/**
|
|
412
|
+
* Type-narrowing predicate: refines `Interval` to those with an open start endpoint.
|
|
413
|
+
*
|
|
414
|
+
* @since 2.0.0
|
|
415
|
+
*/
|
|
416
|
+
export declare const isOpenAtStart: (i: Interval) => i is OpenStart | Open;
|
|
417
|
+
/**
|
|
418
|
+
* Type-narrowing predicate: refines `Interval` to those with an open end endpoint.
|
|
419
|
+
*
|
|
420
|
+
* @since 2.0.0
|
|
421
|
+
*/
|
|
422
|
+
export declare const isOpenAtEnd: (i: Interval) => i is OpenEnd | Open;
|
|
423
|
+
/**
|
|
424
|
+
* Type-narrowing predicate: refines `Interval` to those with a closed start endpoint.
|
|
425
|
+
*
|
|
426
|
+
* @since 2.0.0
|
|
427
|
+
*/
|
|
428
|
+
export declare const isClosedAtStart: (i: Interval) => i is Closed | OpenEnd;
|
|
429
|
+
/**
|
|
430
|
+
* Type-narrowing predicate: refines `Interval` to those with a closed end endpoint.
|
|
431
|
+
*
|
|
432
|
+
* @since 2.0.0
|
|
433
|
+
*/
|
|
434
|
+
export declare const isClosedAtEnd: (i: Interval) => i is Closed | OpenStart;
|
|
435
|
+
/**
|
|
436
|
+
* The unit interval, `[0, 1]`.
|
|
437
|
+
*
|
|
438
|
+
* @since 1.0.0
|
|
439
|
+
*/
|
|
440
|
+
export declare const unit: Closed;
|
|
441
|
+
/**
|
|
442
|
+
* The open unit interval, `(0, 1)`. The symmetric open analog of {@link unit};
|
|
443
|
+
* convenient for "strict interior" use cases such as filtering roots that
|
|
444
|
+
* must lie strictly inside the unit parameter range.
|
|
445
|
+
*
|
|
446
|
+
* @since 2.0.0
|
|
447
|
+
*/
|
|
448
|
+
export declare const unitOpen: Open;
|
|
449
|
+
/**
|
|
450
|
+
* The biunit interval, `[-1, 1]`.
|
|
451
|
+
*
|
|
452
|
+
* @since 1.0.0
|
|
453
|
+
*/
|
|
454
|
+
export declare const biunit: Closed;
|
|
455
|
+
/**
|
|
456
|
+
* Linearly interpolates a value within bounds.
|
|
457
|
+
*
|
|
458
|
+
* @param interval - The bounds to interpolate within.
|
|
459
|
+
* @param t - The interpolation factor, typically between 0 and 1.
|
|
460
|
+
* @returns The interpolated value.
|
|
461
|
+
* @since 1.0.0
|
|
462
|
+
*/
|
|
463
|
+
export declare const lerp: (interval: Bounds, t: number) => number;
|
|
464
|
+
/**
|
|
465
|
+
* Creates a linear interpolation function for given bounds.
|
|
466
|
+
*
|
|
467
|
+
* @param interval - The bounds to create the interpolation function for.
|
|
468
|
+
* @returns A function that takes a factor `t` and returns the interpolated value.
|
|
469
|
+
* @since 1.0.0
|
|
470
|
+
*/
|
|
471
|
+
export declare const toLerpFn: (interval: Bounds) => (t: number) => number;
|
|
472
|
+
/**
|
|
473
|
+
* Normalizes a value within bounds.
|
|
474
|
+
*
|
|
475
|
+
* @param interval - The bounds to normalize within.
|
|
476
|
+
* @param x - The value to normalize.
|
|
477
|
+
* @returns The normalized value.
|
|
478
|
+
* @since 1.0.0
|
|
479
|
+
*/
|
|
480
|
+
export declare const normalize: (interval: Bounds, x: number) => number;
|
|
481
|
+
/**
|
|
482
|
+
* Creates a normalization function for given bounds.
|
|
483
|
+
*
|
|
484
|
+
* @param interval - The bounds to create the normalization function for.
|
|
485
|
+
* @returns A function that takes a value `x` and returns the normalized value.
|
|
486
|
+
* @since 1.0.0
|
|
487
|
+
*/
|
|
488
|
+
export declare const toNormalizeFn: (interval: Bounds) => (x: number) => number;
|
|
489
|
+
/**
|
|
490
|
+
* Remaps a value from one bounds to another.
|
|
491
|
+
*
|
|
492
|
+
* @param source - The source bounds.
|
|
493
|
+
* @param target - The target bounds.
|
|
494
|
+
* @param x - The value to remap.
|
|
495
|
+
* @returns The remapped value.
|
|
496
|
+
* @since 1.0.0
|
|
497
|
+
*/
|
|
498
|
+
export declare const remap: (source: Bounds, target: Bounds, x: number) => number;
|
|
499
|
+
/**
|
|
500
|
+
* Creates a remapping function for given bounds.
|
|
501
|
+
*
|
|
502
|
+
* @param source - The source bounds.
|
|
503
|
+
* @param target - The target bounds.
|
|
504
|
+
* @returns A function that takes a value `x` and returns the remapped value.
|
|
505
|
+
* @since 1.0.0
|
|
506
|
+
*/
|
|
507
|
+
export declare const toRemapFn: (source: Bounds, target: Bounds) => (x: number) => number;
|
|
508
|
+
/**
|
|
509
|
+
* Calculates the scale and shift needed to map a source bounds to a target bounds.
|
|
510
|
+
*
|
|
511
|
+
* @param source - The source bounds.
|
|
512
|
+
* @param target - The target bounds.
|
|
513
|
+
* @returns An object containing the scale and shift values.
|
|
514
|
+
* @since 1.0.0
|
|
515
|
+
*/
|
|
516
|
+
export declare const scaleShift: (source: Bounds, target: Bounds) => ScaleShift;
|
|
517
|
+
/**
|
|
518
|
+
* The scale and shift needed to map a source bounds to a target bounds.
|
|
519
|
+
*
|
|
520
|
+
* @since 1.0.0
|
|
521
|
+
*/
|
|
522
|
+
export interface ScaleShift {
|
|
523
|
+
readonly scale: number;
|
|
524
|
+
readonly shift: number;
|
|
525
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|