Last active
December 26, 2015 10:49
-
-
Save jgdoncel/7139704 to your computer and use it in GitHub Desktop.
Descomponer en RGB un color pasado en hexadecimal.
This file contains hidden or 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
| 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