curvy 1.0.9 → 2.0.0-alpha.2
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 +3 -0
- package/dist/interval/index.mjs +3 -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 +261 -0
- package/dist/path/index.mjs +325 -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-B9nCh_cx.mjs +104 -0
- package/dist/shared/characteristic-B9nCh_cx.mjs.map +1 -0
- package/dist/shared/chunk-25Hzd3z8.mjs +13 -0
- package/dist/shared/cubic-BajUY0JT.d.mts +1100 -0
- package/dist/shared/cubic-CpHAx8cC.mjs +479 -0
- package/dist/shared/cubic-CpHAx8cC.mjs.map +1 -0
- package/dist/shared/interval-05CR6eBf.mjs +421 -0
- package/dist/shared/interval-05CR6eBf.mjs.map +1 -0
- package/dist/shared/interval-Dy-RMEE3.d.mts +533 -0
- package/dist/shared/interval2d-8IBZnUOq.mjs +108 -0
- package/dist/shared/interval2d-8IBZnUOq.mjs.map +1 -0
- package/dist/shared/interval2d-C2id9u31.d.mts +172 -0
- package/dist/shared/matrix4x4-Ck2WROK-.mjs +440 -0
- package/dist/shared/matrix4x4-Ck2WROK-.mjs.map +1 -0
- package/dist/shared/matrix4x4-Dm_tSiH1.d.mts +1183 -0
- package/dist/shared/quadratic-CamozcFc.mjs +330 -0
- package/dist/shared/quadratic-CamozcFc.mjs.map +1 -0
- package/dist/shared/rationalCubic2d-B6g97ryJ.d.mts +308 -0
- package/dist/shared/rationalCubic2d-BEgUGSFf.mjs +295 -0
- package/dist/shared/rationalCubic2d-BEgUGSFf.mjs.map +1 -0
- package/dist/shared/rationalCubic2d-Bys2Uory.mjs +695 -0
- package/dist/shared/rationalCubic2d-Bys2Uory.mjs.map +1 -0
- package/dist/shared/rationalCubic2d-DlQfBURs.d.mts +818 -0
- package/dist/shared/solution-CrtLfqEq.mjs +306 -0
- package/dist/shared/solution-CrtLfqEq.mjs.map +1 -0
- package/dist/shared/solution-sNQ-ZVhN.d.mts +251 -0
- package/dist/{pipe.d.mts → shared/utils-MCckigYk.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-DPUY3_eA.d.mts +470 -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/vector3-DqeOZtOB.d.mts +703 -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 -205
- package/dist/utils.mjs +88 -52
- package/dist/utils.mjs.map +1 -1
- package/dist/vector/index.d.mts +3 -0
- package/dist/vector/index.mjs +4 -0
- package/package.json +49 -92
- package/dist/curve/cubic2d.d.mts +0 -109
- package/dist/curve/cubic2d.d.ts +0 -109
- package/dist/curve/cubic2d.mjs +0 -80
- package/dist/curve/cubic2d.mjs.map +0 -1
- package/dist/curve/linear2d.d.mts +0 -94
- package/dist/curve/linear2d.d.ts +0 -94
- package/dist/curve/linear2d.mjs +0 -46
- package/dist/curve/linear2d.mjs.map +0 -1
- package/dist/curve/quadratic2d.d.mts +0 -117
- package/dist/curve/quadratic2d.d.ts +0 -117
- package/dist/curve/quadratic2d.mjs +0 -82
- package/dist/curve/quadratic2d.mjs.map +0 -1
- package/dist/interval.d.mts +0 -251
- package/dist/interval.d.ts +0 -251
- package/dist/interval.mjs +0 -86
- package/dist/interval.mjs.map +0 -1
- package/dist/matrix/matrix2x2.d.mts +0 -320
- package/dist/matrix/matrix2x2.d.ts +0 -320
- package/dist/matrix/matrix2x2.mjs +0 -25
- package/dist/matrix/matrix2x2.mjs.map +0 -1
- package/dist/matrix/matrix3x3.d.mts +0 -370
- package/dist/matrix/matrix3x3.d.ts +0 -370
- package/dist/matrix/matrix3x3.mjs +0 -28
- package/dist/matrix/matrix3x3.mjs.map +0 -1
- package/dist/matrix/matrix4x4.d.mts +0 -381
- package/dist/matrix/matrix4x4.d.ts +0 -381
- package/dist/matrix/matrix4x4.mjs +0 -178
- package/dist/matrix/matrix4x4.mjs.map +0 -1
- package/dist/path/cubic2d.d.mts +0 -95
- package/dist/path/cubic2d.d.ts +0 -95
- package/dist/path/cubic2d.mjs +0 -60
- package/dist/path/cubic2d.mjs.map +0 -1
- package/dist/path/linear2d.d.mts +0 -95
- package/dist/path/linear2d.d.ts +0 -95
- package/dist/path/linear2d.mjs +0 -53
- package/dist/path/linear2d.mjs.map +0 -1
- package/dist/path/quadratic2d.d.mts +0 -95
- package/dist/path/quadratic2d.d.ts +0 -95
- package/dist/path/quadratic2d.mjs +0 -57
- package/dist/path/quadratic2d.mjs.map +0 -1
- package/dist/pipe.d.ts +0 -58
- package/dist/pipe.mjs +0 -92
- package/dist/pipe.mjs.map +0 -1
- package/dist/polynomial/cubic.d.mts +0 -7
- package/dist/polynomial/cubic.d.ts +0 -7
- package/dist/polynomial/cubic.mjs +0 -133
- package/dist/polynomial/cubic.mjs.map +0 -1
- package/dist/polynomial/linear.d.mts +0 -7
- package/dist/polynomial/linear.d.ts +0 -7
- package/dist/polynomial/linear.mjs +0 -24
- package/dist/polynomial/linear.mjs.map +0 -1
- package/dist/polynomial/quadratic.d.mts +0 -7
- package/dist/polynomial/quadratic.d.ts +0 -7
- package/dist/polynomial/quadratic.mjs +0 -27
- package/dist/polynomial/quadratic.mjs.map +0 -1
- package/dist/shared/curvy.Bf5TIk31.d.mts +0 -22
- package/dist/shared/curvy.Bf5TIk31.d.ts +0 -22
- package/dist/shared/curvy.BkkW8Tx9.mjs +0 -102
- package/dist/shared/curvy.BkkW8Tx9.mjs.map +0 -1
- package/dist/shared/curvy.BxdGW9he.mjs +0 -116
- package/dist/shared/curvy.BxdGW9he.mjs.map +0 -1
- package/dist/shared/curvy.C_sCeg9J.mjs +0 -66
- package/dist/shared/curvy.C_sCeg9J.mjs.map +0 -1
- package/dist/shared/curvy.Cg8lZVUz.d.ts +0 -688
- package/dist/shared/curvy.DCt1gGII.mjs +0 -147
- package/dist/shared/curvy.DCt1gGII.mjs.map +0 -1
- package/dist/shared/curvy.DJ4xO0al.mjs +0 -63
- package/dist/shared/curvy.DJ4xO0al.mjs.map +0 -1
- package/dist/shared/curvy.DmVFTi0N.mjs +0 -35
- package/dist/shared/curvy.DmVFTi0N.mjs.map +0 -1
- package/dist/shared/curvy.FDaj5rlj.d.mts +0 -688
- package/dist/shared/curvy.lktriTpx.mjs +0 -101
- package/dist/shared/curvy.lktriTpx.mjs.map +0 -1
- package/dist/shared/curvy.mLFprrGm.mjs +0 -85
- package/dist/shared/curvy.mLFprrGm.mjs.map +0 -1
- package/dist/shared/curvy.r6f1j287.mjs +0 -76
- package/dist/shared/curvy.r6f1j287.mjs.map +0 -1
- package/dist/splines/basis2d.d.mts +0 -130
- package/dist/splines/basis2d.d.ts +0 -130
- package/dist/splines/basis2d.mjs +0 -90
- package/dist/splines/basis2d.mjs.map +0 -1
- package/dist/splines/bezier2d.d.mts +0 -182
- package/dist/splines/bezier2d.d.ts +0 -182
- package/dist/splines/bezier2d.mjs +0 -23
- package/dist/splines/bezier2d.mjs.map +0 -1
- package/dist/splines/cardinal2d.d.mts +0 -178
- package/dist/splines/cardinal2d.d.ts +0 -178
- package/dist/splines/cardinal2d.mjs +0 -114
- package/dist/splines/cardinal2d.mjs.map +0 -1
- package/dist/splines/hermite2d.d.mts +0 -124
- package/dist/splines/hermite2d.d.ts +0 -124
- package/dist/splines/hermite2d.mjs +0 -63
- package/dist/splines/hermite2d.mjs.map +0 -1
- package/dist/utils.d.ts +0 -205
- package/dist/vector/vector2.d.mts +0 -324
- package/dist/vector/vector2.d.ts +0 -324
- package/dist/vector/vector2.mjs +0 -30
- package/dist/vector/vector2.mjs.map +0 -1
- package/dist/vector/vector3.d.mts +0 -417
- package/dist/vector/vector3.d.ts +0 -417
- package/dist/vector/vector3.mjs +0 -38
- package/dist/vector/vector3.mjs.map +0 -1
- package/dist/vector/vector4.d.mts +0 -205
- package/dist/vector/vector4.d.ts +0 -205
- package/dist/vector/vector4.mjs +0 -20
- package/dist/vector/vector4.mjs.map +0 -1
package/dist/interval.d.mts
DELETED
|
@@ -1,251 +0,0 @@
|
|
|
1
|
-
import { Pipeable } from './pipe.mjs';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* A mathematical interval.
|
|
5
|
-
*
|
|
6
|
-
* All fields are readonly and immutable, and all operations create new instances.
|
|
7
|
-
*
|
|
8
|
-
* @since 1.0.0
|
|
9
|
-
*/
|
|
10
|
-
interface Interval extends Pipeable {
|
|
11
|
-
readonly start: number;
|
|
12
|
-
readonly end: number;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Checks if a value is an `Interval`.
|
|
16
|
-
*
|
|
17
|
-
* @param v - The value to check.
|
|
18
|
-
* @returns `true` if the value is an `Interval`, `false` otherwise.
|
|
19
|
-
* @since 1.0.0
|
|
20
|
-
*/
|
|
21
|
-
declare const isInterval: (v: unknown) => v is Interval;
|
|
22
|
-
declare const make: {
|
|
23
|
-
/**
|
|
24
|
-
* Creates a new `Interval` instance.
|
|
25
|
-
*
|
|
26
|
-
* @param point - The point of the interval.
|
|
27
|
-
* @returns A new `Interval` instance.
|
|
28
|
-
* @since 1.0.0
|
|
29
|
-
*/
|
|
30
|
-
(point: number): Interval;
|
|
31
|
-
/**
|
|
32
|
-
* Creates a new `Interval` instance.
|
|
33
|
-
*
|
|
34
|
-
* @param start - The start of the interval.
|
|
35
|
-
* @param end - The end of the interval.
|
|
36
|
-
* @returns A new `Interval` instance.
|
|
37
|
-
* @since 1.0.0
|
|
38
|
-
*/
|
|
39
|
-
(start: number, end: number): Interval;
|
|
40
|
-
};
|
|
41
|
-
declare const fromSize: {
|
|
42
|
-
/**
|
|
43
|
-
* Creates a new `Interval` instance from a size.
|
|
44
|
-
*
|
|
45
|
-
* @param size - The size of the interval.
|
|
46
|
-
* @returns A new `Interval` instance.
|
|
47
|
-
* @since 1.0.0
|
|
48
|
-
*/
|
|
49
|
-
(size: number): Interval;
|
|
50
|
-
/**
|
|
51
|
-
* Creates a new `Interval` instance from a size.
|
|
52
|
-
*
|
|
53
|
-
* @param size - The size of the interval.
|
|
54
|
-
* @param start - The start of the interval.
|
|
55
|
-
* @returns A new `Interval` instance.
|
|
56
|
-
* @since 1.0.0
|
|
57
|
-
*/
|
|
58
|
-
(start: number, size: number): Interval;
|
|
59
|
-
};
|
|
60
|
-
/**
|
|
61
|
-
* Creates a new `Interval` instance from a minimum and maximum value.
|
|
62
|
-
*
|
|
63
|
-
* @param values - The minimum and maximum values of the interval.
|
|
64
|
-
* @returns A new `Interval` instance.
|
|
65
|
-
* @since 1.0.0
|
|
66
|
-
*/
|
|
67
|
-
declare const fromMinMax: (...values: ReadonlyArray<number>) => Interval;
|
|
68
|
-
/**
|
|
69
|
-
* Calculates the size of an interval.
|
|
70
|
-
*
|
|
71
|
-
* @param interval - The interval to calculate the size of.
|
|
72
|
-
* @returns The size of the interval.
|
|
73
|
-
* @since 1.0.0
|
|
74
|
-
*/
|
|
75
|
-
declare const size: (i: Interval) => number;
|
|
76
|
-
declare const contains: {
|
|
77
|
-
/**
|
|
78
|
-
* Checks if a value is contained within an interval.
|
|
79
|
-
*
|
|
80
|
-
* @param interval - The interval to check.
|
|
81
|
-
* @param value - The value to check.
|
|
82
|
-
* @param options - Options for the check.
|
|
83
|
-
* @returns `true` if the value is contained within the interval, `false` otherwise.
|
|
84
|
-
* @since 1.0.0
|
|
85
|
-
*/
|
|
86
|
-
(interval: Interval, value: number, options?: {
|
|
87
|
-
includeStart?: boolean;
|
|
88
|
-
includeEnd?: boolean;
|
|
89
|
-
}): boolean;
|
|
90
|
-
/**
|
|
91
|
-
* Checks if a value is contained within an interval.
|
|
92
|
-
*
|
|
93
|
-
* @param value - The value to check.
|
|
94
|
-
* @param options - Options for the check.
|
|
95
|
-
* @returns A function that takes an interval and returns `true` if the value is contained within the interval, `false` otherwise.
|
|
96
|
-
* @since 1.0.0
|
|
97
|
-
*/
|
|
98
|
-
(value: number, options?: {
|
|
99
|
-
includeStart?: boolean;
|
|
100
|
-
includeEnd?: boolean;
|
|
101
|
-
}): (interval: Interval) => boolean;
|
|
102
|
-
};
|
|
103
|
-
declare const filter: {
|
|
104
|
-
/**
|
|
105
|
-
* Filters a value to be within an interval.
|
|
106
|
-
*
|
|
107
|
-
* @param interval - The interval to filter the value to.
|
|
108
|
-
* @param value - The value to filter.
|
|
109
|
-
* @param options - Options for the filter.
|
|
110
|
-
* @returns The filtered value.
|
|
111
|
-
* @since 1.0.0
|
|
112
|
-
*/
|
|
113
|
-
<V extends ReadonlyArray<number>>(interval: Interval, value: V, options?: {
|
|
114
|
-
includeStart?: boolean;
|
|
115
|
-
includeEnd?: boolean;
|
|
116
|
-
}): V;
|
|
117
|
-
/**
|
|
118
|
-
* Filters a value to be within an interval.
|
|
119
|
-
*
|
|
120
|
-
* @param value - The value to filter.
|
|
121
|
-
* @param options - Options for the filter.
|
|
122
|
-
* @returns A function that takes an interval and returns the filtered value.
|
|
123
|
-
* @since 1.0.0
|
|
124
|
-
*/
|
|
125
|
-
<V extends ReadonlyArray<number>>(value: V, options?: {
|
|
126
|
-
includeStart?: boolean;
|
|
127
|
-
includeEnd?: boolean;
|
|
128
|
-
}): (interval: Interval) => V;
|
|
129
|
-
};
|
|
130
|
-
declare const clamp: {
|
|
131
|
-
/**
|
|
132
|
-
* Clamps a value to be within an interval.
|
|
133
|
-
*
|
|
134
|
-
* @param interval - The interval to clamp the value to.
|
|
135
|
-
* @param value - The value to clamp.
|
|
136
|
-
* @returns The clamped value.
|
|
137
|
-
* @since 1.0.0
|
|
138
|
-
*/
|
|
139
|
-
(interval: Interval, value: number): number;
|
|
140
|
-
/**
|
|
141
|
-
* Clamps a value to be within an interval.
|
|
142
|
-
*
|
|
143
|
-
* @param value - The value to clamp.
|
|
144
|
-
* @returns A function that takes an interval and returns the clamped value.
|
|
145
|
-
* @since 1.0.0
|
|
146
|
-
*/
|
|
147
|
-
(value: number): (interval: Interval) => number;
|
|
148
|
-
/**
|
|
149
|
-
* Clamps an array of values to be within an interval.
|
|
150
|
-
*
|
|
151
|
-
* @param interval - The interval to clamp the values to.
|
|
152
|
-
* @param value - The values to clamp.
|
|
153
|
-
* @returns The clamped values.
|
|
154
|
-
* @since 1.0.0
|
|
155
|
-
*/
|
|
156
|
-
(interval: Interval, value: ReadonlyArray<number>): ReadonlyArray<number>;
|
|
157
|
-
/**
|
|
158
|
-
* Clamps an array of values to be within an interval.
|
|
159
|
-
*
|
|
160
|
-
* @param value - The values to clamp.
|
|
161
|
-
* @returns A function that takes an interval and returns the clamped values.
|
|
162
|
-
* @since 1.0.0
|
|
163
|
-
*/
|
|
164
|
-
(value: ReadonlyArray<number>): (interval: Interval) => ReadonlyArray<number>;
|
|
165
|
-
};
|
|
166
|
-
/**
|
|
167
|
-
* The unit interval, which is the interval [0, 1].
|
|
168
|
-
*
|
|
169
|
-
* @since 1.0.0
|
|
170
|
-
*/
|
|
171
|
-
declare const unit: Interval;
|
|
172
|
-
/**
|
|
173
|
-
* The biunit interval, which is the interval [-1, 1].
|
|
174
|
-
*
|
|
175
|
-
* @since 1.0.0
|
|
176
|
-
*/
|
|
177
|
-
declare const biunit: Interval;
|
|
178
|
-
/**
|
|
179
|
-
* Linearly interpolates a value within an interval.
|
|
180
|
-
*
|
|
181
|
-
* @param interval - The interval to interpolate within.
|
|
182
|
-
* @param t - The interpolation factor, typically between 0 and 1.
|
|
183
|
-
* @returns The interpolated value.
|
|
184
|
-
* @since 1.0.0
|
|
185
|
-
*/
|
|
186
|
-
declare const lerp: (interval: Interval, t: number) => number;
|
|
187
|
-
/**
|
|
188
|
-
* Creates a linear interpolation function for an interval.
|
|
189
|
-
*
|
|
190
|
-
* @param interval - The interval to create the interpolation function for.
|
|
191
|
-
* @returns A function that takes a factor `t` and returns the interpolated value.
|
|
192
|
-
* @since 1.0.0
|
|
193
|
-
*/
|
|
194
|
-
declare const toLerpFn: (interval: Interval) => (t: number) => number;
|
|
195
|
-
/**
|
|
196
|
-
* Normalizes a value within an interval.
|
|
197
|
-
*
|
|
198
|
-
* @param interval - The interval to normalize within.
|
|
199
|
-
* @param x - The value to normalize.
|
|
200
|
-
* @returns The normalized value.
|
|
201
|
-
* @since 1.0.0
|
|
202
|
-
*/
|
|
203
|
-
declare const normalize: (interval: Interval, x: number) => number;
|
|
204
|
-
/**
|
|
205
|
-
* Creates a normalization function for an interval.
|
|
206
|
-
*
|
|
207
|
-
* @param interval - The interval to create the normalization function for.
|
|
208
|
-
* @returns A function that takes a value `x` and returns the normalized value.
|
|
209
|
-
* @since 1.0.0
|
|
210
|
-
*/
|
|
211
|
-
declare const toNormalizeFn: (interval: Interval) => (x: number) => number;
|
|
212
|
-
/**
|
|
213
|
-
* Remaps a value from one interval to another.
|
|
214
|
-
*
|
|
215
|
-
* @param source - The source interval.
|
|
216
|
-
* @param target - The target interval.
|
|
217
|
-
* @param x - The value to remap.
|
|
218
|
-
* @returns The remapped value.
|
|
219
|
-
* @since 1.0.0
|
|
220
|
-
*/
|
|
221
|
-
declare const remap: (source: Interval, target: Interval, x: number) => number;
|
|
222
|
-
/**
|
|
223
|
-
* Creates a remapping function for an interval.
|
|
224
|
-
*
|
|
225
|
-
* @param source - The source interval.
|
|
226
|
-
* @param target - The target interval.
|
|
227
|
-
* @returns A function that takes a value `x` and returns the remapped value.
|
|
228
|
-
* @since 1.0.0
|
|
229
|
-
*/
|
|
230
|
-
declare const toRemapFn: (source: Interval, target: Interval) => (x: number) => number;
|
|
231
|
-
/**
|
|
232
|
-
* Calculates the scale and shift needed to map a source interval to a target interval.
|
|
233
|
-
*
|
|
234
|
-
* @param source - The source interval.
|
|
235
|
-
* @param target - The target interval.
|
|
236
|
-
* @returns An object containing the scale and shift values.
|
|
237
|
-
* @since 1.0.0
|
|
238
|
-
*/
|
|
239
|
-
declare const scaleShift: (source: Interval, target: Interval) => ScaleShift;
|
|
240
|
-
/**
|
|
241
|
-
* The scale and shift needed to map a source interval to a target interval.
|
|
242
|
-
*
|
|
243
|
-
* @since 1.0.0
|
|
244
|
-
*/
|
|
245
|
-
interface ScaleShift {
|
|
246
|
-
readonly scale: number;
|
|
247
|
-
readonly shift: number;
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
export { biunit, clamp, contains, filter, fromMinMax, fromSize, isInterval, lerp, make, normalize, remap, scaleShift, size, toLerpFn, toNormalizeFn, toRemapFn, unit };
|
|
251
|
-
export type { Interval, ScaleShift };
|
package/dist/interval.d.ts
DELETED
|
@@ -1,251 +0,0 @@
|
|
|
1
|
-
import { Pipeable } from './pipe.js';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* A mathematical interval.
|
|
5
|
-
*
|
|
6
|
-
* All fields are readonly and immutable, and all operations create new instances.
|
|
7
|
-
*
|
|
8
|
-
* @since 1.0.0
|
|
9
|
-
*/
|
|
10
|
-
interface Interval extends Pipeable {
|
|
11
|
-
readonly start: number;
|
|
12
|
-
readonly end: number;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Checks if a value is an `Interval`.
|
|
16
|
-
*
|
|
17
|
-
* @param v - The value to check.
|
|
18
|
-
* @returns `true` if the value is an `Interval`, `false` otherwise.
|
|
19
|
-
* @since 1.0.0
|
|
20
|
-
*/
|
|
21
|
-
declare const isInterval: (v: unknown) => v is Interval;
|
|
22
|
-
declare const make: {
|
|
23
|
-
/**
|
|
24
|
-
* Creates a new `Interval` instance.
|
|
25
|
-
*
|
|
26
|
-
* @param point - The point of the interval.
|
|
27
|
-
* @returns A new `Interval` instance.
|
|
28
|
-
* @since 1.0.0
|
|
29
|
-
*/
|
|
30
|
-
(point: number): Interval;
|
|
31
|
-
/**
|
|
32
|
-
* Creates a new `Interval` instance.
|
|
33
|
-
*
|
|
34
|
-
* @param start - The start of the interval.
|
|
35
|
-
* @param end - The end of the interval.
|
|
36
|
-
* @returns A new `Interval` instance.
|
|
37
|
-
* @since 1.0.0
|
|
38
|
-
*/
|
|
39
|
-
(start: number, end: number): Interval;
|
|
40
|
-
};
|
|
41
|
-
declare const fromSize: {
|
|
42
|
-
/**
|
|
43
|
-
* Creates a new `Interval` instance from a size.
|
|
44
|
-
*
|
|
45
|
-
* @param size - The size of the interval.
|
|
46
|
-
* @returns A new `Interval` instance.
|
|
47
|
-
* @since 1.0.0
|
|
48
|
-
*/
|
|
49
|
-
(size: number): Interval;
|
|
50
|
-
/**
|
|
51
|
-
* Creates a new `Interval` instance from a size.
|
|
52
|
-
*
|
|
53
|
-
* @param size - The size of the interval.
|
|
54
|
-
* @param start - The start of the interval.
|
|
55
|
-
* @returns A new `Interval` instance.
|
|
56
|
-
* @since 1.0.0
|
|
57
|
-
*/
|
|
58
|
-
(start: number, size: number): Interval;
|
|
59
|
-
};
|
|
60
|
-
/**
|
|
61
|
-
* Creates a new `Interval` instance from a minimum and maximum value.
|
|
62
|
-
*
|
|
63
|
-
* @param values - The minimum and maximum values of the interval.
|
|
64
|
-
* @returns A new `Interval` instance.
|
|
65
|
-
* @since 1.0.0
|
|
66
|
-
*/
|
|
67
|
-
declare const fromMinMax: (...values: ReadonlyArray<number>) => Interval;
|
|
68
|
-
/**
|
|
69
|
-
* Calculates the size of an interval.
|
|
70
|
-
*
|
|
71
|
-
* @param interval - The interval to calculate the size of.
|
|
72
|
-
* @returns The size of the interval.
|
|
73
|
-
* @since 1.0.0
|
|
74
|
-
*/
|
|
75
|
-
declare const size: (i: Interval) => number;
|
|
76
|
-
declare const contains: {
|
|
77
|
-
/**
|
|
78
|
-
* Checks if a value is contained within an interval.
|
|
79
|
-
*
|
|
80
|
-
* @param interval - The interval to check.
|
|
81
|
-
* @param value - The value to check.
|
|
82
|
-
* @param options - Options for the check.
|
|
83
|
-
* @returns `true` if the value is contained within the interval, `false` otherwise.
|
|
84
|
-
* @since 1.0.0
|
|
85
|
-
*/
|
|
86
|
-
(interval: Interval, value: number, options?: {
|
|
87
|
-
includeStart?: boolean;
|
|
88
|
-
includeEnd?: boolean;
|
|
89
|
-
}): boolean;
|
|
90
|
-
/**
|
|
91
|
-
* Checks if a value is contained within an interval.
|
|
92
|
-
*
|
|
93
|
-
* @param value - The value to check.
|
|
94
|
-
* @param options - Options for the check.
|
|
95
|
-
* @returns A function that takes an interval and returns `true` if the value is contained within the interval, `false` otherwise.
|
|
96
|
-
* @since 1.0.0
|
|
97
|
-
*/
|
|
98
|
-
(value: number, options?: {
|
|
99
|
-
includeStart?: boolean;
|
|
100
|
-
includeEnd?: boolean;
|
|
101
|
-
}): (interval: Interval) => boolean;
|
|
102
|
-
};
|
|
103
|
-
declare const filter: {
|
|
104
|
-
/**
|
|
105
|
-
* Filters a value to be within an interval.
|
|
106
|
-
*
|
|
107
|
-
* @param interval - The interval to filter the value to.
|
|
108
|
-
* @param value - The value to filter.
|
|
109
|
-
* @param options - Options for the filter.
|
|
110
|
-
* @returns The filtered value.
|
|
111
|
-
* @since 1.0.0
|
|
112
|
-
*/
|
|
113
|
-
<V extends ReadonlyArray<number>>(interval: Interval, value: V, options?: {
|
|
114
|
-
includeStart?: boolean;
|
|
115
|
-
includeEnd?: boolean;
|
|
116
|
-
}): V;
|
|
117
|
-
/**
|
|
118
|
-
* Filters a value to be within an interval.
|
|
119
|
-
*
|
|
120
|
-
* @param value - The value to filter.
|
|
121
|
-
* @param options - Options for the filter.
|
|
122
|
-
* @returns A function that takes an interval and returns the filtered value.
|
|
123
|
-
* @since 1.0.0
|
|
124
|
-
*/
|
|
125
|
-
<V extends ReadonlyArray<number>>(value: V, options?: {
|
|
126
|
-
includeStart?: boolean;
|
|
127
|
-
includeEnd?: boolean;
|
|
128
|
-
}): (interval: Interval) => V;
|
|
129
|
-
};
|
|
130
|
-
declare const clamp: {
|
|
131
|
-
/**
|
|
132
|
-
* Clamps a value to be within an interval.
|
|
133
|
-
*
|
|
134
|
-
* @param interval - The interval to clamp the value to.
|
|
135
|
-
* @param value - The value to clamp.
|
|
136
|
-
* @returns The clamped value.
|
|
137
|
-
* @since 1.0.0
|
|
138
|
-
*/
|
|
139
|
-
(interval: Interval, value: number): number;
|
|
140
|
-
/**
|
|
141
|
-
* Clamps a value to be within an interval.
|
|
142
|
-
*
|
|
143
|
-
* @param value - The value to clamp.
|
|
144
|
-
* @returns A function that takes an interval and returns the clamped value.
|
|
145
|
-
* @since 1.0.0
|
|
146
|
-
*/
|
|
147
|
-
(value: number): (interval: Interval) => number;
|
|
148
|
-
/**
|
|
149
|
-
* Clamps an array of values to be within an interval.
|
|
150
|
-
*
|
|
151
|
-
* @param interval - The interval to clamp the values to.
|
|
152
|
-
* @param value - The values to clamp.
|
|
153
|
-
* @returns The clamped values.
|
|
154
|
-
* @since 1.0.0
|
|
155
|
-
*/
|
|
156
|
-
(interval: Interval, value: ReadonlyArray<number>): ReadonlyArray<number>;
|
|
157
|
-
/**
|
|
158
|
-
* Clamps an array of values to be within an interval.
|
|
159
|
-
*
|
|
160
|
-
* @param value - The values to clamp.
|
|
161
|
-
* @returns A function that takes an interval and returns the clamped values.
|
|
162
|
-
* @since 1.0.0
|
|
163
|
-
*/
|
|
164
|
-
(value: ReadonlyArray<number>): (interval: Interval) => ReadonlyArray<number>;
|
|
165
|
-
};
|
|
166
|
-
/**
|
|
167
|
-
* The unit interval, which is the interval [0, 1].
|
|
168
|
-
*
|
|
169
|
-
* @since 1.0.0
|
|
170
|
-
*/
|
|
171
|
-
declare const unit: Interval;
|
|
172
|
-
/**
|
|
173
|
-
* The biunit interval, which is the interval [-1, 1].
|
|
174
|
-
*
|
|
175
|
-
* @since 1.0.0
|
|
176
|
-
*/
|
|
177
|
-
declare const biunit: Interval;
|
|
178
|
-
/**
|
|
179
|
-
* Linearly interpolates a value within an interval.
|
|
180
|
-
*
|
|
181
|
-
* @param interval - The interval to interpolate within.
|
|
182
|
-
* @param t - The interpolation factor, typically between 0 and 1.
|
|
183
|
-
* @returns The interpolated value.
|
|
184
|
-
* @since 1.0.0
|
|
185
|
-
*/
|
|
186
|
-
declare const lerp: (interval: Interval, t: number) => number;
|
|
187
|
-
/**
|
|
188
|
-
* Creates a linear interpolation function for an interval.
|
|
189
|
-
*
|
|
190
|
-
* @param interval - The interval to create the interpolation function for.
|
|
191
|
-
* @returns A function that takes a factor `t` and returns the interpolated value.
|
|
192
|
-
* @since 1.0.0
|
|
193
|
-
*/
|
|
194
|
-
declare const toLerpFn: (interval: Interval) => (t: number) => number;
|
|
195
|
-
/**
|
|
196
|
-
* Normalizes a value within an interval.
|
|
197
|
-
*
|
|
198
|
-
* @param interval - The interval to normalize within.
|
|
199
|
-
* @param x - The value to normalize.
|
|
200
|
-
* @returns The normalized value.
|
|
201
|
-
* @since 1.0.0
|
|
202
|
-
*/
|
|
203
|
-
declare const normalize: (interval: Interval, x: number) => number;
|
|
204
|
-
/**
|
|
205
|
-
* Creates a normalization function for an interval.
|
|
206
|
-
*
|
|
207
|
-
* @param interval - The interval to create the normalization function for.
|
|
208
|
-
* @returns A function that takes a value `x` and returns the normalized value.
|
|
209
|
-
* @since 1.0.0
|
|
210
|
-
*/
|
|
211
|
-
declare const toNormalizeFn: (interval: Interval) => (x: number) => number;
|
|
212
|
-
/**
|
|
213
|
-
* Remaps a value from one interval to another.
|
|
214
|
-
*
|
|
215
|
-
* @param source - The source interval.
|
|
216
|
-
* @param target - The target interval.
|
|
217
|
-
* @param x - The value to remap.
|
|
218
|
-
* @returns The remapped value.
|
|
219
|
-
* @since 1.0.0
|
|
220
|
-
*/
|
|
221
|
-
declare const remap: (source: Interval, target: Interval, x: number) => number;
|
|
222
|
-
/**
|
|
223
|
-
* Creates a remapping function for an interval.
|
|
224
|
-
*
|
|
225
|
-
* @param source - The source interval.
|
|
226
|
-
* @param target - The target interval.
|
|
227
|
-
* @returns A function that takes a value `x` and returns the remapped value.
|
|
228
|
-
* @since 1.0.0
|
|
229
|
-
*/
|
|
230
|
-
declare const toRemapFn: (source: Interval, target: Interval) => (x: number) => number;
|
|
231
|
-
/**
|
|
232
|
-
* Calculates the scale and shift needed to map a source interval to a target interval.
|
|
233
|
-
*
|
|
234
|
-
* @param source - The source interval.
|
|
235
|
-
* @param target - The target interval.
|
|
236
|
-
* @returns An object containing the scale and shift values.
|
|
237
|
-
* @since 1.0.0
|
|
238
|
-
*/
|
|
239
|
-
declare const scaleShift: (source: Interval, target: Interval) => ScaleShift;
|
|
240
|
-
/**
|
|
241
|
-
* The scale and shift needed to map a source interval to a target interval.
|
|
242
|
-
*
|
|
243
|
-
* @since 1.0.0
|
|
244
|
-
*/
|
|
245
|
-
interface ScaleShift {
|
|
246
|
-
readonly scale: number;
|
|
247
|
-
readonly shift: number;
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
export { biunit, clamp, contains, filter, fromMinMax, fromSize, isInterval, lerp, make, normalize, remap, scaleShift, size, toLerpFn, toNormalizeFn, toRemapFn, unit };
|
|
251
|
-
export type { Interval, ScaleShift };
|
package/dist/interval.mjs
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import { dual, Pipeable } from './pipe.mjs';
|
|
2
|
-
import { round } from './utils.mjs';
|
|
3
|
-
|
|
4
|
-
var _a;
|
|
5
|
-
const TypeId = Symbol.for("curvy/interval");
|
|
6
|
-
class IntervalImpl extends Pipeable {
|
|
7
|
-
constructor(start = 0, end = start) {
|
|
8
|
-
super();
|
|
9
|
-
this[_a] = TypeId;
|
|
10
|
-
if (end < start) {
|
|
11
|
-
throw new Error("Interval end must be greater than or equal to start");
|
|
12
|
-
}
|
|
13
|
-
this.start = round(start);
|
|
14
|
-
this.end = round(end);
|
|
15
|
-
}
|
|
16
|
-
get [(_a = TypeId, Symbol.toStringTag)]() {
|
|
17
|
-
return `Interval [${this.start}, ${this.end}]`;
|
|
18
|
-
}
|
|
19
|
-
get [Symbol.for("nodejs.util.inspect.custom")]() {
|
|
20
|
-
return this[Symbol.toStringTag];
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
const isInterval$1 = (v) => typeof v === "object" && v !== null && TypeId in v;
|
|
24
|
-
const make$1 = (start, end) => new IntervalImpl(start, end ?? start);
|
|
25
|
-
const fromSize$1 = (a, b) => {
|
|
26
|
-
if (b === void 0) {
|
|
27
|
-
return new IntervalImpl(0, a);
|
|
28
|
-
}
|
|
29
|
-
return new IntervalImpl(a, a + b);
|
|
30
|
-
};
|
|
31
|
-
const fromMinMax$1 = (...values) => new IntervalImpl(Math.min(...values), Math.max(...values));
|
|
32
|
-
const size$1 = (i) => Math.abs(i.end - i.start);
|
|
33
|
-
const contains$1 = dual(
|
|
34
|
-
(args) => isInterval$1(args[0]),
|
|
35
|
-
(interval, value, { includeStart = true, includeEnd = true } = {}) => value > interval.start && value < interval.end || includeStart && value === interval.start || includeEnd && value === interval.end
|
|
36
|
-
);
|
|
37
|
-
const filter$1 = dual(
|
|
38
|
-
(args) => isInterval$1(args[0]),
|
|
39
|
-
(interval, value, options) => {
|
|
40
|
-
return value.filter((v) => contains$1(interval, v, options));
|
|
41
|
-
}
|
|
42
|
-
);
|
|
43
|
-
const clamp$1 = dual(2, (interval, value) => {
|
|
44
|
-
if (Array.isArray(value)) {
|
|
45
|
-
return value.map((v) => clamp$1(interval, v));
|
|
46
|
-
}
|
|
47
|
-
return contains$1(interval, value) ? value : value < interval.start ? interval.start : interval.end;
|
|
48
|
-
});
|
|
49
|
-
const unit$1 = make$1(0, 1);
|
|
50
|
-
const biunit$1 = make$1(-1, 1);
|
|
51
|
-
const lerp$1 = (interval, t) => (1 - t) * interval.start + t * interval.end;
|
|
52
|
-
const toLerpFn$1 = (interval) => (t) => lerp$1(interval, t);
|
|
53
|
-
const normalize$1 = (interval, x) => (x - interval.start) / size$1(interval);
|
|
54
|
-
const toNormalizeFn$1 = (interval) => (x) => normalize$1(interval, x);
|
|
55
|
-
const remap$1 = (source, target, x) => {
|
|
56
|
-
return target.start + (x - source.start) * size$1(target) / size$1(source);
|
|
57
|
-
};
|
|
58
|
-
const toRemapFn$1 = (source, target) => (x) => remap$1(source, target, x);
|
|
59
|
-
const scaleShift$1 = (source, target) => {
|
|
60
|
-
const scale = size$1(target) / size$1(source);
|
|
61
|
-
return {
|
|
62
|
-
scale,
|
|
63
|
-
shift: target.start - source.start * scale
|
|
64
|
-
};
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
const isInterval = isInterval$1;
|
|
68
|
-
const make = make$1;
|
|
69
|
-
const fromSize = fromSize$1;
|
|
70
|
-
const fromMinMax = fromMinMax$1;
|
|
71
|
-
const size = size$1;
|
|
72
|
-
const contains = contains$1;
|
|
73
|
-
const filter = filter$1;
|
|
74
|
-
const clamp = clamp$1;
|
|
75
|
-
const unit = unit$1;
|
|
76
|
-
const biunit = biunit$1;
|
|
77
|
-
const lerp = lerp$1;
|
|
78
|
-
const toLerpFn = toLerpFn$1;
|
|
79
|
-
const normalize = normalize$1;
|
|
80
|
-
const toNormalizeFn = toNormalizeFn$1;
|
|
81
|
-
const remap = remap$1;
|
|
82
|
-
const toRemapFn = toRemapFn$1;
|
|
83
|
-
const scaleShift = scaleShift$1;
|
|
84
|
-
|
|
85
|
-
export { biunit, clamp, contains, filter, fromMinMax, fromSize, isInterval, lerp, make, normalize, remap, scaleShift, size, toLerpFn, toNormalizeFn, toRemapFn, unit };
|
|
86
|
-
//# sourceMappingURL=interval.mjs.map
|
package/dist/interval.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"interval.mjs","sources":["../src/interval.internal.ts","../src/interval.ts"],"sourcesContent":["import type { Interval } from './interval'\nimport { Pipeable } from './pipe'\nimport { dual } from './pipe'\nimport { round } from './utils'\n\nconst TypeId: unique symbol = Symbol.for('curvy/interval')\ntype TypeId = typeof TypeId\n\nclass IntervalImpl extends Pipeable implements Interval {\n readonly [TypeId]: TypeId = TypeId\n\n readonly start: number\n readonly end: number\n\n constructor(start = 0, end = start) {\n super()\n\n if (end < start) {\n throw new Error('Interval end must be greater than or equal to start')\n }\n\n this.start = round(start)\n this.end = round(end)\n }\n\n get [Symbol.toStringTag]() {\n return `Interval [${this.start}, ${this.end}]`\n }\n\n get [Symbol.for('nodejs.util.inspect.custom')]() {\n return this[Symbol.toStringTag]\n }\n}\n\nexport const isInterval = (v: unknown): v is Interval =>\n typeof v === 'object' && v !== null && TypeId in v\n\nexport const make = (start: number, end?: number) => new IntervalImpl(start, end ?? start)\n\nexport const fromSize = (a: number, b?: number) => {\n if (b === undefined) {\n return new IntervalImpl(0, a)\n }\n return new IntervalImpl(a, a + b)\n}\n\nexport const fromMinMax = (...values: ReadonlyArray<number>) =>\n new IntervalImpl(Math.min(...values), Math.max(...values))\n\nexport const size = (i: Interval) => Math.abs(i.end - i.start)\n\nexport const contains = dual<\n (\n value: number,\n options?: { includeStart?: boolean; includeEnd?: boolean },\n ) => (interval: Interval) => boolean,\n (\n interval: Interval,\n value: number,\n options?: { includeStart?: boolean; includeEnd?: boolean },\n ) => boolean\n>(\n (args) => isInterval(args[0]),\n (interval: Interval, value: number, { includeStart = true, includeEnd = true } = {}) =>\n (value > interval.start && value < interval.end) ||\n (includeStart && value === interval.start) ||\n (includeEnd && value === interval.end),\n)\n\nexport const filter = dual<\n <V extends ReadonlyArray<number>>(\n value: V,\n options?: { includeStart?: boolean; includeEnd?: boolean },\n ) => (interval: Interval) => V,\n <V extends ReadonlyArray<number>>(\n interval: Interval,\n value: V,\n options?: { includeStart?: boolean; includeEnd?: boolean },\n ) => V\n>(\n (args) => isInterval(args[0]),\n <V extends ReadonlyArray<number>>(\n interval: Interval,\n value: V,\n options?: { includeStart?: boolean; includeEnd?: boolean },\n ): V => {\n return value.filter((v) => contains(interval, v, options)) as unknown as V\n },\n)\n\nexport const clamp = dual<\n <V extends number | ReadonlyArray<number>>(value: V) => (interval: Interval) => V,\n <V extends number | ReadonlyArray<number>>(interval: Interval, value: V) => V\n>(2, <V extends number | ReadonlyArray<number>>(interval: Interval, value: V): V => {\n if (Array.isArray(value)) {\n return value.map((v) => clamp(interval, v)) as unknown as V\n }\n\n return (\n contains(interval, value as number)\n ? (value as number)\n : (value as number) < interval.start\n ? interval.start\n : interval.end\n ) as V\n})\n\nexport const unit = make(0, 1)\n\nexport const biunit = make(-1, 1)\n\nexport const lerp = (interval: Interval, t: number) => (1 - t) * interval.start + t * interval.end\n\nexport const toLerpFn = (interval: Interval) => (t: number) => lerp(interval, t)\n\nexport const normalize = (interval: Interval, x: number) => (x - interval.start) / size(interval)\n\nexport const toNormalizeFn = (interval: Interval) => (x: number) => normalize(interval, x)\n\nexport const remap = (source: Interval, target: Interval, x: number) => {\n return target.start + ((x - source.start) * size(target)) / size(source)\n}\n\nexport const toRemapFn = (source: Interval, target: Interval) => (x: number) =>\n remap(source, target, x)\n\nexport const scaleShift = (source: Interval, target: Interval) => {\n const scale = size(target) / size(source)\n\n return {\n scale,\n shift: target.start - source.start * scale,\n }\n}\n","import * as internal from './interval.internal'\nimport type { Pipeable } from './pipe'\n\n/**\n * A mathematical interval.\n *\n * All fields are readonly and immutable, and all operations create new instances.\n *\n * @since 1.0.0\n */\nexport interface Interval extends Pipeable {\n readonly start: number\n readonly end: number\n}\n\n/**\n * Checks if a value is an `Interval`.\n *\n * @param v - The value to check.\n * @returns `true` if the value is an `Interval`, `false` otherwise.\n * @since 1.0.0\n */\nexport const isInterval: (v: unknown) => v is Interval = internal.isInterval\n\nexport const make: {\n /**\n * Creates a new `Interval` instance.\n *\n * @param point - The point of the interval.\n * @returns A new `Interval` instance.\n * @since 1.0.0\n */\n (point: number): Interval\n /**\n * Creates a new `Interval` instance.\n *\n * @param start - The start of the interval.\n * @param end - The end of the interval.\n * @returns A new `Interval` instance.\n * @since 1.0.0\n */\n (start: number, end: number): Interval\n} = internal.make\n\nexport const fromSize: {\n /**\n * Creates a new `Interval` instance from a size.\n *\n * @param size - The size of the interval.\n * @returns A new `Interval` instance.\n * @since 1.0.0\n */\n (size: number): Interval\n /**\n * Creates a new `Interval` instance from a size.\n *\n * @param size - The size of the interval.\n * @param start - The start of the interval.\n * @returns A new `Interval` instance.\n * @since 1.0.0\n */\n (start: number, size: number): Interval\n} = internal.fromSize\n\n/**\n * Creates a new `Interval` instance from a minimum and maximum value.\n *\n * @param values - The minimum and maximum values of the interval.\n * @returns A new `Interval` instance.\n * @since 1.0.0\n */\nexport const fromMinMax: (...values: ReadonlyArray<number>) => Interval = internal.fromMinMax\n\n/**\n * Calculates the size of an interval.\n *\n * @param interval - The interval to calculate the size of.\n * @returns The size of the interval.\n * @since 1.0.0\n */\nexport const size: (i: Interval) => number = internal.size\n\nexport const contains: {\n /**\n * Checks if a value is contained within an interval.\n *\n * @param interval - The interval to check.\n * @param value - The value to check.\n * @param options - Options for the check.\n * @returns `true` if the value is contained within the interval, `false` otherwise.\n * @since 1.0.0\n */\n (\n interval: Interval,\n value: number,\n options?: { includeStart?: boolean; includeEnd?: boolean },\n ): boolean\n /**\n * Checks if a value is contained within an interval.\n *\n * @param value - The value to check.\n * @param options - Options for the check.\n * @returns A function that takes an interval and returns `true` if the value is contained within the interval, `false` otherwise.\n * @since 1.0.0\n */\n (\n value: number,\n options?: { includeStart?: boolean; includeEnd?: boolean },\n ): (interval: Interval) => boolean\n} = internal.contains\n\nexport const filter: {\n /**\n * Filters a value to be within an interval.\n *\n * @param interval - The interval to filter the value to.\n * @param value - The value to filter.\n * @param options - Options for the filter.\n * @returns The filtered value.\n * @since 1.0.0\n */\n <V extends ReadonlyArray<number>>(\n interval: Interval,\n value: V,\n options?: { includeStart?: boolean; includeEnd?: boolean },\n ): V\n /**\n * Filters a value to be within an interval.\n *\n * @param value - The value to filter.\n * @param options - Options for the filter.\n * @returns A function that takes an interval and returns the filtered value.\n * @since 1.0.0\n */\n <V extends ReadonlyArray<number>>(\n value: V,\n options?: { includeStart?: boolean; includeEnd?: boolean },\n ): (interval: Interval) => V\n} = internal.filter\n\nexport const clamp: {\n /**\n * Clamps a value to be within an interval.\n *\n * @param interval - The interval to clamp the value to.\n * @param value - The value to clamp.\n * @returns The clamped value.\n * @since 1.0.0\n */\n (interval: Interval, value: number): number\n /**\n * Clamps a value to be within an interval.\n *\n * @param value - The value to clamp.\n * @returns A function that takes an interval and returns the clamped value.\n * @since 1.0.0\n */\n (value: number): (interval: Interval) => number\n /**\n * Clamps an array of values to be within an interval.\n *\n * @param interval - The interval to clamp the values to.\n * @param value - The values to clamp.\n * @returns The clamped values.\n * @since 1.0.0\n */\n (interval: Interval, value: ReadonlyArray<number>): ReadonlyArray<number>\n /**\n * Clamps an array of values to be within an interval.\n *\n * @param value - The values to clamp.\n * @returns A function that takes an interval and returns the clamped values.\n * @since 1.0.0\n */\n (value: ReadonlyArray<number>): (interval: Interval) => ReadonlyArray<number>\n} = internal.clamp\n\n/**\n * The unit interval, which is the interval [0, 1].\n *\n * @since 1.0.0\n */\nexport const unit: Interval = internal.unit\n\n/**\n * The biunit interval, which is the interval [-1, 1].\n *\n * @since 1.0.0\n */\nexport const biunit: Interval = internal.biunit\n\n/**\n * Linearly interpolates a value within an interval.\n *\n * @param interval - The interval to interpolate within.\n * @param t - The interpolation factor, typically between 0 and 1.\n * @returns The interpolated value.\n * @since 1.0.0\n */\nexport const lerp: (interval: Interval, t: number) => number = internal.lerp\n\n/**\n * Creates a linear interpolation function for an interval.\n *\n * @param interval - The interval to create the interpolation function for.\n * @returns A function that takes a factor `t` and returns the interpolated value.\n * @since 1.0.0\n */\nexport const toLerpFn: (interval: Interval) => (t: number) => number = internal.toLerpFn\n\n/**\n * Normalizes a value within an interval.\n *\n * @param interval - The interval to normalize within.\n * @param x - The value to normalize.\n * @returns The normalized value.\n * @since 1.0.0\n */\nexport const normalize: (interval: Interval, x: number) => number = internal.normalize\n\n/**\n * Creates a normalization function for an interval.\n *\n * @param interval - The interval to create the normalization function for.\n * @returns A function that takes a value `x` and returns the normalized value.\n * @since 1.0.0\n */\nexport const toNormalizeFn: (interval: Interval) => (x: number) => number = internal.toNormalizeFn\n\n/**\n * Remaps a value from one interval to another.\n *\n * @param source - The source interval.\n * @param target - The target interval.\n * @param x - The value to remap.\n * @returns The remapped value.\n * @since 1.0.0\n */\nexport const remap: (source: Interval, target: Interval, x: number) => number = internal.remap\n\n/**\n * Creates a remapping function for an interval.\n *\n * @param source - The source interval.\n * @param target - The target interval.\n * @returns A function that takes a value `x` and returns the remapped value.\n * @since 1.0.0\n */\nexport const toRemapFn: (source: Interval, target: Interval) => (x: number) => number =\n internal.toRemapFn\n\n/**\n * Calculates the scale and shift needed to map a source interval to a target interval.\n *\n * @param source - The source interval.\n * @param target - The target interval.\n * @returns An object containing the scale and shift values.\n * @since 1.0.0\n */\nexport const scaleShift: (source: Interval, target: Interval) => ScaleShift = internal.scaleShift\n\n/**\n * The scale and shift needed to map a source interval to a target interval.\n *\n * @since 1.0.0\n */\nexport interface ScaleShift {\n readonly scale: number\n readonly shift: number\n}\n"],"names":["isInterval","make","fromSize","fromMinMax","size","contains","filter","clamp","unit","biunit","lerp","toLerpFn","normalize","toNormalizeFn","remap","toRemapFn","scaleShift","internal.isInterval","internal.make","internal.fromSize","internal.fromMinMax","internal.size","internal.contains","internal.filter","internal.clamp","internal.unit","internal.biunit","internal.l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