mirror of
https://github.com/photonstorm/phaser
synced 2024-12-28 05:53:49 +00:00
12 lines
227 B
JavaScript
12 lines
227 B
JavaScript
|
// Takes value and returns the nearest power of 2
|
||
|
|
||
|
var GetPowerOfTwo (value)
|
||
|
{
|
||
|
// Math.log(2)
|
||
|
var index = Math.log(value) / 0.6931471805599453;
|
||
|
|
||
|
return (1 << Math.ceil(index));
|
||
|
};
|
||
|
|
||
|
module.exports = GetPowerOfTwo;
|