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}
|
|
|
|
*/
|
|
|
|
|
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;
|