phaser/v3/src/math/Clamp.js

16 lines
400 B
JavaScript
Raw Normal View History

/**
* Force a value within the boundaries by clamping it to the range `min`, `max`.
*
* @method Phaser.Math#clamp
* @param {float} v - The value to be clamped.
* @param {float} min - The minimum bounds.
* @param {float} max - The maximum bounds.
* @return {number} The clamped value.
*/
var Clamp = function (v, min, max)
{
2017-09-20 15:51:15 +00:00
return Math.max(min, Math.min(max, value));
};
module.exports = Clamp;