Created
August 22, 2016 09:50
-
-
Save fsschmitt/14f5bd44ddad9f39e714576205f2b664 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
const componentToHex = c => { | |
const hex = c.toString(16) | |
return hex.length === 1 ? '0' + hex : hex | |
} | |
const rgbToHex = (r, g, b) => '#' + [r, g, b].map(componentToHex).join('') | |
const hexToRgb = hex => hex.substring(1).match(/.{2}/g).map(x => parseInt(x, 16)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment