2018-02-12 16:01:20 +00:00
|
|
|
/**
|
|
|
|
* @author Richard Davey <rich@photonstorm.com>
|
2022-02-28 14:29:51 +00:00
|
|
|
* @copyright 2022 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
|
|
|
*/
|
|
|
|
|
2017-10-06 05:16:31 +00:00
|
|
|
/**
|
2018-05-23 16:42:54 +00:00
|
|
|
* Wrap the given `value` between `min` and `max.
|
2017-10-06 05:16:31 +00:00
|
|
|
*
|
|
|
|
* @function Phaser.Math.Wrap
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
2018-05-23 16:42:54 +00:00
|
|
|
* @param {number} value - The value to wrap.
|
|
|
|
* @param {number} min - The minimum value.
|
|
|
|
* @param {number} max - The maximum value.
|
2017-10-06 05:16:31 +00:00
|
|
|
*
|
2018-05-23 16:42:54 +00:00
|
|
|
* @return {number} The wrapped value.
|
2017-10-06 05:16:31 +00:00
|
|
|
*/
|
2016-12-07 17:16:59 +00:00
|
|
|
var Wrap = function (value, min, max)
|
|
|
|
{
|
|
|
|
var range = max - min;
|
|
|
|
|
2017-06-17 03:15:02 +00:00
|
|
|
return (min + ((((value - min) % range) + range) % range));
|
2016-12-07 17:16:59 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = Wrap;
|