Skip to content

Instantly share code, notes, and snippets.

@Hexrays
Created March 2, 2016 16:18
Show Gist options
  • Save Hexrays/6cd3085b524841fad915 to your computer and use it in GitHub Desktop.
Save Hexrays/6cd3085b524841fad915 to your computer and use it in GitHub Desktop.
function getRGB(hex){
var res = 'rgb(';
if (hex.length === 7) {
res += parseInt(hex[1] + hex[2], 16) + ', ';
res += parseInt(hex[3] + hex[4], 16) + ', ';
res += parseInt(hex[5] + hex[6], 16) + ')';
return res;
} else {
res += parseInt(hex[1]+ hex[1], 16) + ', ';
res += parseInt(hex[2] + hex[2], 16) + ', ';
res += parseInt(hex[3] + hex[3], 16) + ')';
return res;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment