w3c / w3c/csswg-drafts

[css-color-4] How to handle conversions that result in negative lightness?

Open
#9,484 22 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Closed Accepted as Editorial Commenter Satisfied css-color-4 Needs Testcase (WPT)
Dominant language
Bikeshed
Stars
4.9k
Forks
816
PR merge metrics
PR metrics pending

Description

It's possible for a color conversion to result in negative lightness. For example, the color lab(1% 60 100) is naively equivalent to oklab(-4.8743815325% 0.7106198377 0.1847214228). Negative lightnesses are generally disallowed, but the spec is only explicit that they should be clamped at parsed-value time, which leaves it ambiguous what to do when they come up as the result of a conversion.

It's not clear to me what the right solution is here. If you clamp eagerly, you break the ability to round-trip safely between Lab and OKLab. Clamping at parsed-value time means that there are valid Lab colors which can't be represented in OKLab. Is this acceptable? If not, how should it be solved?

Edit: A more prominent example is color(xyz-d65 1 1 1), which can't be exactly represented in Lab without a lightness above 100% because Lab uses a d50 whitepoint.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with issue #9484 and the CSS Color 4 discussion, focusing on the Lab and OKLab examples and the xyz-d65 example. Review the existing parsed-value clamping language and the 22-comment thread before proposing a direction. Done means the conversion behavior for negative or above-range lightness has an agreed, unambiguous specification.

Written by the indexing model from the issue text.

Assessment

Tech stack
css
Domain
web-dev
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Active
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.