hexToRGB now accepts short hex codes (#EEE)

This commit is contained in:
Stuart Lee 2013-10-30 13:34:46 +00:00
parent 24c809dd5f
commit 9030fbf352

View file

@ -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);