phaser/v3/src/math/Wrap.js
2016-12-07 17:16:59 +00:00

20 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;