dastal - v5.0.0 / NumberUtils
▸ clamp(num
, min
, max
): number
Limits a number to be within a given range.
f(x, min, max) = y, where min <= y <= max
Name | Type | Description |
---|---|---|
num |
number |
The number to clamp |
min |
number |
The minimum result value, inclusive |
max |
number |
The maximum result value, inclusive |
number
The clamped number
▸ wrap(num
, min
, max
): number
Wraps a number if outside a given range
Name | Type | Description |
---|---|---|
num |
number |
The number to wrap |
min |
number |
The minimum result value, inclusive |
max |
number |
The maximum result value, inclusive |
number
- The wrapped number
▸ wrapLeft(num
, min
, max
): number
Wraps a number if below a given range
f(x, min, max) = { x, where x >= min max - (min - x), where x < min }
Name | Type | Description |
---|---|---|
num |
number |
The number to wrap |
min |
number |
The minimum result value, inclusive |
max |
number |
The maximum result value, inclusive |
number
- The wrapped number
▸ wrapRight(num
, min
, max
): number
Wraps a number if above a given range
f(x, min, max) = { x, where x <= max min + (x - max), where x > max }
Name | Type | Description |
---|---|---|
num |
number |
The number to wrap |
min |
number |
The minimum result value, inclusive |
max |
number |
The maximum result value, inclusive |
number
- The wrapped number