Skip to content

[css-color-4] Use 0 chroma when hue is powerless during conversion #14133

Description

@romainmenke

https://drafts.csswg.org/css-color-4/#powerless-color-component

When performing color space conversion to a cylindrical polar color space, user agents shall treat a hue component as powerless if the chroma (or other measure of colorfulness, such as saturation in hsl) is less than the epsilon (ε) specified for that color space. For example, a gray color converted into oklch() may, due to numerical errors, have an extremely small chroma rather than precisely 0%; as a result, the hue component is powerless.

https://drafts.csswg.org/css-color-4/#specifying-oklab-oklch

Powerless hue ε C <= 0.000004

So hue is powerless when chroma is smaller than 0.000004 but chroma itself is not set to 0.
And any missing component is treated as 0 for the actual conversion math.

So color(from oklch(0.5 0.000004 180) display-p3 r g b) which should have a powerless hue still ends up as: color(display-p3 0.38857936 0.38856994 0.38857244)

Converting that to hsl for example results in color(srgb 0.38858148 0.38856954 0.3885725).


Shouldn't chroma/saturation also be set to 0 when it matches the powerless hue condition? Otherwise the outcome is a color with whatever hue 0deg is for a given color space. This hue might itself be powerless, but when converting to polar spaces it will still surface.

@svgeesus

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions