Skip to content

Commit 0a77690

Browse files
committed
Merge pull request phaserjs#144 from beeglebug/dev
hexToRGB now accepts short hex codes (#EEE)
2 parents 24c809d + 9030fbf commit 0a77690

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

src/utils/Color.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ Phaser.Color = {
4848
hexToRGB: function (h) {
4949

5050
var hex16 = (h.charAt(0) == "#") ? h.substring(1, 7) : h;
51+
52+
if (hex16.length==3) {
53+
hex16 = hex16.charAt(0) + hex16.charAt(0) + hex16.charAt(1) + hex16.charAt(1) + hex16.charAt(2) + hex16.charAt(2);
54+
}
55+
5156
var red = parseInt(hex16.substring(0, 2), 16);
5257
var green = parseInt(hex16.substring(2, 4), 16);
5358
var blue = parseInt(hex16.substring(4, 6), 16);

0 commit comments

Comments
 (0)