Re: [csswg-drafts] [css-color-6] color-contrast() should take transparency into account (#7358)

I separated the possibility of a compositing function into #8431.

---

A few brief thoughts on finding the "worst case" for a transparent background:  for a start, I think when we're looking for the worst case, we should be looking for the worst case under the assumption that the colors are being used in a surface that's fully opaque, uses source-over compositing and normal blend mode.  Cases beyond that aren't the problem of the color contrast algorithm.  An example (of the "not the contrast algorithm's problem" case):
```html
<div style="background: black">
  <div style="background: black; color: white; mix-blend-mode: darken">
    This text is black on black!
  </div>
</div>
```

---

A very naive possibility for finding the worst case backdrop is to choose an R, G, and B component for the backdrop such that compositing the (partially transparent) background color on top of the backdrop will produce R, G, and B results that are as close as possible to the R, G, and B components of the foreground color.

I think this naive possibility does find the cases where it's possible to get to zero contrast with a particular backdrop, but probably doesn't get to minimal contrast for the cases where you can't get to zero.  An example zero-contrast case is:
```html
<div class="backdrop" style="background: rgb(155, 240, 200)">
  <div style="background: rgba(255, 140, 0, 0.4); color: rgb(195, 200, 120)">
    This text is not visible!
  </div>
</div>
```
Note that this case has (I think) reasonable contrast against a black backdrop (though not against white).

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


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

Received on Wednesday, 8 February 2023 18:52:29 UTC