Last active
May 24, 2021 11:18
-
-
Save mchoiruln/0698482b1ba3b1d2169afe42671017cc to your computer and use it in GitHub Desktop.
Hex Color to RGB color (matrix digit)
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 hexToRGB = hex => { | |
const parse = val => Math.round((val / 255) * 100) / 100 | |
var r = parseInt(hex.slice(1, 3), 16), | |
g = parseInt(hex.slice(3, 5), 16), | |
b = parseInt(hex.slice(5, 7), 16) | |
return { r: parse(r), g: parse(g), b: parse(b) } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment