Skip to content

Instantly share code, notes, and snippets.

@ajfarkas
Last active August 29, 2015 14:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ajfarkas/bb9c4ad055b8c913f7f1 to your computer and use it in GitHub Desktop.
Save ajfarkas/bb9c4ad055b8c913f7f1 to your computer and use it in GitHub Desktop.
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