@@ -61,7 +61,8 @@ Computing a sufficiently contrasting color: the ''contrast-color()'' function {#
61
61
Its syntax is:
62
62
63
63
64
- contrast-color() = contrast-color( <> [ vs <> #{2,} ]? [ to [<> | AA | AA-large | AAA | AAA-large]]? )
64
+ contrast-color() = contrast-color( <> [ vs <> #{2,} ]? [ to <> ]? )
65
+ <> = wcag2([<> | [ aa | aaa ] && large? ])
65
66
66
67
67
68
The only mandatory argument is the first color, which is the color to be contrasted,
@@ -85,12 +86,14 @@ Computing a sufficiently contrasting color: the ''contrast-color()'' function {#
85
86
and the target contrast, if present, is separated from the list
86
87
with the keyword to .
87
88
89
+ The target contrast is specified by providing a function for the algorithm used
90
+ (currently only [WCAG 2.1] (#luminance-contrast) is supported )
91
+ with the contrast ratio as the argument.
88
92
89
-
90
- The keyword AA is equivalent to ''4.5'' ,
91
- AA-large is equivalent to ''3'' ,
92
- AAA is equivalent to ''7'' , and
93
- AAA-large is equivalent to ''4.5'' .
93
+ For ''wcag2()'' , ''aa'' is equivalent to ''4.5'' ,
94
+ ''aa large'' (or ''large aa'' ) is equivalent to ''3'' ,
95
+ ''aaa'' is equivalent to ''7'' ,
96
+ and ''aaa large'' (or ''large aaa'' ) is equivalent to ''4.5'' .
94
97
95
98
96
99
Calculating luminance and WCAG 2.1 contrast
@@ -160,7 +163,7 @@ Computing a sufficiently contrasting color: the ''contrast-color()'' function {#
160
163
https://colorjs.io/notebook/?storage=https%3A%2F%2Fgist.github.com%2Fsvgeesus%2Fec249f376fcecbaa8794f75dbfc1dacf
161
164
-->
162
165
163
- contrast-color(wheat vs bisque, darkgoldenrod, olive, sienna, darkgreen, maroon to
AA )
166
+ contrast-color(wheat vs bisque, darkgoldenrod, olive, sienna, darkgreen, maroon to
wcag2(aa) )
164
167
165
168
The calculation is as follows:
166
169
* wheat (#f5deb3), the background, has relative luminance 0.749
@@ -177,7 +180,7 @@ Computing a sufficiently contrasting color: the ''contrast-color()'' function {#
177
180
178
181
179
182
180
- contrast-color(wheat vs bisque, darkgoldenrod, olive, sienna, darkgreen, maroon to 5.8)
183
+ contrast-color(wheat vs bisque, darkgoldenrod, olive, sienna, darkgreen, maroon to
wcag2( 5.8
) )
181
184
182
185
The calculation is as follows:
183
186
* the relative luminances and contrast ratios are the same as the previous example.
@@ -205,7 +208,7 @@ Computing a sufficiently contrasting color: the ''contrast-color()'' function {#
205
208
whichever has the higher contrast.
206
209
207
210
208
- contrast-color(wheat vs bisque, darkgoldenrod, olive to
AA )
211
+ contrast-color(wheat vs bisque, darkgoldenrod, olive to
wcag2(AA) )
209
212
210
213
The calculation is as follows:
211
214
* the relative luminances and contrast ratios are the same as the previous example.
@@ -268,7 +271,7 @@ Computing a sufficiently contrasting color: the ''contrast-color()'' function {#
268
271
For example, given the value
269
272
270
273
271
- contrast-color(rgb(179 213 230) vs cadetblue, hsl(200 83% 23%) to AA )
274
+ contrast-color(rgb(179 213 230) vs cadetblue, hsl(200 83% 23%) to wcag2(AA) )
272
275
273
276
274
277
the contrast with cadetblue is 1.97
@@ -289,13 +292,13 @@ Computing a sufficiently contrasting color: the ''contrast-color()'' function {#
289
292
the value
290
293
291
294
292
- contrast-color(currentColor vs hsl(200 83% 23%), purple to AA )
295
+ contrast-color(currentColor vs hsl(200 83% 23%), purple to wcag2(AA) )
293
296
294
297
295
298
has the computed value
296
299
297
300
298
- contrast-color(currentColor vs rgb(10 75 107), rgb(128 0 128) to 4.5)
301
+ contrast-color(currentColor vs rgb(10 75 107), rgb(128 0 128) to wcag2( 4.5) )
299
302
300
303
301
304
0 commit comments