Skip to content

Commit 6a93bd8

Browse files
committed
[css-color-5] Added worked example of color-mix() using device-cmyk fallback color #9555
1 parent 34184a4 commit 6a93bd8

File tree

2 files changed

+96
-0
lines changed

2 files changed

+96
-0
lines changed

css-color-5/Overview.bs

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,60 @@ The choice of mixing color space can have a large effect on the end result.
511511
<span class="swatch oog" style="--color: rgb(72.66% 100% 0%)"></span> color(srgb -0.3387 1.0943 -0.48899)
512512
</div>
513513

514+
<div class="example" id="ex-device-cmyk-mix">
515+
''device-cmyk()'' can be used in ''color-mix()''
516+
but the result will depend on how the implementation
517+
chooses to obtain a computed value.
518+
519+
<!-- detailed calculation is in the file
520+
workings/device-cmyk conversion worked example.txt -->
521+
522+
<pre class="lang-css">
523+
color-mix(in lab, device-cmyk(0.091777 0.043303 0.312816 0.000000) 100%, yellow);
524+
</pre>
525+
526+
Since the first color is at 100%,
527+
the second color is 0% and does not affect the mixed result in any way.
528+
The result is thus the computed value of the first color,
529+
in CIE Lab.
530+
531+
To visualize the result,
532+
let us say that the device CMYK values
533+
are in fact to be printed using SWOP 2006 coated.
534+
535+
* <span class="swatch" style="--color: rgb(98% 89% 75%)"></span>
536+
device-cmyk(0.091777 0.043303 0.312816 0.000000) is
537+
<span class="swatch" style="--color: rgb(98% 89% 75%)"></span>
538+
lab(91.44% 4.142 20.52)
539+
540+
Suppose the implementation uses an ICC profile
541+
to obtain ''lab()'' colors,
542+
and in this example a FOGRA39 Coated profile is used:
543+
544+
* <span class="swatch" style="--color: rgb(98% 89% 75%)"></span>
545+
device-cmyk(0.091777 0.043303 0.312816 0.000000) is
546+
<span class="swatch" style="--color: rgb(92.81% 91.34% 75.31%)"></span>
547+
lab(91.840596 -3.559090 20.449159)
548+
* The deltaE 2000 between this and the original printed color
549+
is <strong>8.17</strong> which is clearly visible.
550+
551+
Now suppose another implementation uses
552+
the naive color conversion algorithm,
553+
giving an sRGB result.
554+
555+
* <span class="swatch" style="--color: rgb(98% 89% 75%)"></span>
556+
device-cmyk(0.091777 0.043303 0.312816 0.000000) is
557+
<span class="swatch" style="--color: rgb(90.8223% 95.6697% 68.7184%)"></span>
558+
rgb(90.8223% 95.6697% 68.7184%)
559+
which is
560+
<span class="swatch" style="--color: rgb(90.8223% 95.6697% 68.7184%)"></span>
561+
lab(94.02% -12.31 31.79)
562+
563+
* The deltaE 2000 between this and the original printed color
564+
is <strong>14.3</strong> which is very visible.
565+
566+
</div>
567+
514568
<h3 id="color-mix-with-alpha">
515569
Effect of Non-Unity Alpha on color-mix
516570
</h3>
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
Starting color rgb(98% 89% 75%) is lab(91.44% 4.142 20.52)
2+
3+
(ICC profiles are in css-color-4/ICCprofiles )
4+
5+
Converting to CMYK in swop, xicclu -f b .\SWOP2006_Coated5v2.icc
6+
7+
91.440000 -4.142000 20.520000 [Lab] -> Lut -> 0.091777 0.043303 0.312816 0.000000 [CMYK]
8+
9+
using ICC with coated fogra: xicclu -f f .\Coated_Fogra39L_VIGC_300.icc
10+
11+
0.091777 0.043303 0.312816 0.000000 [CMYK] -> Lut -> 91.840596 -3.559090 20.449159 [Lab]
12+
which is rgb(92.81% 91.34% 75.31%)
13+
14+
let color1 = new Color("lab(91.44% 4.142 20.52)");
15+
let color2 = new Color("lab(91.840596 -3.559090 20.449159)");
16+
17+
color1.deltaE(color2, "2000"); 8.17
18+
19+
lab(91.840596 -3.559090 20.449159) is rgb(92.81% 91.34% 75.31%)
20+
21+
Now using naive algorithm:
22+
23+
0.091777 0.043303 0.312816 0.000000
24+
25+
function naive(cmyk) {
26+
let [cyan, magenta, yellow, black] = cmyk;
27+
let red = 1 - Math.min(1, cyan * (1 - black) + black);
28+
let green = 1 - Math.min(1, magenta * (1 - black) + black);
29+
let blue = 1 - Math.min(1, yellow * (1 - black) + black);…
30+
}
31+
32+
let x = [0.091777, 0.043303, 0.312816, 0.000000]
33+
naive(x); // [ 0.908223, 0.956697, 0.687184 ]
34+
35+
rgb(90.8223% 95.6697% 68.7184%) = lab(94.02% -12.31 31.79)
36+
37+
let color1 = new Color("lab(91.44% 4.142 20.52)");
38+
let color2 = new Color("lab(91.840596 -3.559090 20.449159)");
39+
let color3 = new Color("rgb(90.8223% 95.6697% 68.7184%)");
40+
41+
color1.deltaE(color2, "2000"); // 8.17
42+
color1.deltaE(color3, "2000"); // 14.3

0 commit comments

Comments
 (0)