Skip to content

Instantly share code, notes, and snippets.

@sioniks
Created August 7, 2019 07:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sioniks/e59d2381e9a6400bb12580502a5b20d8 to your computer and use it in GitHub Desktop.
Save sioniks/e59d2381e9a6400bb12580502a5b20d8 to your computer and use it in GitHub Desktop.
#color #convert
const hexToRgb = hex =>
hex.replace(/^#?([a-f\d])([a-f\d])([a-f\d])$/i
,(m, r, g, b) => '#' + r + r + g + g + b + b)
.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