Created
January 11, 2018 18:48
-
-
Save kfox/bf0d6fe6fd5499d817eb9f4f548f5d8f to your computer and use it in GitHub Desktop.
RGB/Hex Color Conversions in JavaScript
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 convertRGBArrayToHexString = rgb => | |
`#${rgb.map(color => ('0' + color.toString(16)).slice(-2)).join('')}`; | |
const convertHexStringToRGBArray = hex => | |
hex.match(/[^#]{2}/g).map(color => parseInt(color, 16)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment