@bitbybit-dev/base 1.2.0 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/lib/api/GlobalCDNProvider.js +1 -1
  2. package/lib/api/inputs/base-inputs.d.ts +13 -12
  3. package/lib/api/inputs/color-inputs.d.ts +97 -48
  4. package/lib/api/inputs/color-inputs.js +95 -46
  5. package/lib/api/inputs/dates-inputs.d.ts +67 -26
  6. package/lib/api/inputs/dates-inputs.js +57 -16
  7. package/lib/api/inputs/io-inputs.d.ts +13 -15
  8. package/lib/api/inputs/io-inputs.js +7 -8
  9. package/lib/api/inputs/line-inputs.d.ts +88 -33
  10. package/lib/api/inputs/line-inputs.js +61 -11
  11. package/lib/api/inputs/lists-inputs.d.ts +207 -96
  12. package/lib/api/inputs/lists-inputs.js +153 -45
  13. package/lib/api/inputs/logic-inputs.d.ts +52 -22
  14. package/lib/api/inputs/logic-inputs.js +41 -12
  15. package/lib/api/inputs/math-inputs.d.ts +113 -52
  16. package/lib/api/inputs/math-inputs.js +112 -51
  17. package/lib/api/inputs/mesh-inputs.d.ts +30 -11
  18. package/lib/api/inputs/mesh-inputs.js +21 -3
  19. package/lib/api/inputs/point-inputs.d.ts +240 -107
  20. package/lib/api/inputs/point-inputs.js +199 -73
  21. package/lib/api/inputs/polyline-inputs.d.ts +68 -28
  22. package/lib/api/inputs/polyline-inputs.js +48 -13
  23. package/lib/api/inputs/text-inputs.d.ts +117 -46
  24. package/lib/api/inputs/text-inputs.js +111 -41
  25. package/lib/api/inputs/transforms-inputs.d.ts +65 -23
  26. package/lib/api/inputs/transforms-inputs.js +64 -22
  27. package/lib/api/inputs/vector-inputs.d.ts +154 -76
  28. package/lib/api/inputs/vector-inputs.js +132 -57
  29. package/lib/api/models/point/hex-grid-data.d.ts +1 -1
  30. package/lib/api/models/point/hex-grid-data.js +1 -1
  31. package/lib/api/services/color.d.ts +149 -70
  32. package/lib/api/services/color.js +149 -70
  33. package/lib/api/services/dates.d.ts +313 -150
  34. package/lib/api/services/dates.js +313 -150
  35. package/lib/api/services/line.d.ts +138 -68
  36. package/lib/api/services/line.js +138 -68
  37. package/lib/api/services/lists.d.ts +357 -177
  38. package/lib/api/services/lists.js +357 -177
  39. package/lib/api/services/logic.d.ts +98 -45
  40. package/lib/api/services/logic.js +98 -45
  41. package/lib/api/services/math.d.ts +363 -211
  42. package/lib/api/services/math.js +363 -211
  43. package/lib/api/services/mesh.d.ts +73 -31
  44. package/lib/api/services/mesh.js +73 -31
  45. package/lib/api/services/point.d.ts +367 -147
  46. package/lib/api/services/point.js +367 -147
  47. package/lib/api/services/polyline.d.ts +146 -71
  48. package/lib/api/services/polyline.js +146 -71
  49. package/lib/api/services/text.d.ts +320 -165
  50. package/lib/api/services/text.js +320 -165
  51. package/lib/api/services/transforms.d.ts +145 -58
  52. package/lib/api/services/transforms.js +145 -58
  53. package/lib/api/services/vector.d.ts +381 -156
  54. package/lib/api/services/vector.js +381 -156
  55. package/package.json +1 -1
@@ -1,331 +1,436 @@
1
1
  import * as Inputs from "../inputs";
2
2
  /**
3
- * Contains various math methods.
3
+ * Arithmetic, rounding, ranges, random numbers and the trigonometric functions on plain numbers.
4
+ * The trigonometric functions take and give angles in radians; `degToRad` and `radToDeg` convert at
5
+ * the boundary, because almost every angle a user types is in degrees. The interpolation helpers
6
+ * (`lerp`, `remap`, `ease`, `smoothstep`, `pingPong`) are the building blocks of animation and
7
+ * parametric variation.
4
8
  */
