Skip to content

Commit 36594e9

Browse files
committed
[css-color-6] Rename color-contrast() to contrast-color(), closes w3c#7557
1 parent 4bdf6a1 commit 36594e9

File tree

1 file changed

+23
-23
lines changed

1 file changed

+23
-23
lines changed

css-color-6/Overview.bs

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Introduction {#intro}
3535
<em>This section is not normative.</em>
3636

3737
This module adds two one function:
38-
''color-contrast()''.
38+
''contrast-color()''.
3939

4040

4141

@@ -52,7 +52,7 @@ Introduction {#intro}
5252
https://caniuse.com/mdn-css_types_color_color-contrast
5353
-->
5454

55-
Selecting the most contrasting color: the ''color-contrast()'' function {#colorcontrast}
55+
Selecting the most contrasting color: the ''contrast-color()'' function {#colorcontrast}
5656
========================================================================================
5757

5858
This function takes, firstly, a single color
@@ -71,13 +71,13 @@ Selecting the most contrasting color: the ''color-contrast()'' function {#colorc
7171
with the keyword <css>to</css>.
7272

7373
<pre class='prod'>
74-
<dfn>color-contrast()</dfn> = color-contrast( <<color>> vs <<color>>#{2,} [ to [<<number>> | AA | AA-large | AAA | AAA-large]]? )
74+
<dfn>contrast-color()</dfn> = contrast-color( <<color>> vs <<color>>#{2,} [ to [<<number>> | AA | AA-large | AAA | AAA-large]]? )
7575
</pre>
7676

77-
The keyword <dfn value for="color-contrast()">AA</dfn> is equivalent to ''4.5'',
78-
<dfn value for="color-contrast()">AA-large</dfn> is equivalent to ''3'',
79-
<dfn value for="color-contrast()">AAA</dfn> is equivalent to ''7'', and
80-
<dfn value for="color-contrast()">AAA-large</dfn> is equivalent to ''4.5'' .
77+
The keyword <dfn value for="contrast-color()">AA</dfn> is equivalent to ''4.5'',
78+
<dfn value for="contrast-color()">AA-large</dfn> is equivalent to ''3'',
79+
<dfn value for="contrast-color()">AAA</dfn> is equivalent to ''7'', and
80+
<dfn value for="contrast-color()">AAA-large</dfn> is equivalent to ''4.5'' .
8181

8282
<h3 id="luminance-contrast">
8383
Calculating luminance and WCAG 2.1 contrast
@@ -129,7 +129,7 @@ Selecting the most contrasting color: the ''color-contrast()'' function {#colorc
129129
-->
130130

131131
<div class="example">
132-
<pre class="lang-css">color-contrast(wheat vs tan, sienna, var(--myAccent), #d2691e)</pre>
132+
<pre class="lang-css">contrast-color(wheat vs tan, sienna, var(--myAccent), #d2691e)</pre>
133133

134134
The calculation is as follows:
135135
* <span class="swatch" style="--color: wheat"></span> wheat (#f5deb3), the background, has relative luminance 0.749
@@ -147,7 +147,7 @@ Selecting the most contrasting color: the ''color-contrast()'' function {#colorc
147147
https://colorjs.io/notebook/?storage=https%3A%2F%2Fgist.github.com%2Fsvgeesus%2Fec249f376fcecbaa8794f75dbfc1dacf
148148
-->
149149
<div class="example">
150-
<pre class="lang-css">color-contrast(wheat vs bisque, darkgoldenrod, olive, sienna, darkgreen, maroon to AA)</pre>
150+
<pre class="lang-css">contrast-color(wheat vs bisque, darkgoldenrod, olive, sienna, darkgreen, maroon to AA)</pre>
151151

152152
The calculation is as follows:
153153
* <span class="swatch" style="--color: wheat"></span> wheat (#f5deb3), the background, has relative luminance 0.749
@@ -164,7 +164,7 @@ Selecting the most contrasting color: the ''color-contrast()'' function {#colorc
164164
</div>
165165

166166
<div class="example">
167-
<pre class="lang-css">color-contrast(wheat vs bisque, darkgoldenrod, olive, sienna, darkgreen, maroon to 5.8)</pre>
167+
<pre class="lang-css">contrast-color(wheat vs bisque, darkgoldenrod, olive, sienna, darkgreen, maroon to 5.8)</pre>
168168

169169
The calculation is as follows:
170170
* the relative luminances and contrast ratios are the same as the previous example.
@@ -192,7 +192,7 @@ Selecting the most contrasting color: the ''color-contrast()'' function {#colorc
192192
whichever has the higher contrast.
193193

194194
<div class="example">
195-
<pre class="lang-css">color-contrast(wheat vs bisque, darkgoldenrod, olive to AA)</pre>
195+
<pre class="lang-css">contrast-color(wheat vs bisque, darkgoldenrod, olive to AA)</pre>
196196

197197
The calculation is as follows:
198198
* the relative luminances and contrast ratios are the same as the previous example.
@@ -209,7 +209,7 @@ Selecting the most contrasting color: the ''color-contrast()'' function {#colorc
209209
foo {
210210
--bg: hsl(200 50% 80%);
211211
--purple-in-hsl: hsl(300 100% 25%);
212-
color: color-contrast(var(--bg) vs hsl(200 83% 23%), purple, var(--purple-in-hsl));
212+
color: contrast-color(var(--bg) vs hsl(200 83% 23%), purple, var(--purple-in-hsl));
213213
}
214214
</pre>
215215

@@ -239,14 +239,14 @@ Selecting the most contrasting color: the ''color-contrast()'' function {#colorc
239239
<h2 id='resolving-color-values'>
240240
Resolving <<color>> Values</h2>
241241

242-
<h3 id="resolving-contrast">Resolving ''color-contrast()'' values</h3>
242+
<h3 id="resolving-contrast">Resolving ''contrast-color()'' values</h3>
243243

244244
If all <<color>> parameters resolve
245245
to the corresponding colors in their respective color spaces,
246246
the computed value is the winning color
247247
resolved according to [[css-color-4#resolving-color-values]].
248248
Otherwise (if ''currentColor'' was used in the function),
249-
the computed value is the ''color-contrast()'' function
249+
the computed value is the ''contrast-color()'' function
250250
with each <<color>> parameter resolved according to [[css-color-4#resolving-color-values]],
251251
and the keywords ''AA'', ''AA-large'', ''AAA'', ''AAA-large'' replaced with their corresponding numeric value,
252252
thus preserving inheritance into child elements.
@@ -255,7 +255,7 @@ Selecting the most contrasting color: the ''color-contrast()'' function {#colorc
255255
For example, given the value
256256

257257
<pre class="lang-css">
258-
color-contrast(rgb(179 213 230) vs cadetblue, hsl(200 83% 23%) to AA)
258+
contrast-color(rgb(179 213 230) vs cadetblue, hsl(200 83% 23%) to AA)
259259
</pre>
260260

261261
the contrast with cadetblue is <strong>1.97</strong>
@@ -276,13 +276,13 @@ Selecting the most contrasting color: the ''color-contrast()'' function {#colorc
276276
the value
277277

278278
<pre class="lang-css">
279-
color-contrast(currentColor vs hsl(200 83% 23%), purple to AA)
279+
contrast-color(currentColor vs hsl(200 83% 23%), purple to AA)
280280
</pre>
281281

282282
has the computed value
283283

284284
<pre class="lang-css">
285-
color-contrast(currentColor vs rgb(10 75 107), rgb(128 0 128) to 4.5)
285+
contrast-color(currentColor vs rgb(10 75 107), rgb(128 0 128) to 4.5)
286286
</pre>
287287

288288
</div>
@@ -304,7 +304,7 @@ Serialization {#serial}
304304
This section extends [[css-color-4#serializing-color-values]]
305305
to add serialization of the
306306
results of the
307-
''color-contrast()'' function.
307+
''contrast-color()'' function.
308308

309309
In this section, the strings used in the specification and the corresponding characters are as follows.
310310

@@ -344,10 +344,10 @@ if the alpha of the result is exactly 1,
344344
it is omitted from the serialization;
345345
an implicit value of 1 (fully opaque) is the default.
346346

347-
Serializing color-contrast() {#serial-color-contrast}
347+
Serializing contrast-color() {#serial-contrast-color}
348348
-----------------------------------------------------
349349

350-
The serialization of the result of a ''color-contrast()'' function
350+
The serialization of the result of a ''contrast-color()'' function
351351
is a <<color>>,
352352
as defined in [[css-color-4#serializing-color-values]].
353353
The form used
@@ -366,14 +366,14 @@ is the same as that specified in
366366

367367
<div class="example">
368368
The winner of this contrast choice
369-
<pre>color-contrast(wheat vs olive, sienna, maroon)</pre>
369+
<pre>contrast-color(wheat vs olive, sienna, maroon)</pre>
370370
is maroon,
371371
so the result is serialized as
372372
<span class="swatch" style="--color: maroon"></span>
373373
"rgb(128 0 0)".
374374

375375
While the winner of
376-
<pre>color-contrast(wheat vs color(prophoto-rgb 0.4 0.4 0.2), color(display-p3 0.45 0.08 0.05))</pre>
376+
<pre>contrast-color(wheat vs color(prophoto-rgb 0.4 0.4 0.2), color(display-p3 0.45 0.08 0.05))</pre>
377377
is color(display-p3 0.45 0.08 0.05),
378378
so the result is serialized as
379379
<span class="swatch" style="--color: rgb(49.277% 0.414% 0.524%)"></span>
@@ -425,7 +425,7 @@ Changes {#changes}
425425
<h3 id='changes-from-5'>
426426
Changes from Colors 5</h3>
427427

428-
The new ''color-contrast()'' function allows one of a list of colors to be chosen,
428+
The new ''contrast-color()'' function allows one of a list of colors to be chosen,
429429
based on the WCAG 2.1 contrast with a specified color.
430430

431431
<!--

0 commit comments

Comments
 (0)