devgru / postcss-color-hcl

PostCSS plugin to transform hcl() color to compatible CSS (rgb() or rgba()).
MIT License
10 stars 6 forks source link

Color out of range #5

Open gazay opened 9 years ago

gazay commented 9 years ago

Maybe we should do same thing as done here – display closest possible color in rgb? http://bl.ocks.org/mbostock/3e115519a1b495e0bd95

devgru commented 9 years ago

Detecting out of range colors is mission critical feature for this plugin.

You can easily disable it, just remove this three lines: https://github.com/devgru/postcss-color-hcl/blob/016ab1e17dc850be50057443be02a0863c3beb2f/index.js#L28-L30

HCL (CIELCH) and LAB are used when you want to get predictable perception, not predictable domain. So with HCL/LAB you easily get out-of-domain colors. E.g. you cannot ask for 'dark chromatic green', hcl(145, 60, 10) or 'bright chromatic blue', hcl(250, 60, 80). They are out of domain because there's no such colors.

To get predictable domain (360°, 100, 100) of nice cylinder with unpredictable perception and awful ΔE distribution one can use HSL or HSV.

Compare HSL and LAB domains to get the idea: http://bl.ocks.org/devgru/4c6c73b278a0dba364f8

IMHO there's more sense in improving HCL picker (http://devgru.github.io/hcl-picker/) so it will help you choose proper HCL gradient.

Also, there are better tools for selecting specific HCL gradients. I'm looking forward to port it into this PostCSS plugin. http://gka.github.io/palettes/#diverging|c0=darkred,deeppink,lightyellow|c1=lightyellow,lightgreen,teal|steps=13|bez0=1|bez1=1|coL0=1|coL1=1

gazay commented 9 years ago

Wow, thanks for detailed answer! Then maybe add an option that allow you to use this plugin in unsafe mode?

When I tried to understand HCL spec – I found your hcl-picker, but I didn't get how to use it =) There is only rgb values on the right and no values for hcl