Skip to content

Commit 81da168

Browse files
committed
[css-color] Define device-cmyk().
1 parent e960586 commit 81da168

2 files changed

Lines changed: 94 additions & 15 deletions

File tree

css-color/Overview.html

Lines changed: 49 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
</a></p>
4141
<h1 class="p-name no-ref" id=title>CSS Color Module Level 4</h1>
4242
<h2 class="no-num no-toc no-ref heading settled heading" id=subtitle><span class=content>Editor’s Draft,
43-
<span class=dt-updated><span class=value-title title=20130923>23 September 2013</span></span></span></h2>
43+
<span class=dt-updated><span class=value-title title=20130924>24 September 2013</span></span></span></h2>
4444
<div data-fill-with=spec-metadata><dl><dt>This version:<dd><a class=u-url href=http://dev.w3.org/csswg/css-color/>http://dev.w3.org/csswg/css-color/</a><dt>Editor’s Draft:<dd><a href=http://dev.w3.org/csswg/css-color/>http://dev.w3.org/csswg/css-color/</a>
4545
<dt>Feedback:</dt>
4646
<dd><a href="mailto:www-style@w3.org?subject=%5Bcss-color%5D%20feedback">www-style@w3.org</a>
@@ -1698,12 +1698,52 @@ <h2 class="heading settled heading" data-level=6 id=grays><span class=secno>6 </
16981698

16991699

17001700
<h2 class="heading settled heading" data-level=7 id=cmyk-colors><span class=secno>7 </span><span class=content>
1701-
CMYK Colors: the <span class=css data-link-type=maybe title=device-cmyk()>device-cmyk()</span> function</span><a class=self-link href=#cmyk-colors></a></h2>
1701+
CMYK Colors: the <a class=css data-link-type=maybe href=#funcdef-device-cmyk title=device-cmyk()>device-cmyk()</a> function</span><a class=self-link href=#cmyk-colors></a></h2>
17021702

1703-
<p class=issue id=issue-84e118fb><a class=self-link href=#issue-84e118fb></a>
1704-
Import the <span class=css data-link-type=maybe title=device-cmyk()>device-cmyk()</span> definition from GCPM,
1705-
filling in the spec details we hammered out at the Paris 2013 F2F.
1703+
<p> While screens typically display colors directly with RGB pixels,
1704+
printers often represent colors in different ways.
1705+
In particular, one of the most common print-based ways of representing colors is with CMYK:
1706+
a combination of cyan, magenta, yellow, and black.
1707+
The <a class=css data-link-type=maybe href=#funcdef-device-cmyk title=device-cmyk()>device-cmyk()</a> function allows authors to specify a color in this way:
17061708

1709+
<pre class=prod> <dfn class=css-code data-dfn-type=function data-export="" id=funcdef-device-cmyk title=device-cmyk()>device-cmyk()<a class=self-link href=#funcdef-device-cmyk></a></dfn> = device-cmyk( <a class="production css-code" data-link-type=type href=#typedef-cmyk-components title="<cmyk-components>">&lt;cmyk-components&gt;</a> [, <a class="production css-code" data-link-type=type href=#typedef-alpha-value title="<alpha-value>">&lt;alpha-value&gt;</a>]? [, <a class="production css-code" data-link-type=type href=#typedef-color title="<color>">&lt;color&gt;</a> ]? )
1710+
<dfn class=css-code data-dfn-type=type data-export="" id=typedef-cmyk-components>&lt;cmyk-components&gt;<a class=self-link href=#typedef-cmyk-components></a></dfn> = <a class="production css-code" data-link-type=type href=#typedef-cmyk-component title="<cmyk-component>">&lt;cmyk-component&gt;</a>, <a class="production css-code" data-link-type=type href=#typedef-cmyk-component title="<cmyk-component>">&lt;cmyk-component&gt;</a>, <a class="production css-code" data-link-type=type href=#typedef-cmyk-component title="<cmyk-component>">&lt;cmyk-component&gt;</a>, <a class="production css-code" data-link-type=type href=#typedef-cmyk-component title="<cmyk-component>">&lt;cmyk-component&gt;</a>
1711+
<dfn class=css-code data-dfn-type=type data-export="" id=typedef-cmyk-component>&lt;cmyk-component&gt;<a class=self-link href=#typedef-cmyk-component></a></dfn> = <a class="production css-code" data-link-type=type href=http://dev.w3.org/csswg/css-values-3/#number-value title="<number>">&lt;number&gt;</a> | <a class="production css-code" data-link-type=type href=http://dev.w3.org/csswg/css-values-3/#percentage-value title="<percentage>">&lt;percentage&gt;</a>
1712+
</pre>
1713+
<p> The arguments of the <a class=css data-link-type=maybe href=#funcdef-device-cmyk title=device-cmyk()>device-cmyk()</a> function specify the cyan, magenta, yellow, and black components, in order,
1714+
as a number between 0 and 1 or a percentage between 0% and 100%.
1715+
These two usages are equivalent, and map to each other linearly.
1716+
Values less than 0 or 0%, or greater than 1 or 100%,
1717+
are not invalid;
1718+
instead, they are clamped to 0/0% or 1/100%.
1719+
1720+
<p> The fifth argument specifies the alpha channel of the color.
1721+
It’s interpreted identically to the fourth argument of the <a class=css data-link-type=maybe href=#funcdef-rgba title=rgba()>rgba()</a> function.
1722+
If omitted, it defaults to <span class=css data-link-type=maybe title=100%>100%</span>.
1723+
1724+
<p> The sixth argument specifies the fallback color,
1725+
used when the user agent doesn’t know how to accurately transform the CMYK color to RGB.
1726+
If omitted, it defaults to an RGBA color calculated as follows:
1727+
1728+
<p> <ul>
1729+
<li><code>red = 1.0 - min(1.0, cyan + black)</code>
1730+
<li><code>green = 1.0 - min(1.0, magenta + black)</code>
1731+
<li><code>blue = 1.0 - min(1.0, yellow + black)</code>
1732+
<li>Alpha remains as specified.
1733+
</ul>
1734+
1735+
<p> Typically, print-based applications will actually store the used colors as CMYK,
1736+
and send them to the printer in that form.
1737+
Unfortunately, CSS cannot do that;
1738+
various CSS features require an RGB color,
1739+
so that compositing/blending/etc. can be done.
1740+
As such, CMYK colors must be converted to an equivalent RGB color.
1741+
This is not trivial, like the conversion from HSL or HWB to RGB;
1742+
the precise conversion depends on the precise characteristics of the output device.
1743+
1744+
<p> If the user agent has information about the output device such that it believes it can accurately convert the CMYK color to a correct RGB color,
1745+
the computed value of the <a class=css data-link-type=maybe href=#funcdef-device-cmyk title=device-cmyk()>device-cmyk()</a> function must be that RGBA color.
1746+
Otherwise, the computed value must be the fallback color.
17071747

17081748

17091749
<h2 class="heading settled heading" data-level=8 id=modifying-colors><span class=secno>8 </span><span class=content>
@@ -2633,6 +2673,8 @@ <h2 class="no-num no-ref heading settled heading" id=index><span class=content>
26332673
<li>CaptionText, <a href=#captiontext title="section Unnumbered section">Unnumbered section</a>
26342674
<li>chartreuse (value), <a href=#valuedef-chartreuse title="section 3.3">3.3</a>
26352675
<li>chocolate (value), <a href=#valuedef-chocolate title="section 3.3">3.3</a>
2676+
<li>&lt;cmyk-component&gt;, <a href=#typedef-cmyk-component title="section 7">7</a>
2677+
<li>&lt;cmyk-components&gt;, <a href=#typedef-cmyk-components title="section 7">7</a>
26362678
<li>&lt;color&gt;, <a href=#typedef-color title="section 3">3</a>
26372679
<li>color(), <a href=#funcdef-color title="section 8">8</a>
26382680
<li>&lt;color-adjuster&gt;, <a href=#typedef-color-adjuster title="section 8">8</a>
@@ -2665,6 +2707,7 @@ <h2 class="no-num no-ref heading settled heading" id=index><span class=content>
26652707
<li>darkviolet (value), <a href=#valuedef-darkviolet title="section 3.3">3.3</a>
26662708
<li>deeppink (value), <a href=#valuedef-deeppink title="section 3.3">3.3</a>
26672709
<li>deepskyblue (value), <a href=#valuedef-deepskyblue title="section 3.3">3.3</a>
2710+
<li>device-cmyk(), <a href=#funcdef-device-cmyk title="section 7">7</a>
26682711
<li>dimgray (value), <a href=#valuedef-dimgray title="section 3.3">3.3</a>
26692712
<li>dimgrey (value), <a href=#valuedef-dimgrey title="section 3.3">3.3</a>
26702713
<li>dodgerblue (value), <a href=#valuedef-dodgerblue title="section 3.3">3.3</a>
@@ -2843,13 +2886,7 @@ <h2 class="no-num heading settled" id=issues-index><span class=content>Issues In
28432886
</p><a href=#issue-f73c1044></a></div>
28442887

28452888

2846-
<p class=issue>
2847-
Import the <span class=css data-link-type=maybe title=device-cmyk()>device-cmyk()</span> definition from GCPM,
2848-
filling in the spec details we hammered out at the Paris 2013 F2F.
2849-
2850-
2851-
2852-
<a href=#issue-84e118fb></a><div class=issue>
2889+
<div class=issue>
28532890
More possibilities:
28542891

28552892
<p> <ul>

css-color/Overview.src.html

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1635,10 +1635,52 @@ <h2 id='grays'>
16351635
<h2 id='cmyk-colors'>
16361636
CMYK Colors: the ''device-cmyk()'' function</h2>
16371637

1638-
<p class='issue'>
1639-
Import the ''device-cmyk()'' definition from GCPM,
1640-
filling in the spec details we hammered out at the Paris 2013 F2F.
1638+
While screens typically display colors directly with RGB pixels,
1639+
printers often represent colors in different ways.
1640+
In particular, one of the most common print-based ways of representing colors is with CMYK:
1641+
a combination of cyan, magenta, yellow, and black.
1642+
The ''device-cmyk()'' function allows authors to specify a color in this way:
1643+
1644+
<pre class='prod'>
1645+
<dfn>device-cmyk()</dfn> = device-cmyk( <<cmyk-components>> [, <<alpha-value>>]? [, <<color>> ]? )
1646+
<dfn>&lt;cmyk-components></dfn> = <<cmyk-component>>, <<cmyk-component>>, <<cmyk-component>>, <<cmyk-component>>
1647+
<dfn>&lt;cmyk-component></dfn> = <<number>> | <<percentage>>
1648+
</pre>
1649+
1650+
The arguments of the ''device-cmyk()'' function specify the cyan, magenta, yellow, and black components, in order,
1651+
as a number between 0 and 1 or a percentage between 0% and 100%.
1652+
These two usages are equivalent, and map to each other linearly.
1653+
Values less than 0 or 0%, or greater than 1 or 100%,
1654+
are not invalid;
1655+
instead, they are clamped to 0/0% or 1/100%.
1656+
1657+
The fifth argument specifies the alpha channel of the color.
1658+
It's interpreted identically to the fourth argument of the ''rgba()'' function.
1659+
If omitted, it defaults to ''100%''.
1660+
1661+
The sixth argument specifies the fallback color,
1662+
used when the user agent doesn't know how to accurately transform the CMYK color to RGB.
1663+
If omitted, it defaults to an RGBA color calculated as follows:
1664+
1665+
<ul>
1666+
<li><code>red = 1.0 - min(1.0, cyan + black)</code>
1667+
<li><code>green = 1.0 - min(1.0, magenta + black)</code>
1668+
<li><code>blue = 1.0 - min(1.0, yellow + black)</code>
1669+
<li>Alpha remains as specified.
1670+
</ul>
16411671

1672+
Typically, print-based applications will actually store the used colors as CMYK,
1673+
and send them to the printer in that form.
1674+
Unfortunately, CSS cannot do that;
1675+
various CSS features require an RGB color,
1676+
so that compositing/blending/etc. can be done.
1677+
As such, CMYK colors must be converted to an equivalent RGB color.
1678+
This is not trivial, like the conversion from HSL or HWB to RGB;
1679+
the precise conversion depends on the precise characteristics of the output device.
1680+
1681+
If the user agent has information about the output device such that it believes it can accurately convert the CMYK color to a correct RGB color,
1682+
the computed value of the ''device-cmyk()'' function must be that RGBA color.
1683+
Otherwise, the computed value must be the fallback color.
16421684

16431685

16441686
<h2 id='modifying-colors'>

0 commit comments

Comments
 (0)