Revision: 35231
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at November 4, 2010 18:35 by madr
Initial Code
function hex2rgb(hex, opacity) { var rgb = hex.replace('#', '').match(/(.{2})/g); var i = 3; while (i--) { rgb[i] = parseInt(rgb[i], 16); } if (typeof opacity == 'undefined') { return 'rgb(' + rgb.join(', ') + ')'; } return 'rgba(' + rgb.join(', ') + ', ' + opacity + ')'; };
Initial URL
http://madr.se/blog/151
Initial Description
Transform a color given in hex to RGB. An optional opacity argument also enables RBGA.
Initial Title
Hex to RGB or RGBA transluder
Initial Tags
javascript
Initial Language
JavaScript