Re: [csswg-drafts] [css-color] Computing lch/lab to srgb with lightness = 0% or 100% (#8794)

There is a contradiction in the spec. From [ICC Specification ### ICC.1:2004-10](https://www.color.org/icc1v42.pdf) Section 6.4: Converting between CIEXYZ and CIELAB encodings, which are more succinctly summarized on their [wikipedia page](https://en.wikipedia.org/wiki/CIELAB_color_space):

```c++
float kD50_z = 0.8251f;
float kD50_y = 1.0;
float kD50_z = 0.8251;
LabToXYZD50(float l, float a, float b) {
  float y = (l + 16.0f) / 116.0f;
  float x = y + a / 500.0f;
  float z = y - b / 200.0f;

  auto LabInverseTransferFunction = [](float t) {
    constexpr float delta = (24.0f / 116.0f);

    if (t <= delta) {
      return (108.0f / 841.0f) * (t - (16.0f / 116.0f));
    }

    return t * t * t;
  };

  x = LabInverseTransferFunction(x) * kD50_x;
  y = LabInverseTransferFunction(y) * kD50_y;
  z = LabInverseTransferFunction(z) * kD50_z;
}
```

Inputting `l = 0`, `a = 100` and `b = 0` to this formula gives `x = 0.0372`, `y = 0` and `z = 0`, which is equivalent to `srgb 0.38 -0.21 0.03)` which is _not_ black, but a dark red.

This line from https://www.w3.org/TR/css-color-4/#specifying-lab-lch seems to be causing the confusion:

> The first argument specifies the CIE Lightness. This is a number between 0% (representing black) and 100% (representing white), 

I propose the wording there is changed to:
 "This is a number between 0% (representing black when a and b are both zero) and 100% (representing white, when a and b are both zero)"
 or:
 "This is a number between 0% (often representing black) and 100% (often representing white)"
 or:
  "This is a number between 0% (representing fully dark) and 100% (representing fully bright)"
  
  There is some confusion as well in [crbug.com/1439722](crbug.com/1439722) that `a` and `b` should [powerless](https://drafts.csswg.org/css-color/#powerless) when `l` is zero or 100, but this is never mentioned in the spec.

@svgeesus: If I have not misunderstood things, is there any objection to changing the wording?



-- 
GitHub Notification of comment by mysteryDate
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/8794#issuecomment-1540781981 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Tuesday, 9 May 2023 19:33:11 UTC