mirror of
https://github.com/photonstorm/phaser
synced 2024-12-24 12:03:36 +00:00
20 lines
285 B
JavaScript
20 lines
285 B
JavaScript
|
var Percent = function (a, b, base)
|
||
|
{
|
||
|
if (base === undefined) { base = 0; }
|
||
|
|
||
|
if (a > b || base > b)
|
||
|
{
|
||
|
return 1;
|
||
|
}
|
||
|
else if (a < base || base > a)
|
||
|
{
|
||
|
return 0;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return (a - base) / b;
|
||
|
}
|
||
|
};
|
||
|
|
||
|
module.exports = Percent;
|