@tempots/std
clampSym() function
Like clamp but you only pass one argument (max
) that is used as the upper limit and the opposite (additive inverse or -max
) as the lower limit.
Signature:
clampSym: (v: number, max: number) => number
Parameters
Parameter |
Type |
Description |
---|---|---|
v |
number |
The value to clamp. |
max |
number |
The maximum value. |
Returns: number
The clamped value.
Example
clampSym(5, 10) // returns 5
clampSym(15, 10) // returns 10
clampSym(-5, 10) // returns -5
clampSym(-15, 10) // returns -10