Skip to content

Instantly share code, notes, and snippets.

@Indamix
Last active January 4, 2016 19:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Indamix/8665437 to your computer and use it in GitHub Desktop.
Save Indamix/8665437 to your computer and use it in GitHub Desktop.
bitwise for color
var hexToRgb = function(hex) {
hex = parseInt(hex, 16);
return [
(hex & 0xff0000) >> 16,
(hex & 0x00ff00) >> 8,
(hex & 0x0000ff)
];
};
var rgbToHex = function(r, g, b) {
return (1 << 24 | r << 16 | g << 8 | b).toString(16).substr(1);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment