UNPKG

phaser

Version:

A fast, free and fun HTML5 Game Framework for Desktop and Mobile web browsers from the team at Phaser Studio Inc.

25 lines (21 loc) 562 B
/** * @author Richard Davey <rich@phaser.io> * @copyright 2013-2025 Phaser Studio Inc. * @license {@link https://opensource.org/licenses/MIT|MIT License} */ /** * Returns the nearest power of 2 to the given `value`. * * @function Phaser.Math.Pow2.GetNext * @since 3.0.0 * * @param {number} value - The value. * * @return {number} The nearest power of 2 to `value`. */ var GetPowerOfTwo = function (value) { var index = Math.log(value) / 0.6931471805599453; return (1 << Math.ceil(index)); }; module.exports = GetPowerOfTwo;