Skip to content

Commit 3642ff0

Browse files
committed
Phaser.Color.toABGR converts RGBA components to a 32 bit integer in AABBGGRR format.
1 parent e08e086 commit 3642ff0

3 files changed

Lines changed: 22 additions & 2 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,7 @@ You can read all about the philosophy behind Lazer [here](http://phaser.io/news/
324324
* Phaser.Utils.reverseString will take the given string, reverse it, and then return it.
325325
* Phaser.ArrayUtils.rotateRight is the opposite of ArrayUtils.rotate. It takes an array, removes the element from the end of the array, and inserts it at the start, shifting everything else 1 space in the process.
326326
* Phaser.ArrayUtils.rotateLeft is the new name for Phaser.ArrayUtils.rotate. The old method is now deprecated (but still available in this release)
327+
* Phaser.Color.toABGR converts RGBA components to a 32 bit integer in AABBGGRR format.
327328

328329
### Updates
329330

src/utils/Color.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,23 @@ Phaser.Color = {
141141

142142
},
143143

144+
/**
145+
* Converts RGBA components to a 32 bit integer in AABBGGRR format.
146+
*
147+
* @method Phaser.Color.toABGR
148+
* @static
149+
* @param {number} r - The red color component, in the range 0 - 255.
150+
* @param {number} g - The green color component, in the range 0 - 255.
151+
* @param {number} b - The blue color component, in the range 0 - 255.
152+
* @param {number} a - The alpha color component, in the range 0 - 255.
153+
* @return {number} A RGBA-packed 32 bit integer
154+
*/
155+
toABGR: function (r, g, b, a) {
156+
157+
return (a << 24) | (b << 16) | (g << 8) | r;
158+
159+
},
160+
144161
/**
145162
* Converts an RGB color value to HSL (hue, saturation and lightness).
146163
* Conversion forumla from http://en.wikipedia.org/wiki/HSL_color_space.

typescript/phaser.d.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/// <reference path="pixi.d.ts" />
22
/// <reference path="p2.d.ts" />
33

4-
// Type definitions for Phaser 2.5.1 - 27th June 2016
4+
// Type definitions for Phaser 2.5.1 - 2nd July 2016
55
// Project: https://github.com/photonstorm/phaser
66

77
declare module "phaser" {
@@ -224,7 +224,8 @@ declare module Phaser {
224224
static rotateMatrix(matrix: any, direction: number | string): any;
225225
static findClosest(value: number, arr: number[]): number;
226226
static rotate(array: any[]): any;
227-
static shift(array: any[]): any;
227+
static rotateLeft(array: any[]): any;
228+
static rotateRight(array: any[]): any;
228229
static numberArray(start: number, end: number): number[];
229230
static numberArrayStep(start: number, end?: number, step?: number): number[];
230231

@@ -762,6 +763,7 @@ declare module Phaser {
762763
static RGBtoHSV(r: number, g: number, b: number, out?: ColorComponents): ColorComponents;
763764
static RGBtoString(r: number, g: number, b: number, a?: number, prefix?: string): string;
764765
static toRGBA(r: number, g: number, b: number, a: number): number;
766+
static toABGR(r: number, g: number, b: number, a: number): number;
765767
static unpackPixel(rgba: number, out?: ColorComponents, hsl?: boolean, hsv?: boolean): ColorComponents;
766768
static updateColor(out: ColorComponents): ColorComponents;
767769
static valueToColor(value: string, out?: ColorComponents): ColorComponents;

0 commit comments

Comments
 (0)