clamp() function

Restricts an input value to a specified range.

Syntax

clamp(minimum,input,maximum)

Arguments

minimum → The smallest value input is allowed to take.
input → a value which will be restricted to the range specified by minimum and maximum.
maximum → The largest value input is allowed to take.

Example

clamp(1,5,10) → 5 (input is between 1 and 10 so is returned unchanged)
clamp(1,0,10) → 1 (input is less than minimum value of 1, so function returns 1)
clamp(1,11,10) → 10 (input is greater than maximum value of 10, so function returns 10)