facelessuser / coloraide

A library to aid in using colors
https://facelessuser.github.io/coloraide
MIT License
195 stars 12 forks source link

Do not gamut map HSL and similar spaces when interpolating? #287

Closed facelessuser closed 1 year ago

facelessuser commented 1 year ago

The people over CSS are debating dropping the gamut map requirement for certain spaces like HSL and such in order to defer gamut mapping to a later spec. Generally, HSL can round trip fine, but when dealing with interpolation, colors can give negative saturation which can make interpolation messy.

I actually don't have a problem with removing the requirement to gamut map with interpolation, but I'd at least want to tighten up the window for on some of the spaces when the lightness is very close to 1 (or 100 depending on the space's scaling). Basically, for some of the conversions, if lightness is very close 1 or 100, we count saturation as 0. This helps provide sane behavior during interpolation. It slightly affects roundtripping when very close to white, but the overall benefit that is gained when working with the colors outweighs the negative I think.

Anyways, there are couple of color spaces who's range won't quite capture resolve crazy saturation with something like oklch(1 0 0). We can adjust that range to give good results. We also had some spaces where we forgot to add the flag to force gamut mapping anyways (hsi).

Generally, we can mention that some spaces may give odd results if lightness exceeds the SDR threshold we put in place, and we can suggest that people should probably fit the inputs for best results if using a finicky interpolation space that is sensitive to SDR ranges.

facelessuser commented 1 year ago

Fixed by https://github.com/facelessuser/coloraide/pull/296