Skip to content

Instantly share code, notes, and snippets.

@jgdoncel
Last active December 26, 2015 10:49
Show Gist options
  • Select an option

  • Save jgdoncel/7139704 to your computer and use it in GitHub Desktop.

Select an option

Save jgdoncel/7139704 to your computer and use it in GitHub Desktop.
Descomponer en RGB un color pasado en hexadecimal.
function hexToRgb (hex) {
var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
return result ? {
r: parseInt(result[1], 16),
g: parseInt(result[2], 16),
b: parseInt(result[3], 16)
} : null;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment