phaser/v3/src/math/pow2/GetPowerOfTwo.js
photonstorm 6585297fbf Lots of Math component exports added.
Restructured Phaser export file, finally removing it out of the Boot folder.
Fixed several broken math functions.
2016-12-13 16:12:25 +00:00

11 lines
238 B
JavaScript

// Takes value and returns the nearest power of 2
var GetPowerOfTwo = function (value)
{
// Math.log(2)
var index = Math.log(value) / 0.6931471805599453;
return (1 << Math.ceil(index));
};
module.exports = GetPowerOfTwo;