2018-02-12 16:01:20 +00:00
|
|
|
/**
|
|
|
|
* @author Richard Davey <rich@photonstorm.com>
|
2019-01-15 16:20:22 +00:00
|
|
|
* @copyright 2019 Photon Storm Ltd.
|
2018-02-12 16:01:20 +00:00
|
|
|
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
|
|
|
*/
|
|
|
|
|
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;
|