Skip to content

Commit

Permalink
[css-color-6] Add handling for non-opaque colors in contrast-color()
Browse files Browse the repository at this point in the history
Relates to #7358

Co-Authored-By: fantasai <725717+fantasai@users.noreply.github.com>
  • Loading branch information
LeaVerou and fantasai committed Oct 21, 2022
1 parent 14a10b8 commit be4cc30
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions css-color-6/Overview.bs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Editor: Lea Verou, Invited Expert, http://lea.verou.me/about, w3cid 52258
Editor: Adam Argyle, Google, https://nerdy.dev, w3cid 112669
Abstract: This module extends CSS Color [[css-color-5]] to add contrast calculation.
Repository: w3c/csswg-drafts
Inline Github Issues: title
Inline Github Issues: false
</pre>

<pre class='ignored-specs'>
Expand Down Expand Up @@ -86,7 +86,7 @@ Computing a Contrasting Color: the ''contrast-color()'' function {#colorcontrast
or as a background against a list of [=color candidate|candidate=] text colors.
(The effective contrast of a pair of colors depends on their usage.)

ISSUE(#7359): The keywords to specify whether the [=base color=] is a foreground or background are <abbr title="to be decided">TBD</abbr>.
ISSUE(7359): The keywords to specify whether the [=base color=] is a foreground or background are <abbr title="to be decided">TBD</abbr>.

The <dfn><<target-contrast>></dfn> argument specifies the contrast algorithm(s) to use.
If no [=color candidates=] have been provided,
Expand Down Expand Up @@ -272,13 +272,27 @@ If no target contrast is specified</h4>
* the contrast is (0.92781 + 0.05) / (0.03568 + 0.05) = <b>11.4123</b>
</div>

<h4 id="contrast-transparency">
Contrasting Semi-transparent Colors</h4>

This section applies only to contrast algorithms that require their inputs to be opaque colors.

When calculating the contrast of a pair of colors:

1. The background color is first blended over an opaque canvas color
using simple alpha compositing (see [[compositing-1#simplealphacompositing]])
to find an opaque background color.

<div class="issue">
<a href="https://github.com/w3c/csswg-drafts/issues/7358">#7358</a> Find a good opaque canvas color for this computation.
Candidates are:
- the foreground color with alpha = 1
- the ''canvas'' system color
- some other color calculated to minimize the contrast for the algorithm used
</div>



2. The foreground color is then blended over this opaque background color
to find an opaque foreground color.



Expand Down

0 comments on commit be4cc30

Please sign in to comment.