Skip to content

Commit

Permalink
Merge pull request phaserjs#144 from beeglebug/dev
Browse files Browse the repository at this point in the history
hexToRGB now accepts short hex codes (#EEE)
  • Loading branch information
photonstorm committed Oct 30, 2013
2 parents 24c809d + 9030fbf commit 0a77690
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/utils/Color.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 0a77690

Please sign in to comment.