Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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