Is it possible to convert a colour as such #ff0000
to rgb?
So convert #ff0000
to rgb(255,0,0);
I'm pretty sure this has got to be possible, I just don't know how. Any insight would be great!
You could use:
var s = "#ff0000";
var patt = /^#([\da-fA-F]{2})([\da-fA-F]{2})([\da-fA-F]{2})$/;
var matches = patt.exec(s);
var rgb = "rgb("+parseInt(matches[1], 16)+","+parseInt(matches[2], 16)+","+parseInt(matches[3], 16)+");";
alert(rgb);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With