Created
December 15, 2011 22:03
-
-
Save alanedwardes/1483114 to your computer and use it in GitHub Desktop.
JavaScript function to convert a hexadecimal colour representation to an RGB object, {r: n, g: n, b: n}
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function hexToRGB(hex){ | |
hex = hex.replace('#', ''); | |
return { | |
'r': parseInt(hex.substring(0, 2), 16), | |
'g': parseInt(hex.substring(2, 4), 16), | |
'b': parseInt(hex.substring(4, 6), 16) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment