From 9030fbf3520ed71d96c3b3acc5e28c0cbec2d6ec Mon Sep 17 00:00:00 2001 From: Stuart Lee Date: Wed, 30 Oct 2013 13:34:46 +0000 Subject: [PATCH] hexToRGB now accepts short hex codes (#EEE) --- src/utils/Color.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/utils/Color.js b/src/utils/Color.js index fb4f2dc70..c7356dfc2 100644 --- a/src/utils/Color.js +++ b/src/utils/Color.js @@ -48,6 +48,11 @@ Phaser.Color = { hexToRGB: function (h) { var hex16 = (h.charAt(0) == "#") ? h.substring(1, 7) : h; + + if (hex16.length==3) { + hex16 = hex16.charAt(0) + hex16.charAt(0) + hex16.charAt(1) + hex16.charAt(1) + hex16.charAt(2) + hex16.charAt(2); + } + var red = parseInt(hex16.substring(0, 2), 16); var green = parseInt(hex16.substring(2, 4), 16); var blue = parseInt(hex16.substring(4, 6), 16);