5
9
  export declare class MathBitByBit {
6
10
  /**
7
- * Creates and returns a number value (pass-through for number input).
8
- * Example: Input 42 → 42, Input 3.14 → 3.14
9
- * @param inputs a number to be created
10
- * @returns number
11
+ * Passes a number through unchanged, so a value can be given a name and reused.
12
+ *
13
+ * Example: 42 -> 42
14
+ * @param inputs - The number
15
+ * @returns The same number
11
16
  * @group create
12
17
  * @shortname number
13
18
  * @drawable false
14
19
  */
15
20
  number(inputs: Inputs.Math.NumberDto): number;
16
21
  /**
17
- * Performs basic arithmetic operations on two numbers (add, subtract, multiply, divide, power, modulus).
18
- * Example: 5 + 3 → 8, 10 % 3 → 1, 2 ^ 3 → 8
19
- * @param inputs two numbers and operator
20
- * @returns Result of math operation action
22
+ * Applies one arithmetic operation to two numbers: add, subtract, multiply, divide, power or
23
+ * modulus.
24
+ *
25
+ * The operation reads `first` then `second`: subtract gives first minus second, power gives
26
+ * first to the power of second.
27
+ * Example: 5 add 3 -> 8, 10 modulus 3 -> 1, 2 power 3 -> 8
28
+ * @param inputs - The two numbers and the operation
29
+ * @returns The result of the operation
21
30
  * @group operations
22
31
  * @shortname two numbers
23
32
  * @drawable false
33
+ * @example
34
+ * ```typescript
35
+ * const result = bitbybit.math.twoNrOperation({ first: 2, second: 3, operation: Bit.Inputs.Math.mathTwoNrOperatorEnum.power });
36
+ * ```
24
37
  */
25
38
  twoNrOperation(inputs: Inputs.Math.ActionOnTwoNumbersDto): number;
26
39
  /**
27
- * Calculates the remainder after division (modulus operation).
28
- * Example: 10 % 3 → 1, 17 % 5 → 2
29
- * @param inputs two numbers and operator
30
- * @returns Result of modulus operation
40
+ * Finds the remainder after dividing one number by another.
41
+ *
42
+ * The sign follows the first number, as it does in JavaScript.
43
+ * Example: 10 modulus 3 -> 1, 17 modulus 5 -> 2
44
+ * @param inputs - The number to divide and the number to divide by
45
+ * @returns The remainder
31
46
  * @group operations
32
47
  * @shortname modulus
33
48
  * @drawable false
49
+ * @example
50
+ * ```typescript
51
+ * const remainder = bitbybit.math.modulus({ number: 17, modulus: 5 });
52
+ * ```
34
53
  */
35
54
  modulus(inputs: Inputs.Math.ModulusDto): number;
36
55
  /**
37
- * Rounds a number to specified decimal places.
38
- * Example: 1.32156 with 3 decimals returns 1.322
39
- * @param inputs a number and decimal places
40
- * @returns Result of rounding
56
+ * Rounds a number to a given number of decimal places.
57
+ *
58
+ * Example: 1.32156 to 3 places -> 1.322
59
+ * @param inputs - The number and how many decimal places to keep
60
+ * @returns The rounded number
41
61
  * @group operations
42
62
  * @shortname round to decimals
43
63
  * @drawable false
64
+ * @example
65
+ * ```typescript
66
+ * const rounded = bitbybit.math.roundToDecimals({ number: 1.32156, decimalPlaces: 3 });
67
+ * ```
44
68
  */
45
69
  roundToDecimals(inputs: Inputs.Math.RoundToDecimalsDto): number;
46
70
  /**
47
- * Rounds a number to specified decimal places and removes trailing zeros.
48
- * Example: 1.32156 with 3 decimals returns 1.322, but 1.320000001 returns 1.32, and 1.000 returns 1
49
- * @param inputs a number and decimal places
50
- * @returns Result of rounding as a number without trailing zeros
71
+ * Rounds a number to a given number of decimal places and drops the zeros at the end.
72
+ *
73
+ * As a number the result cannot carry trailing zeros anyway; the difference from
74
+ * `roundToDecimals` is that floating-point noise such as 1.320000001 is cleaned to 1.32.
75
+ * Example: 1.32156 to 3 places -> 1.322, 1.320000001 -> 1.32, 1.000 -> 1
76
+ * @param inputs - The number and how many decimal places to keep
77
+ * @returns The rounded number
51
78
  * @group operations
52
79
  * @shortname round trim zeros
53
80
  * @drawable false
81
+ * @example
82
+ * ```typescript
83
+ * const clean = bitbybit.math.roundAndRemoveTrailingZeros({ number: 1.320000001, decimalPlaces: 3 });
84
+ * ```
54
85
  */
55
86
  roundAndRemoveTrailingZeros(inputs: Inputs.Math.RoundToDecimalsDto): number;
56
87
  /**
57
- * Performs mathematical operations on a single number (absolute, negate, sqrt, trig functions, logarithms, etc.).
58
- * Example: sqrt(5) → 2.236, abs(-3) → 3, sin(π/2) → 1
59
- * @param inputs one number and operator action
60
- * @returns Result of math operation
88
+ * Applies one operation to a single number: absolute, negate, square root, rounding,
89
+ * logarithms, the trigonometric functions and their inverses, exponential, or a conversion
90
+ * between radians and degrees.
91
+ *
92
+ * The trigonometric functions work in radians.
93
+ * Example: sqrt of 5 -> 2.236, absolute of -3 -> 3
94
+ * @param inputs - The number and the operation
95
+ * @returns The result of the operation
61
96
  * @group operations
62
97
  * @shortname one number
63
98
  * @drawable false
99
+ * @example
100
+ * ```typescript
101
+ * const root = bitbybit.math.oneNrOperation({ number: 5, operation: Bit.Inputs.Math.mathOneNrOperatorEnum.sqrt });
102
+ * ```
64
103
  */
65
104
  oneNrOperation(inputs: Inputs.Math.ActionOnOneNumberDto): number;
66
105
  /**
67
- * Maps a number from one range to another range proportionally.
68
- * Example: 5 from [0,10] to [0,100] → 50, 0.5 from [0,1] to [-10,10] → 0
69
- * @param inputs one number and operator action
70
- * @returns Result of mapping
71
- * @group operations
72
- * @shortname remap
73
- * @drawable false
74
- */
106
+ * Maps a number from one range onto another, keeping its relative position.
107
+ *
108
+ * A number outside the source range maps proportionally beyond the target range.
109
+ * Example: 5 from [0,10] to [0,100] -> 50, 0.5 from [0,1] to [-10,10] -> 0
110
+ * @param inputs - The number, the range it is in and the range to map it to
111
+ * @returns The number at the same relative position in the target range
112
+ * @group operations
113
+ * @shortname remap
114
+ * @drawable false
115
+ * @example
116
+ * ```typescript
117
+ * const percent = bitbybit.math.remap({ number: 5, fromLow: 0, fromHigh: 10, toLow: 0, toHigh: 100 });
118
+ * ```
119
+ */
75
120
  remap(inputs: Inputs.Math.RemapNumberDto): number;
76
121
  /**
77
- * Generates a random decimal number between 0 (inclusive) and 1 (exclusive).
78
- * Example: Outputs like 0.342, 0.891, or any value in [0, 1)
79
- * @returns A random number between 0 and 1
80
- * @group generate
81
- * @shortname random 0 - 1
82
- * @drawable false
83
- */
122
+ * Gives a random number from 0 up to, but not including, 1.
123
+ *
124
+ * Example: 0.342, 0.891 or any other value in that range
125
+ * @returns A random number between 0 and 1
126
+ * @group generate
127
+ * @shortname random 0 - 1
128
+ * @drawable false
129
+ */
84
130
  random(): number;
85
131
  /**
86
- * Generates a random number within a specified range (low to high).
87
- * Example: Range [0, 10] → outputs like 3.7, 8.2, or any value between 0 and 10
88
- * @param inputs low and high numbers
89
- * @returns A random number
90
- * @group generate
91
- * @shortname random number
92
- * @drawable false
93
- */
132
+ * Gives a random number between `low` and `high`.
133
+ *
134
+ * Example: low 0, high 10 -> 3.7, 8.2 or any other value between them
135
+ * @param inputs - The low and high ends of the range
136
+ * @returns A random number in the range
137
+ * @group generate
138
+ * @shortname random number
139
+ * @drawable false
140
+ * @example
141
+ * ```typescript
142
+ * const value = bitbybit.math.randomNumber({ low: 0, high: 10 });
143
+ * ```
144
+ */
94
145
  randomNumber(inputs: Inputs.Math.RandomNumberDto): number;
95
146
  /**
96
- * Generates multiple random numbers within a specified range.
97
- * Example: Range [0, 10] with 3 items → [2.5, 7.1, 4.8]
98
- * @param inputs low and high numbers
99
- * @returns A list of random numbers
100
- * @group generate
101
- * @shortname random numbers
102
- * @drawable false
103
- */
147
+ * Gives a list of random numbers between `low` and `high`.
148
+ *
149
+ * Example: low 0, high 10, count 3 -> [2.5, 7.1, 4.8]
150
+ * @param inputs - The low and high ends of the range and how many numbers to make
151
+ * @returns The random numbers
152
+ * @group generate
153
+ * @shortname random numbers
154
+ * @drawable false
155
+ * @example
156
+ * ```typescript
157
+ * const values = bitbybit.math.randomNumbers({ low: 0, high: 10, count: 3 });
158
+ * ```
159
+ */
104
160
  randomNumbers(inputs: Inputs.Math.RandomNumbersDto): number[];
105
161
  /**
106
- * Returns the mathematical constant π (pi) ≈ 3.14159.
107
- * Example: Outputs 3.141592653589793
108
- * @returns A number PI
109
- * @group generate
110
- * @shortname π
111
- * @drawable false
112
- */
162
+ * Gives the constant pi, the ratio of a circle's circumference to its diameter.
163
+ *
164
+ * Example: 3.141592653589793
165
+ * @returns The number pi
166
+ * @group generate
167
+ * @shortname π
168
+ * @drawable false
169
+ */
113
170
  pi(): number;
114
171
  /**
115
- * Formats a number as a string with a fixed number of decimal places (always shows trailing zeros).
116
- * Example: 3.14159 with 2 decimals → '3.14', 5 with 3 decimals → '5.000'
117
- * @param inputs a number to be rounded to decimal places
118
- * @returns number
172
+ * Formats a number as text with a fixed number of decimal places, keeping trailing zeros.
173
+ *
174
+ * Example: 3.14159 with 2 places -> '3.14', 5 with 3 places -> '5.000'
175
+ * @param inputs - The number and how many decimal places to show
176
+ * @returns The formatted text
119
177
  * @group operations
120
178
  * @shortname to fixed
121
179
  * @drawable false
180
+ * @example
181
+ * ```typescript
182
+ * const label = bitbybit.math.toFixed({ number: 3.14159, decimalPlaces: 2 });
183
+ * ```
122
184
  */
123
185
  toFixed(inputs: Inputs.Math.ToFixedDto): string;
124
186
  /**
125
- * Adds two numbers together.
126
- * Example: 5 + 3 → 8, -2 + 7 → 5
127
- * @param inputs two numbers
128
- * @returns number
187
+ * Adds two numbers.
188
+ *
189
+ * Example: 5 and 3 -> 8, -2 and 7 -> 5
190
+ * @param inputs - The two numbers
191
+ * @returns Their sum
129
192
  * @group basics
130
193
  * @shortname add
131
194
  * @drawable false
195
+ * @example
196
+ * ```typescript
197
+ * const sum = bitbybit.math.add({ first: 5, second: 3 });
198
+ * ```
132
199
  */
133
200
  add(inputs: Inputs.Math.TwoNumbersDto): number;
134
201
  /**
135
202
  * Subtracts the second number from the first.
136
- * Example: 10 - 3 → 7, 5 - 8 → -3
137
- * @param inputs two numbers
138
- * @returns number
203
+ *
204
+ * Example: 10 and 3 -> 7, 5 and 8 -> -3
205
+ * @param inputs - The number to subtract from and the number to subtract
206
+ * @returns Their difference
139
207
  * @group basics
140
208
  * @shortname subtract
141
209
  * @drawable false
210
+ * @example
211
+ * ```typescript
212
+ * const difference = bitbybit.math.subtract({ first: 10, second: 3 });
213
+ * ```
142
214
  */
143
215
  subtract(inputs: Inputs.Math.TwoNumbersDto): number;
144
216
  /**
145
- * Multiplies two numbers together.
146
- * Example: 5 × 3 → 15, -2 × 4 → -8
147
- * @param inputs two numbers
148
- * @returns number
217
+ * Multiplies two numbers.
218
+ *
219
+ * Example: 5 and 3 -> 15, -2 and 4 -> -8
220
+ * @param inputs - The two numbers
221
+ * @returns Their product
149
222
  * @group basics
150
223
  * @shortname multiply
151
224
  * @drawable false
225
+ * @example
226
+ * ```typescript
227
+ * const product = bitbybit.math.multiply({ first: 5, second: 3 });
228
+ * ```
152
229
  */
153
230
  multiply(inputs: Inputs.Math.TwoNumbersDto): number;
154
231
  /**
155
232
  * Divides the first number by the second.
156
- * Example: 10 ÷ 2 → 5, 7 ÷ 2 → 3.5
157
- * @param inputs two numbers
158
- * @returns number
233
+ *
234
+ * Dividing by 0 gives Infinity, as in JavaScript.
235
+ * Example: 10 and 2 -> 5, 7 and 2 -> 3.5
236
+ * @param inputs - The number to divide and the number to divide by
237
+ * @returns Their quotient
159
238
  * @group basics
160
239
  * @shortname divide
161
240
  * @drawable false
241
+ * @example
242
+ * ```typescript
243
+ * const quotient = bitbybit.math.divide({ first: 7, second: 2 });
244
+ * ```
162
245
  */
163
246
  divide(inputs: Inputs.Math.TwoNumbersDto): number;
164
247
  /**
165
- * Raises the first number to the power of the second (exponentiation).
166
- * Example: 2³ → 8, 5² → 25, 10⁻¹ → 0.1
167
- * @param inputs two numbers
168
- * @returns number
248
+ * Raises the first number to the power of the second.
249
+ *
250
+ * Example: 2 to the 3 -> 8, 5 to the 2 -> 25, 10 to the -1 -> 0.1
251
+ * @param inputs - The base and the exponent
252
+ * @returns The power
169
253
  * @group basics
170
254
  * @shortname power
171
255
  * @drawable false
256
+ * @example
257
+ * ```typescript
258
+ * const cube = bitbybit.math.power({ first: 2, second: 3 });
259
+ * ```
172
260
  */
173
261
  power(inputs: Inputs.Math.TwoNumbersDto): number;
174
262
  /**
175
- * Calculates the square root of a number.
176
- * Example: √9 → 3, √2 → 1.414, √16 → 4
177
- * @param inputs a number
178
- * @returns number
263
+ * Finds the square root of a number.
264
+ *
265
+ * A negative number gives NaN.
266
+ * Example: 9 -> 3, 2 -> 1.414
267
+ * @param inputs - The number
268
+ * @returns The square root
179
269
  * @group basics
180
270
  * @shortname sqrt
181
271
  * @drawable false
182
272
  */
183
273
  sqrt(inputs: Inputs.Math.NumberDto): number;
184
274
  /**
185
- * Returns the absolute value (removes negative sign, always positive or zero).
186
- * Example: |-5| → 5, |3| → 3, |0| → 0
187
- * @param inputs a number
188
- * @returns number
275
+ * Drops the sign of a number, so the result is never negative.
276
+ *
277
+ * Example: -5 -> 5, 3 -> 3, 0 -> 0
278
+ * @param inputs - The number
279
+ * @returns The absolute value
189
280
  * @group basics
190
281
  * @shortname abs
191
282
  * @drawable false
192
283
  */
193
284
  abs(inputs: Inputs.Math.NumberDto): number;
194
285
  /**
195
- * Rounds a number to the nearest integer.
196
- * Example: 3.7 → 4, 2.3 → 2, 5.5 → 6
197
- * @param inputs a number
198
- * @returns number
286
+ * Rounds a number to the nearest whole number; halves round up.
287
+ *
288
+ * Example: 3.7 -> 4, 2.3 -> 2, 5.5 -> 6
289
+ * @param inputs - The number
290
+ * @returns The nearest whole number
199
291
  * @group basics
200
292
  * @shortname round
201
293
  * @drawable false
202
294
  */
203
295
  round(inputs: Inputs.Math.NumberDto): number;
204
296
  /**
205
- * Rounds a number down to the nearest integer (toward negative infinity).
206
- * Example: 3.7 → 3, -2.3 → -3, 5 → 5
207
- * @param inputs a number
208
- * @returns number
297
+ * Rounds a number down to the whole number below it.
298
+ *
299
+ * Example: 3.7 -> 3, -2.3 -> -3, 5 -> 5
300
+ * @param inputs - The number
301
+ * @returns The whole number below
209
302
  * @group basics
210
303
  * @shortname floor
211
304
  * @drawable false
212
305
  */
213
306
  floor(inputs: Inputs.Math.NumberDto): number;
214
307
  /**
215
- * Rounds a number up to the nearest integer (toward positive infinity).
216
- * Example: 3.2 → 4, -2.8 → -2, 5 → 5
217
- * @param inputs a number
218
- * @returns number
308
+ * Rounds a number up to the whole number above it.
309
+ *
310
+ * Example: 3.2 -> 4, -2.8 -> -2, 5 -> 5
311
+ * @param inputs - The number
312
+ * @returns The whole number above
219
313
  * @group basics
220
314
  * @shortname ceil
221
315
  * @drawable false
222
316
  */
223
317
  ceil(inputs: Inputs.Math.NumberDto): number;
224
318
  /**
225
- * Negates a number (flips its sign: positive becomes negative, negative becomes positive).
226
- * Example: 5 → -5, -3 → 3, 0 → 0
227
- * @param inputs a number
228
- * @returns number
319
+ * Flips the sign of a number.
320
+ *
321
+ * Example: 5 -> -5, -3 -> 3, 0 -> 0
322
+ * @param inputs - The number
323
+ * @returns The number with the opposite sign
229
324
  * @group basics
230
325
  * @shortname negate
231
326
  * @drawable false
232
327
  */
233
328
  negate(inputs: Inputs.Math.NumberDto): number;
234
329
  /**
235
- * Calculates the natural logarithm (base e) of a number.
236
- * Example: ln(2.718) → ~1, ln(7.389) → ~2, ln(1) → 0
237
- * @param inputs a number
238
- * @returns number
330
+ * Finds the natural logarithm of a number: the power e must be raised to for that number.
331
+ *
332
+ * Example: 2.718 -> about 1, 1 -> 0
333
+ * @param inputs - The number, greater than 0
334
+ * @returns The natural logarithm
239
335
  * @group basics
240
336
  * @shortname ln
241
337
  * @drawable false
242
338
  */
243
339
  ln(inputs: Inputs.Math.NumberDto): number;
244
340
  /**
245
- * Calculates the base 10 logarithm of a number.
246
- * Example: log₁₀(100) → 2, log₁₀(1000) → 3, log₁₀(10) → 1
247
- * @param inputs a number
248
- * @returns number
341
+ * Finds the base-10 logarithm of a number: the power 10 must be raised to for that number.
342
+ *
343
+ * Example: 100 -> 2, 1000 -> 3, 10 -> 1
344
+ * @param inputs - The number, greater than 0
345
+ * @returns The base-10 logarithm
249
346
  * @group basics
250
347
  * @shortname log10
251
348
  * @drawable false
252
349
  */
253
350
  log10(inputs: Inputs.Math.NumberDto): number;
254
351
  /**
255
- * Raises 10 to the power of the input number.
256
- * Example: 10² → 100, 10³ → 1000, 10⁻¹ → 0.1
257
- * @param inputs a number
258
- * @returns number
352
+ * Raises 10 to the power of a number.
353
+ *
354
+ * Example: 2 -> 100, 3 -> 1000, -1 -> 0.1
355
+ * @param inputs - The exponent
356
+ * @returns 10 to that power
259
357
  * @group basics
260
358
  * @shortname ten pow
261
359
  * @drawable false
262
360
  */
263
361
  tenPow(inputs: Inputs.Math.NumberDto): number;
264
362
  /**
265
- * Calculates the sine of an angle in radians.
266
- * Example: sin(0) → 0, sin(π/2) → 1, sin(π) → ~0
267
- * @param inputs a number
268
- * @returns number
363
+ * Finds the sine of an angle given in radians.
364
+ *
365
+ * Example: 0 -> 0, pi/2 -> 1
366
+ * @param inputs - The angle in radians
367
+ * @returns The sine, between -1 and 1
269
368
  * @group basics
270
369
  * @shortname sin
271
370
  * @drawable false
272
371
  */
273
372
  sin(inputs: Inputs.Math.NumberDto): number;
274
373
  /**
275
- * Calculates the cosine of an angle in radians.
276
- * Example: cos(0) → 1, cos(π/2) → ~0, cos(π) → -1
277
- * @param inputs a number
278
- * @returns number
374
+ * Finds the cosine of an angle given in radians.
375
+ *
376
+ * Example: 0 -> 1, pi -> -1
377
+ * @param inputs - The angle in radians
378
+ * @returns The cosine, between -1 and 1
279
379
  * @group basics
280
380
  * @shortname cos
281
381
  * @drawable false
282
382
  */
283
383
  cos(inputs: Inputs.Math.NumberDto): number;
284
384
  /**
285
- * Calculates the tangent of an angle in radians.
286
- * Example: tan(0) → 0, tan(π/4) → ~1, tan(π/2) → infinity
287
- * @param inputs a number
288
- * @returns number
385
+ * Finds the tangent of an angle given in radians.
386
+ *
387
+ * Example: 0 -> 0, pi/4 -> about 1
388
+ * @param inputs - The angle in radians
389
+ * @returns The tangent
289
390
  * @group basics
290
391
  * @shortname tan
291
392
  * @drawable false
292
393
  */
293
394
  tan(inputs: Inputs.Math.NumberDto): number;
294
395
  /**
295
- * Calculates the arcsine (inverse sine) in radians, returns angle whose sine is the input.
296
- * Example: asin(0) → 0, asin(1) → π/2 (~1.57), asin(0.5) → π/6 (~0.524)
297
- * @param inputs a number
298
- * @returns number
396
+ * Finds the angle, in radians, whose sine is the given number.
397
+ *
398
+ * Example: 0 -> 0, 1 -> pi/2 (about 1.57)
399
+ * @param inputs - A number between -1 and 1
400
+ * @returns The angle in radians
299
401
  * @group basics
300
402
  * @shortname asin
301
403
  * @drawable false
302
404
  */
303
405
  asin(inputs: Inputs.Math.NumberDto): number;
304
406
  /**
305
- * Calculates the arccosine (inverse cosine) in radians, returns angle whose cosine is the input.
306
- * Example: acos(1) → 0, acos(0) → π/2 (~1.57), acos(-1) → π (~3.14)
307
- * @param inputs a number
308
- * @returns number
407
+ * Finds the angle, in radians, whose cosine is the given number.
408
+ *
409
+ * Example: 1 -> 0, -1 -> pi (about 3.14)
410
+ * @param inputs - A number between -1 and 1
411
+ * @returns The angle in radians
309
412
  * @group basics
310
413
  * @shortname acos
311
414
  * @drawable false
312
415
  */
313
416
  acos(inputs: Inputs.Math.NumberDto): number;
314
417
  /**
315
- * Calculates the arctangent (inverse tangent) in radians, returns angle whose tangent is the input.
316
- * Example: atan(0) → 0, atan(1) → π/4 (~0.785), atan(-1) → -π/4
317
- * @param inputs a number
318
- * @returns number
418
+ * Finds the angle, in radians, whose tangent is the given number.
419
+ *
420
+ * Example: 0 -> 0, 1 -> pi/4 (about 0.785)
421
+ * @param inputs - The number
422
+ * @returns The angle in radians, between -pi/2 and pi/2
319
423
  * @group basics
320
424
  * @shortname atan
321
425
  * @drawable false
322
426
  */
323
427
  atan(inputs: Inputs.Math.NumberDto): number;
324
428
  /**
325
- * Calculates e raised to the power of the input (exponential function).
326
- * Example: e⁰ → 1, e¹ → ~2.718, e² → ~7.389
327
- * @param inputs a number
328
- * @returns number
429
+ * Raises e, the base of the natural logarithm, to the power of a number.
430
+ *
431
+ * Example: 0 -> 1, 1 -> about 2.718, 2 -> about 7.389
432
+ * @param inputs - The exponent
433
+ * @returns e to that power
329
434
  * @group basics
330
435
  * @shortname exp
331
436
  * @drawable false
@@ -333,9 +438,10 @@ export declare class MathBitByBit {
333
438
  exp(inputs: Inputs.Math.NumberDto): number;
334
439
  /**
335
440
  * Converts an angle from degrees to radians.
336
- * Example: 180° → π (~3.14159), 90° → π/2 (~1.5708), 360° → 2π
337
- * @param inputs a number in degrees
338
- * @returns number
441
+ *
442
+ * Example: 180 -> pi (about 3.14159), 90 -> pi/2
443
+ * @param inputs - The angle in degrees
444
+ * @returns The angle in radians
339
445
  * @group basics
340
446
  * @shortname deg to rad
341
447
  * @drawable false
@@ -343,134 +449,180 @@ export declare class MathBitByBit {
343
449
  degToRad(inputs: Inputs.Math.NumberDto): number;
344
450
  /**
345
451
  * Converts an angle from radians to degrees.
346
- * Example: π → 180°, π/2 → 90°, 2π → 360°
347
- * @param inputs a number in radians
348
- * @returns number
452
+ *
453
+ * Example: pi -> 180, pi/2 -> 90
454
+ * @param inputs - The angle in radians
455
+ * @returns The angle in degrees
349
456
  * @group basics
350
457
  * @shortname rad to deg
351
458
  * @drawable false
352
459
  */
353
460
  radToDeg(inputs: Inputs.Math.NumberDto): number;
354
461
  /**
355
- * Applies an easing function to interpolate smoothly between min and max values.
356
- * Example: x=0.5 from [0,100] with easeInQuad → applies quadratic acceleration curve
357
- * Useful for smooth animations with various acceleration/deceleration curves.
358
- * @param inputs a number, min and max values, and ease type
359
- * @returns number
462
+ * Maps a value from 0 to 1 onto the range `min` to `max` along an easing curve, so the result
463
+ * speeds up or slows down instead of changing evenly.
464
+ *
465
+ * An `easeIn` curve starts slowly, an `easeOut` curve ends slowly, an `easeInOut` curve does
466
+ * both.
467
+ * Example: 0.5 from [0,100] with easeInQuad -> 25
468
+ * @param inputs - The value between 0 and 1, the target range and the easing curve
469
+ * @returns The eased value in the target range
360
470
  * @group operations
361
471
  * @shortname ease
362
472
  * @drawable false
473
+ * @example
474
+ * ```typescript
475
+ * const eased = bitbybit.math.ease({ x: 0.5, min: 0, max: 100, ease: Bit.Inputs.Math.easeEnum.easeInQuad });
476
+ * ```
363
477
  */
364
478
  ease(inputs: Inputs.Math.EaseDto): number;
365
479
  /**
366
- * Constrains a value between a minimum and maximum value.
367
- * Example: clamp(5, 0, 3) returns 3, clamp(-1, 0, 3) returns 0, clamp(1.5, 0, 3) returns 1.5
368
- * @param inputs a number, min and max values
369
- * @returns number clamped between min and max
480
+ * Keeps a number within a range: below `min` becomes `min`, above `max` becomes `max`.
481
+ *
482
+ * Example: 5 in [0,3] -> 3, -1 in [0,3] -> 0, 1.5 in [0,3] -> 1.5
483
+ * @param inputs - The number and the range to keep it in
484
+ * @returns The number, limited to the range
370
485
  * @group operations
371
486
  * @shortname clamp
372
487
  * @drawable false
488
+ * @example
489
+ * ```typescript
490
+ * const limited = bitbybit.math.clamp({ number: 5, min: 0, max: 3 });
491
+ * ```
373
492
  */
374
493
  clamp(inputs: Inputs.Math.ClampDto): number;
375
494
  /**
376
- * Linear interpolation between two values using parameter t (0 to 1).
377
- * Example: From 0 to 100 at t=0.5 → 50, From 10 to 20 at t=0.25 → 12.5
378
- * When t=0 returns start, when t=1 returns end. Useful for smooth transitions.
379
- * @param inputs start value, end value, and interpolation parameter t
380
- * @returns interpolated value
495
+ * Blends from a start value to an end value by a fraction `t`: 0 gives the start, 1 the end,
496
+ * 0.5 the midpoint.
497
+ *
498
+ * A `t` outside 0 to 1 extrapolates past the ends.
499
+ * Example: 0 to 100 at 0.5 -> 50, 10 to 20 at 0.25 -> 12.5
500
+ * @param inputs - The start value, the end value and the fraction
501
+ * @returns The blended value
381
502
  * @group operations
382
503
  * @shortname lerp
383
504
  * @drawable false
505
+ * @example
506
+ * ```typescript
507
+ * const mid = bitbybit.math.lerp({ start: 10, end: 20, t: 0.25 });
508
+ * ```
384
509
  */
385
510
  lerp(inputs: Inputs.Math.LerpDto): number;
386
511
  /**
387
- * Calculates the interpolation parameter t for a value between start and end (reverse of lerp).
388
- * Example: Value 5 in range [0,10] → t=0.5, Value 2.5 in range [0,10] → t=0.25
389
- * Returns what t value would produce the given value in a lerp. Useful for finding relative position.
390
- * @param inputs start value, end value, and the value to find t for
391
- * @returns interpolation parameter (typically 0-1)
512
+ * Finds where a value sits between a start and an end, as a fraction: the `t` that `lerp` would
513
+ * need to produce it.
514
+ *
515
+ * Example: 5 in [0,10] -> 0.5, 2.5 in [0,10] -> 0.25
516
+ * @param inputs - The start value, the end value and the value to locate
517
+ * @returns The fraction from start to end
392
518
  * @group operations
393
519
  * @shortname inverse lerp
394
520
  * @drawable false
521
+ * @example
522
+ * ```typescript
523
+ * const fraction = bitbybit.math.inverseLerp({ start: 0, end: 10, value: 2.5 });
524
+ * ```
395
525
  */
396
526
  inverseLerp(inputs: Inputs.Math.InverseLerpDto): number;
397
527
  /**
398
- * Hermite interpolation with smooth acceleration and deceleration (smoother than linear lerp).
399
- * Example: x=0 → 0, x=0.5 → 0.5, x=1 → 1 (but with smooth S-curve in between)
400
- * Input is automatically clamped to [0,1]. Output eases in and out smoothly. Great for animations.
401
- * @param inputs a number between 0 and 1
402
- * @returns smoothly interpolated value
528
+ * Turns a value from 0 to 1 into a smooth S-curve that starts and ends gently; the value is
529
+ * clamped to that range first.
530
+ *
531
+ * Example: 0 -> 0, 0.5 -> 0.5, 0.25 -> 0.156
532
+ * @param inputs - The value between 0 and 1
533
+ * @returns The smoothed value between 0 and 1
403
534
  * @group operations
404
535
  * @shortname smoothstep
405
536
  * @drawable false
406
537
  */
407
538
  smoothstep(inputs: Inputs.Math.NumberDto): number;
408
539
  /**
409
- * Returns the sign of a number: -1 for negative, 0 for zero, 1 for positive.
410
- * Example: -5 → -1, 0 → 0, 3.14 → 1
411
- * Useful for determining direction or polarity.
412
- * @param inputs a number
413
- * @returns -1, 0, or 1
540
+ * Tells the sign of a number: -1 when negative, 0 when zero, 1 when positive.
541
+ *
542
+ * Example: -5 -> -1, 0 -> 0, 3.14 -> 1
543
+ * @param inputs - The number
544
+ * @returns -1, 0 or 1
414
545
  * @group operations
415
546
  * @shortname sign
416
547
  * @drawable false
417
548
  */
418
549
  sign(inputs: Inputs.Math.NumberDto): number;
419
550
  /**
420
- * Returns the fractional part of a number (removes integer part, keeps decimals).
421
- * Example: 3.14 → 0.14, 5.9 → 0.9, -2.3 → 0.7
422
- * Useful for wrapping values and creating repeating patterns.
423
- * @param inputs a number
424
- * @returns fractional part (always positive)
551
+ * Keeps the part of a number after the decimal point, measured up from the whole number below
552
+ * it, so the result is always from 0 up to 1.
553
+ *
554
+ * Example: 3.14 -> 0.14, -2.3 -> 0.7
555
+ * @param inputs - The number
556
+ * @returns The fractional part, from 0 up to 1
425
557
  * @group operations
426
558
  * @shortname fract
427
559
  * @drawable false
428
560
  */
429
561
  fract(inputs: Inputs.Math.NumberDto): number;
430
562
  /**
431
- * Wraps a number within a specified range (creates repeating cycle).
432
- * Example: 1.5 in range [0,1) → 0.5, -0.3 in range [0,1) → 0.7, 370° in range [0,360) → 10°
433
- * Useful for angles, UVs, or any repeating domain. Like modulo but handles negatives properly.
434
- * @param inputs a number, min and max values
435
- * @returns wrapped value within range
563
+ * Wraps a number into a range so it cycles round: past `max` it comes back in at `min`, and
564
+ * below `min` it comes back in at `max`.
565
+ *
566
+ * Useful for angles and repeating patterns; unlike a plain modulus it handles negative numbers.
567
+ * Example: 1.5 in [0,1) -> 0.5, -0.3 in [0,1) -> 0.7, 370 in [0,360) -> 10
568
+ * @param inputs - The number and the range to wrap it into
569
+ * @returns The wrapped number, from min up to max
436
570
  * @group operations
437
571
  * @shortname wrap
438
572
  * @drawable false
573
+ * @example
574
+ * ```typescript
575
+ * const angle = bitbybit.math.wrap({ number: 370, min: 0, max: 360 });
576
+ * ```
439
577
  */
440
578
  wrap(inputs: Inputs.Math.WrapDto): number;
441
579
  /**
442
- * Creates a ping-pong (back-and-forth) effect that bounces a value between 0 and length.
443
- * The value goes from 0→length, then back length→0, repeating this cycle.
444
- * Example: With length=1: t=0→0, t=0.5→0.5, t=1→1 (peak), t=1.5→0.5, t=2→0, t=2.5→0.5 (repeats)
445
- * Useful for creating bouncing animations like a ball or oscillating motion.
446
- * @param inputs time value t and length
447
- * @returns value bouncing between 0 and length
580
+ * Bounces a value back and forth between 0 and `length` as `t` grows: up to `length`, back down
581
+ * to 0, and again.
582
+ *
583
+ * Example: length 1 at t 0.5 -> 0.5, t 1 -> 1, t 1.5 -> 0.5, t 2 -> 0
584
+ * @param inputs - The running value and the length to bounce within
585
+ * @returns The bounced value between 0 and length
448
586
  * @group operations
449
587
  * @shortname ping pong
450
588
  * @drawable false
589
+ * @example
590
+ * ```typescript
591
+ * const bounce = bitbybit.math.pingPong({ t: 1.5, length: 1 });
592
+ * ```
451
593
  */
452
594
  pingPong(inputs: Inputs.Math.PingPongDto): number;
453
595
  /**
454
- * Moves a value toward a target by a maximum delta amount (never overshooting).
455
- * Example: From 0 toward 10 by max 3 → 3, From 8 toward 10 by max 3 → 10 (reached)
456
- * Useful for smooth movement with maximum speed limits.
457
- * @param inputs current value, target value, and maximum delta
458
- * @returns new value moved toward target
596
+ * Moves a value toward a target by at most `maxDelta`, without overshooting it.
597
+ *
598
+ * Example: 0 toward 10 by 3 -> 3, 8 toward 10 by 3 -> 10
599
+ * @param inputs - The current value, the target and the largest step allowed
600
+ * @returns The value after one step
459
601
  * @group operations
460
602
  * @shortname move towards
461
603
  * @drawable false
604
+ * @example
605
+ * ```typescript
606
+ * const next = bitbybit.math.moveTowards({ current: 8, target: 10, maxDelta: 3 });
607
+ * ```
462
608
  */
463
609
  moveTowards(inputs: Inputs.Math.MoveTowardsDto): number;
464
610
  /**
465
- * Safely evaluates a simple arithmetic expression containing only
466
- * numbers, +, -, *, /, parentheses, and whitespace.
467
- * Uses the shunting-yard algorithm — no eval/Function.
468
- * Example: '(3+2)*4' → 20, '10/3' → 3.3333...
469
- * @param inputs arithmetic expression string
470
- * @returns evaluated result
611
+ * Works out a simple arithmetic expression written as text: numbers, +, -, the multiplication
612
+ * sign, /, parentheses and spaces.
613
+ *
614
+ * The expression is parsed and computed by the library itself, never handed to the JavaScript
615
+ * engine to run, so it is safe with text a user typed.
616
+ * Example: '(3+2) times 4' written with the sign -> 20, '10/3' -> 3.3333
617
+ * @param inputs - The expression text
618
+ * @returns The computed value
471
619
  * @group operations
472
620
  * @shortname eval arithmetic
473
621
  * @drawable false
622
+ * @example
623
+ * ```typescript
624
+ * const value = bitbybit.math.evalArithmetic({ expression: "(3 + 2) * 4" });
625
+ * ```
474
626
  */
475
627
  evalArithmetic(inputs: Inputs.Math.EvalArithmeticDto): number;
476
628
  private easeInSine;