Restricts a value to lie within a specified range.
Ensures that value is no less than min and no greater than max.
value
min
max
The input value to be clamped.
Optional
The lower bound of the range (default is 0).
The upper bound of the range (default is 1).
clamp(1.5, 0.1, 0.9); // 0.9clamp(0.001, 0.1, 0.9); // 0.1clamp(0.5, 0, 1); // 0.5 Copy
clamp(1.5, 0.1, 0.9); // 0.9clamp(0.001, 0.1, 0.9); // 0.1clamp(0.5, 0, 1); // 0.5
Restricts a value to lie within a specified range.
Ensures that
value
is no less thanmin
and no greater thanmax
.