Display.Color.GetColorFromValue is a new function that will take a hex color value and return it as an integer, for use in WebGL. This is now used internally by the Tint component and other classes.

This commit is contained in:
Richard Davey 2020-08-03 10:48:52 +01:00
parent 0266c7f0a2
commit 6a32ff56f3

View file

@ -0,0 +1,23 @@
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
/**
* Given a hex color value, such as 0xff00ff (for purple), it will return a
* numeric representation of it (i.e. 16711935) for use in WebGL tinting.
*
* @function Phaser.Display.Color.GetColorFromValue
* @since 3.50.0
*
* @param {number} red - The hex color value, such as 0xff0000.
*
* @return {number} The combined color value.
*/
var GetColorFromValue = function (value)
{
return (value >> 16) + (value & 0xff00) + ((value & 0xff) << 16);
};
module.exports = GetColorFromValue;