mirror of
https://github.com/photonstorm/phaser
synced 2025-01-26 11:55:13 +00:00
20 lines
270 B
JavaScript
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;
|