Skip to content

Commit a431644

Browse files
committed
[css-color-5] Remove adjusters from color-mix() and simplify grammar
1 parent d384477 commit a431644

File tree

1 file changed

+10
-64
lines changed

1 file changed

+10
-64
lines changed

css-color-5/Overview.bs

Lines changed: 10 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -119,74 +119,17 @@ Mixing colors: the ''color-mix()'' function {#color-mix}
119119
in a given [=colorspace=],
120120
by a specified amount.
121121

122-
Multiple color-adjusters can be specified.
123-
124122

125123
<pre class='prod'>
126-
<dfn>color-mix()</dfn> = color-mix([ in <<colorspace>> ]?, <<mix-component>>#{2})
124+
<dfn>color-mix()</dfn> = color-mix([ in <<colorspace>> ]?, <<color>>{2} [ <<percentage>> ]?)
127125
</pre>
128126

129-
<pre class='prod'>
130-
<dfn>&lt;mix-component></dfn> = <<color>> [ <<percentage>> | <<color-adjuster>>+ ]?
131-
</pre>
132-
133-
134-
<pre class='prod'>
135-
<dfn>&lt;color-adjuster></dfn> = [ [
136-
<<srgb-adjuster>> | <<hsl-adjuster>> | <<hwb-adjuster>>
137-
| <<xyz-adjuster>> | <<lab-adjuster>> | <<lch-adjuster>>
138-
] | alpha ] <<percentage>>?
139-
<dfn>&lt;srgb-adjuster></dfn> = red || green || blue
140-
<dfn>&lt;hsl-adjuster></dfn> = <<hue-adjuster>> || saturation || lightness
141-
<dfn>&lt;hwb-adjuster></dfn> = <<hue-adjuster>> || whiteness || blackness
142-
<dfn>&lt;xyz-adjuster></dfn> = x || y || z
143-
<dfn>&lt;lab-adjuster></dfn> = lightness || a || b
144-
<dfn>&lt;lch-adjuster></dfn> = lightness || chroma || <<hue-adjuster>>
145-
<dfn>&lt;hue-adjuster></dfn> = hue [shorter | longer | increasing | decreasing | specified ]?
146-
</pre>
147-
148-
Arguments are normalized as follows:
149-
150-
1. When a percentage is specified without any [=color-adjuster=]s,
151-
it is expanded to all adjusters available for the given [=colorspace=] plus alpha.
152-
2. If a percentage is omitted and there are no adjusters present on any color arguments,
153-
it defaults to 50% (an equal mix of the two colors).
154-
3. Adjusters that are not present on a color default to 0% (i.e. the corresponding components are taken from the other color).
155-
4. Adjusters that are only present on one of the colors default to <code>100% - <i>p</i></code> on the second color,
156-
where <i>p</i> is the percentage of the corresponding adjuster in the other color.
157-
5. If the sum of corresponding adjusters across all colors is not 100%, percentages are scaled proportionally so that the sum is exactly 100%.
158-
159-
Issue: Do missing adjusters default to 0% everywhere, or only in the second color?
160-
If the former, we can end up with adjusters that sum to 0% pretty easily.
161-
162-
The meaning of the adjusters is defined by colorspace.
163-
For example, if the [=colorspace=] is [=hsl=],
164-
hue means the HSL hue, which is not the same as the LCH hue;
165-
if the colorspace is [=lch=],
166-
lightness means the LCH Lightness, which is the same as Lab lightness,
167-
but different to the HSL Lightness.
168-
169-
Only the [=color-adjuster=]s defined for a given [=colorspace=] are available.
170-
For example, it is not possible to use the HWB [=whiteness=] adjuster unless the colorspace is [=hwb=].
171-
The alpha adjuster is available on any [=colorspace=].
127+
If a percentage is omitted, it defaults to 50% (an equal mix of the two colors).
172128

173129
If the specified colorspace has a smaller gamut
174130
than the one in which the color to be adjusted is specified,
175131
gamut mapping will occur.
176132

177-
Note: not all [=color-adjuster=]s are equally useful.
178-
Adjustments in LCH are the most useful, which is why it is the default.
179-
Adjustments on the a and b axes are rarely needed.
180-
Adjustments in the srgb-related spaces (srgb itself, hsl, hwb)
181-
are provided mainly for backward compatibility
182-
with the sorts of adjustments currently done in CSS preprocessors.
183-
Adjusting the individual x, y and z channels will produce significant hue shifts;
184-
however, adjusting all three channels together is useful
185-
and will lighten or darken the color.
186-
187-
The [=hue-adjuster=] takes optional keywords, to specify the [[css-color-4#hue-interpolation]] algorithm.
188-
If no keyword is specified, it is as if ''shorter'' were specified.
189-
190133
<div class="example">
191134
This example produces a mixture of 40% <span class="swatch" style="--color: peru"></span> peru
192135
and 60% <span class="swatch" style="--color: lightgoldenrod"></span> lightgoldenrod.
@@ -227,7 +170,7 @@ If no keyword is specified, it is as if ''shorter'' were specified.
227170
keeps the intermediate colors
228171
as saturated as the endpoint colors.
229172

230-
<pre class="lang-css">color-mix(teal 65%, olive);</pre>
173+
<pre class="lang-css">color-mix(in lch, teal 65%, olive);</pre>
231174

232175
<figure>
233176
<img src="images/CH-mixing3.svg" style="width: 50vmin">
@@ -251,10 +194,8 @@ If no keyword is specified, it is as if ''shorter'' were specified.
251194
* which is a slightly-blueish green: <span class="swatch" style="--color: rgb(7.7377% 52.5730% 37.3213%)"></span> rgb(7.7377% 52.5730% 37.3213%)
252195
</div>
253196

254-
Instead of mixing all channels equally, color-adjusters can be used
255-
to only mix certain channels. The unmixed channels in the result
256-
are copied across from the <em>first</em> color.
257-
197+
<!--
198+
Let's move this example to the appropriate section when we have the new syntax for making these low-level adjustments
258199
<div class="example">
259200
This example produces the mixture of a deep green and a sky blue,
260201
in ''lch()'' colorspace (the default),
@@ -396,6 +337,7 @@ are copied across from the <em>first</em> color.
396337

397338
This example demonstrates that not all colors which can be mixed, can be displayed on current devices.
398339
</div>
340+
-->
399341

400342
<!--
401343
<img src="images/mix_red_yellow_lightness30.png" alt="Result of color-mix(red, yellow, lightness(30%)" />
@@ -928,6 +870,10 @@ Changes {#changes}
928870
<h3 id="changes-20200303">Since the <a href="https://www.w3.org/TR/2020/WD-css-color-5-20200303/">FPWD of 10 June 2020</a></h3>
929871

930872
<ul>
873+
<!--
874+
<li>Added `in` keyword before <<colorspace>> tokens in functions</li>
875+
<li>Removed adjusters from color-mix</li>
876+
-->
931877
<!-- to 28 Jan 2021 -->
932878
<!-- removed interpolation section changes, added to Color 4 -->
933879
<!-- to 5 Jan 2021 -->

0 commit comments

Comments
 (0)