Created
May 1, 2016 15:14
-
-
Save mtford90/d14e1cc9808e79817868ee0ae6f5d3cc to your computer and use it in GitHub Desktop.
This file contains 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 rgba (hex, opacity) { | |
return `rgba(${hexToR(hex)}, ${hexToG(hex)}, ${hexToB(hex)}, ${opacity})` | |
} | |
function hexToR (h) {return parseInt((cutHex(h)).substring(0, 2), 16)} | |
function hexToG (h) {return parseInt((cutHex(h)).substring(2, 4), 16)} | |
function hexToB (h) {return parseInt((cutHex(h)).substring(4, 6), 16)} | |
function cutHex (h) {return (h.charAt(0) == "#") ? h.substring(1, 7) : h} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment