2018-02-12 16:01:20 +00:00
|
|
|
/**
|
|
|
|
* @author Richard Davey <rich@photonstorm.com>
|
2020-01-15 12:07:09 +00:00
|
|
|
* @copyright 2020 Photon Storm Ltd.
|
2019-05-10 15:15:04 +00:00
|
|
|
* @license {@link https://opensource.org/licenses/MIT|MIT License}
|
2018-02-12 16:01:20 +00:00
|
|
|
*/
|
|
|
|
|
2016-12-06 16:18:12 +00:00
|
|
|
/**
|
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)
|
2016-12-06 16:18:12 +00:00
|
|
|
{
|
2017-09-20 15:51:15 +00:00
|
|
|
return Math.max(min, Math.min(max, value));
|
2016-12-06 16:18:12 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = Clamp;
|