@tempots/color
clamp() function
clamp
restricts a value within the specified range.
Signature:
clamp: (value: number, min: number, max: number) => number
Parameters
Parameter |
Type |
Description |
---|---|---|
value |
number |
The value to clamp. |
min |
number |
The minimum value. |
max |
number |
The maximum value. |
Returns: number
The clamped value.
Example
log(clamp(1.3, 0, 1)) // prints 1
log(clamp(0.8, 0, 1)) // prints 0.8
log(clamp(-0.5, 0, 1)) // prints 0.0