clamp
This method takes a numerical value and ensures it fits in a given numerical range. If the number is smaller than the minimum required by the range, then the minimum of the range will be returned. If the number is higher than the maximum allowed by the range then the maximum of the range will be returned.
Return
the clamped value.
Parameters
value
the value to be clamped.
min
minimum resulting value.
max
maximum resulting value.