mirror of
https://github.com/photonstorm/phaser
synced 2025-01-12 13:18:49 +00:00
21 lines
270 B
JavaScript
21 lines
270 B
JavaScript
|
var Wrap = function (value, min, max)
|
||
|
{
|
||
|
var range = max - min;
|
||
|
|
||
|
if (range <= 0)
|
||
|
{
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
|
var result = (value - min) % range;
|
||
|
|
||
|
if (result < 0)
|
||
|
{
|
||
|
result += range;
|
||
|
}
|
||
|
|
||
|
return result + min;
|
||
|
};
|
||
|
|
||
|
module.exports = Wrap;
|