mirror of
https://github.com/wassname/phaser.git
synced 2026-07-01 16:50:43 +08:00
hexToRGB now accepts short hex codes (#EEE)
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user