phaser/src/math/Clamp.js

19 lines
443 B
JavaScript
Raw Normal View History

/**
2017-10-06 02:05:01 +00:00
* Force a value within the boundaries by clamping it to the range `min`, `max`.
*
* @function Phaser.Math.Clamp
* @since 3.0.0
*
* @param {number} value - The value to be clamped.
* @param {number} min - The minimum bounds.
* @param {number} max - The maximum bounds.
*
* @return {number} The clamped value.
*/
2017-09-21 13:26:18 +00:00
var Clamp = function (value, min, max)
{
2017-09-20 15:51:15 +00:00
return Math.max(min, Math.min(max, value));
};
module.exports = Clamp;