Difference between revisions of "Clamping"
(Add clamping page.) |
m (Added missing property for the category page.) |
||
Line 16: | Line 16: | ||
{{#set:Author=Rmcode}} | {{#set:Author=Rmcode}} | ||
{{#set:Description=This function clamps a value to a certain range.}} | {{#set:Description=This function clamps a value to a certain range.}} | ||
+ | {{#set:LOVE Version=any}} |
Latest revision as of 17:21, 11 November 2016
Clamps a value to a certain range. Use this function to make sure the value doesn't get bigger than the given maximum value and smaller than the minimum value.
---
-- Clamps a value to a certain range.
-- @param min - The minimum value.
-- @param val - The value to clamp.
-- @param max - The maximum value.
--
function clamp(min, val, max)
return math.max(min, math.min(val, max));
end