Skip to content

Instantly share code, notes, and snippets.

@ajfarkas
Last active Aug 29, 2015
Embed
What would you like to do?
hex to RGBa conversion
function hexToRGBa(hex, alpha){
var r = parseInt( hex.slice(1,3), 16 ),
g = parseInt( hex.slice(3,5), 16 ),
b = parseInt( hex.slice(5,7), 16 ),
a = alpha || 1;
return "rgba(" + r + ", " + g + ", " + b + ", " + a + ")";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment