Friday, February 26, 2010

HEX to RGB

Color can sometimes make or break your design.
It’s even nice for translating a Hexadecimal color into RGB color.


var color = 0x00cc00
var rgbObject = hex2rgb(color);
function hex2rgb (hex):Object{
var red = hex>>16;
var greenBlue = hex-(red<<16) var green = greenBlue>>8;
var blue = greenBlue - (green << 8);
return({r:red, g:green, b:blue});
}

No comments:

Post a Comment