Mischback / colorizer

A simple web-based colorscheme builder which focuses on contrast values.
https://mischback.github.io/colorizer/
MIT License
1 stars 0 forks source link

Force colors into gamut #25

Open Mischback opened 1 year ago

Mischback commented 1 year ago

Internally, colors are stored in CIE XYZ D65 colorspace, which is really big (meant to provide the means to describe all visible colors). The different input methods are working on their respective color spaces (e.g. sRGB and Oklch), which are not congruent.

Colors must be forced into the color space's gamut. The easiest way is to just clip values, that are outside of the expected range, e.g. for sRGB values < 0 and > 1.

Currently this is the most basic implementation, just discarding these values. Might need more attention!

Resources

Mischback commented 1 year ago

808bbaea83a1a317d6863845d6841ec026d250f6 has (working) RGB and OkLCH inputs. However, the colors are not matching, most likely because of the internal conversion to XYZ and re-conversion into the actual color spaces / input methods. Nope, see #36 for a description of this bug!

The simple clipping is not sufficient to align the colors properly! Despite #36, this is still true and applies when use (i.e.) OkLCH input.