Last active
October 19, 2018 12:55
-
-
Save kirpalmakanga/76dc25f1754f9f06a56df0ee56f39f2b to your computer and use it in GitHub Desktop.
hex to RGBA
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
const parseHex = (hex) => (startChar, endChar) => | |
parseInt(hex.slice(startChar, endChar), 16); | |
function hexToRGBA(hex, a = 1) { | |
const r = parseHex(hex)(1, 3); | |
const g = parseHex(hex)(3, 5); | |
const b = parseHex(hex)(5, 7); | |
return `rgba(${r},${g},${b},${a})`; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment