I wanted to find a way to code a program that would convert ANY rgb including ones with negative integers into a hex number, like this software.
http://www.javascripter.net/faq/rgbtohex.htm
I have this already but it doesn't seem to be working with the rgb:
rgb(-5, 231, -17)
function rgb2hex(rgb){
rgb = rgb.match(/^rgba?[\s+]?\([\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?/i);
return (rgb && rgb.length === 4) ? "#" +
("0" + parseInt(rgb[1],10).toString(16)).slice(-2) +
("0" + parseInt(rgb[2],10).toString(16)).slice(-2) +
("0" + parseInt(rgb[3],10).toString(16)).slice(-2) : '';
}
Thanks to anyone who can help!