Skip to content

Instantly share code, notes, and snippets.

@elliptic-shiho
Last active August 29, 2015 14:25
Show Gist options
  • Save elliptic-shiho/b23c147a0155eca7c890 to your computer and use it in GitHub Desktop.
Save elliptic-shiho/b23c147a0155eca7c890 to your computer and use it in GitHub Desktop.
var r2a = function(x) {
return x.match(/#?([0-9a-fA-F]{1,2})([0-9a-fA-F]{1,2})([0-9a-fA-F]{1,2})/)
.map(function(a) {
return parseInt(a, 16);
}).splice(1);
};
// r2a("#0c0c0c") -> [12, 12, 12]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment