How do I get HTML Color Picker to return RGB values

I am more than capable of converting the Hex values to RGB, but just wondering if there was a setting on the Color Input to automatically return RGB or RGBA values instead of the Hex ones
13 Replies
ἔρως
ἔρως8mo ago
no, there isn't it returns #rrggbb and that's it
Blackwolf
BlackwolfOP8mo ago
ahhhh, ok thanks, i've been googling and couldn;t find anything. so maths it is then 🙂
ἔρως
ἔρως8mo ago
if you need it in rgb, you have to convert it yourself it's not hard
Blackwolf
BlackwolfOP8mo ago
oh i know it's easy enough, i just wanted to keep my code as short as possible
ἔρως
ἔρως8mo ago
you don't have to worry about that that's the dumbest thing you should worry about just make sure you write the best code you can leave the size for the bundler you will read the code more often than you write it so, make sure that you can read it in 10 years
Blackwolf
BlackwolfOP8mo ago
thank you 🙂
ἔρως
ἔρως8mo ago
you're welcome i have a small solution for you
input.value.replace(/#(..)(..)(..)/, (_, r, g, b) => `rgb(${parseInt(r,16)},${parseInt(g,16)},${parseInt(b,16)})`)
input.value.replace(/#(..)(..)(..)/, (_, r, g, b) => `rgb(${parseInt(r,16)},${parseInt(g,16)},${parseInt(b,16)})`)
no math needed, generates rgb values if you must squeeze every byte out of it, you can do this cursed thing:
'#c0ffee'.replace(/#(..)(..)(..)/,(_,r,g,b,x,y,z=parseInt)=>`rgb(${z(r,16)},${z(g,16)},${z(b,16)})`)
'#c0ffee'.replace(/#(..)(..)(..)/,(_,r,g,b,x,y,z=parseInt)=>`rgb(${z(r,16)},${z(g,16)},${z(b,16)})`)
TheJoshShephard
TheJoshShephard8mo ago
If you're on Windows use the color picker tool in Power Toys and you can access whatever variant you need. Also if you mean in the developer console. You can change it easily with Chrome or Firefox
ἔρως
ἔρως8mo ago
he wants a color input on the website
TheJoshShephard
TheJoshShephard8mo ago
Noted! That seems interesting!
ἔρως
ἔρως8mo ago
it's a simple <input type="color">
TheJoshShephard
TheJoshShephard8mo ago
Noted! I've only recently been getting back into everything. So I haven't touched inputs yet since the site I've been using doesn't allow for them. But either way, thanks for the heads up!
ἔρως
ἔρως8mo ago
you're welcome
Want results from more Discord servers?
Add your server