Macro that will return a value limited to a given range
CLAMP( value, minimum, maximum )
Returns the value if it is within the range minimum to maximum.
If the value is smaller than minimum, returns minimum.
If the value is larger than maximum, returns maximum.
Works with both float and integer parameters.
value | input value |
minimum | smallest allowed value |
maximum | largest allowed value |
Returns the value limited to within the given range.
new n, x; n = 60; x = CLAMP(n, 30, 90); // 60 x = CLAMP(n, 10, 20); // 20