facelessuser / ColorHelper

Sublime plugin that provides helpful color previews and tooltips
https://facelessuser.github.io/ColorHelper/
MIT License
254 stars 30 forks source link

New color picker color spaces need to be supported in contrast and colormod #195

Closed facelessuser closed 2 years ago

facelessuser commented 2 years ago

There shouldn't be an issue supported Okhsl and Okhsv in the contrast tool. They are technically sRGB spaces, they just get there directly from Oklab.

As far as ColorMod tool is concerned, we can proabably just convert the values over to sRGB. That is what is "supposed" to happen, but it appears it just ignores the input instead of converting it.

facelessuser commented 2 years ago

This shouldn't be too bad after looking into it. ColorMod tool will probably remain restricted to its spec.

We may, from the color picker, just convert non-accepted color formats to sRGB. ColorPicker will get whatever gets returned.

The contrast tool, on the other hand, we can probably be more flexible with. We can probably extend it to all color formats, but its functionality is still currently restricted to the sRGB range as the algorithm works in the sRGB space using HWB. We can probably convert the color over to HWB, ensure the color is in gamut, and report that color, converted back to the source color space, as the color used. That way we are accurately presented what we are contrasting. The color will be returned back to the color picker, or whatever called it, in the format of the source color.

facelessuser commented 2 years ago

Color contrast should handle any color now, it'll just gamut map them and make it more clear that it is gamut mapping the color. Color contrast tool only works in the sRGB color space at this time.

As for ColorMod, it will not work with Okhsl and Okhsv. Their color(--hsl) format is incompatible with the ColorMod color() format of the same name. That's just the way it is.

facelessuser commented 2 years ago

We got okhsl and okhsv to work after all. It'll convert over to HSL or HSV for the duration of ColorMod and convert back when done.