Skip to content

Instantly share code, notes, and snippets.

@mchoiruln
Last active May 24, 2021 11:18
Show Gist options
  • Save mchoiruln/0698482b1ba3b1d2169afe42671017cc to your computer and use it in GitHub Desktop.
Save mchoiruln/0698482b1ba3b1d2169afe42671017cc to your computer and use it in GitHub Desktop.
Hex Color to RGB color (matrix digit)
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