Skip to content

Instantly share code, notes, and snippets.

@colorswall
Last active September 20, 2018 09:36
Show Gist options
  • Save colorswall/ea2dced5ae0af5804d5d869d77ce59db to your computer and use it in GitHub Desktop.
Save colorswall/ea2dced5ae0af5804d5d869d77ce59db to your computer and use it in GitHub Desktop.
HEX to RGB JavaScript convert
const hex2rgb = (hex, alpha) => {
const r = parseInt(hex.slice(1, 3), 16);
const g = parseInt(hex.slice(3, 5), 16);
const b = parseInt(hex.slice(5, 7), 16);
return { r, g, b };
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment