mirror of
https://github.com/photonstorm/phaser
synced 2024-11-23 05:03:37 +00:00
Color.getWebRGB will now accept either an Object or numeric color value.
This commit is contained in:
parent
2293b64c94
commit
003403c832
3 changed files with 12 additions and 5 deletions
|
@ -133,6 +133,7 @@ Version 2.0.6 - "Jornhill" - -in development-
|
|||
* You can now debug render Ninja Physics AABB and Circle objects (thanks @psalaets, #972)
|
||||
* Phaser.Utils.mixin will mix the source object into the destination object, returning the newly modified destination object.
|
||||
* You can now use `game.add.plugin` from the GameObjectFactory (thanks @alvinsight, #978)
|
||||
* Color.getWebRGB will now accept either an Object or numeric color value.
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
|
2
build/phaser.d.ts
vendored
2
build/phaser.d.ts
vendored
|
@ -1492,7 +1492,7 @@ declare module Phaser {
|
|||
static getRandomColor(min?: number, max?: number, alpha?: number): number;
|
||||
static getRed(color: number): number;
|
||||
static getRGB(color: number): Object;
|
||||
static getWebRGB(color: number): string;
|
||||
static getWebRGB(color: any): string;
|
||||
static hexToRGB(h: string): number;
|
||||
static hexToColor(hex: string, out?: Object): Object;
|
||||
static HSLtoRGB(h: number, s: number, l: number, out?: Object): Object;
|
||||
|
|
|
@ -798,14 +798,20 @@ Phaser.Color = {
|
|||
*
|
||||
* @method Phaser.Color.getWebRGB
|
||||
* @static
|
||||
* @param {number} color - Color in RGB (0xRRGGBB) or ARGB format (0xAARRGGBB).
|
||||
* @param {number|Object} color - Color in RGB (0xRRGGBB), ARGB format (0xAARRGGBB) or an Object with r, g, b, a properties.
|
||||
* @returns {string} A string in the format: 'rgba(r,g,b,a)'
|
||||
*/
|
||||
getWebRGB: function (color) {
|
||||
|
||||
var rgb = Phaser.Color.getRGB(color);
|
||||
|
||||
return 'rgba(' + rgb.r.toString() + ',' + rgb.g.toString() + ',' + rgb.b.toString() + ',' + rgb.a.toString() + ')';
|
||||
if (typeof color === 'object')
|
||||
{
|
||||
return 'rgba(' + color.r.toString() + ',' + color.g.toString() + ',' + color.b.toString() + ',' + (color.a / 255).toString() + ')';
|
||||
}
|
||||
else
|
||||
{
|
||||
var rgb = Phaser.Color.getRGB(color);
|
||||
return 'rgba(' + rgb.r.toString() + ',' + rgb.g.toString() + ',' + rgb.b.toString() + ',' + (rgb.a / 255).toString() + ')';
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
|
|
Loading…
Reference in a new issue