tinyColorPicker
tinyColorPicker copied to clipboard
Rango 0-255 for alpha values
it would be nice to have an option to set the 8 bit native range for alpha values, in my code (openGL calls) I need to specify alpha with a single byte and converting it to float (with only two digits) loses precision and does not exploit all the dynamic range.
May be there already is an easy way to set this but I had,'t been able to figure it out.
thanks Davide
Hi @davidemania, I don't quite understand what you mean by "8-bit native range" as 0-1 is native when it comes to opacity in rgba or hsla. So if you want it to be rgba(100,75,12,200) ... this won't work. If you want to have your custom values in the input field then you need to make your own converters: in the renderCallback() you can always do what you need to do: See https://github.com/PitPik/tinyColorPicker#jqcolorpickerjs and scroll down to the renderCallback() description. You'll see 3 states the function can be in (toggled...). You just need to write a converter that renders different values than the native ones.
Il giorno 03 ott 2017, alle ore 10:17, Peter Dematté [email protected] ha scritto:
Hi @davidemania https://github.com/davidemania, I don't quite understand what you mean by "8-bit native range" as 0-1 is native when it comes to opacity in rgba or hsla. So if you want it to be rgba(100,75,12,200) ... this won't work. I am using the value from color picker to set alpha value in openGL (using the THREE.js library) and there you need to specify an 8 bit value for alpha.
Converting from 0-1 (with two digits) to 0-255 loses a little precision but it's not so bad, now that's what I am doing
If you want to have your custom values in the input field then you need to make your own converters: in the renderCallback() you can always do what you need to do: See https://github.com/PitPik/tinyColorPicker#jqcolorpickerjs https://github.com/PitPik/tinyColorPicker#jqcolorpickerjs and scroll down to the renderCallback() description. You'll see 3 states the function can be in (toggled...). You just need to write a converter that renders different values than the native ones.
I'll have a look to that. Thank you
Thanks for your work, very well done Davide
How do you want the output (input field value) look like?... Maybe I can help you with this.
Il giorno 03 ott 2017, alle ore 14:20, Peter Dematté [email protected] ha scritto:
How do you want the output (input field value) look like?... Maybe I can help you with this.
Well it should be in the 0-255 range exactly like the R, G and B values. As I told you this is not of the highest priority since just multiplying the float value by 255 does the trick (with a little loss in precision) but everything would be more elegant with the proper range. And it’s very likely it will benefit other users too-
thank you Davide