mirror of
https://github.com/photonstorm/phaser
synced 2024-11-24 05:33:35 +00:00
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:
parent
0266c7f0a2
commit
6a32ff56f3
1 changed files with 23 additions and 0 deletions
23
src/display/color/GetColorFromValue.js
Normal file
23
src/display/color/GetColorFromValue.js
Normal 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;
|
Loading…
Reference in a new issue