PitPik / colorPicker

Advanced javaScript color picker and color conversion / calculation (rgb, hsv, hsl, hex, cmyk, cmy, XYZ, Lab, alpha, WCAG 2.0, ...)
http://www.dematte.at/colorPicker/
MIT License
570 stars 136 forks source link

CMYK issues #64

Open thednp opened 5 years ago

thednp commented 5 years ago

This doesn't bother me very much, but if I ever get into a situation where I need CMYK to be used with my favorite colorPicker of all time, well....

Here's the thing: I set an input

<input class="colorpicker" data-colormode="cmyk" type="text" value="cmyk(15,25,30,40)">
var pickers = new jsColorPicker('input.colorpicker', {});

Issues:

PitPik commented 5 years ago

Hi @thednp The issue is not related to a bug but to wrong expectations. The initiator of colorPicker accepts color formats that are supported by the browser which are RGB, rgb, rgba, hsl and hsla. RGBA is also supported nowerdays, but I guess colorPicker doesn't (I have to look it up).

You might want to write an input that takes cmyc and convert it to rgb and feed a hidden input with the value so the hidden input triggers the colorPicker but it shows values from the cmyc input field. If you wrap both inside a <label> tag, the click event will be transferred to the hidden input and the colorPicker should show.

Hope this helped. Greetings.

thednp commented 5 years ago

Thanks for taking the time to reply.

I'm not using the colorpicker to use it's CMYK value as color for web elements, I know it's not supported, but I use it as a way for people to input a color in any format they have, perhaps some folk has come from print with CMYK values and wants to use those colors into web apps, converted to supported formats like rgb/hex or hsl in the near future.

I suggest you take a look, it won't take much.