Skip to content

Commit 0da5a5a

Browse files
committed
[css-color-4] Draft text for carried forward missing values, w3c#7536
1 parent fc59940 commit 0da5a5a

1 file changed

Lines changed: 95 additions & 8 deletions

File tree

css-color-4/Overview.bs

Lines changed: 95 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4257,7 +4257,7 @@ Color Interpolation</h2>
42574257
Interpolation between <<color>> values
42584258
occurs by first
42594259
converting them to a given color space
4260-
which will be referred to as the 'interpolation space' below,
4260+
which will be referred to as the <dfn export>interpolation color space</dfn> below,
42614261
and then
42624262
linearly interpolating each component of the computed value of the color
42634263
separately.
@@ -4311,7 +4311,7 @@ Color Space for Interpolation</h3>
43114311
</div>
43124312

43134313
Mixing or otherwise combining colors
4314-
has different results depending on the color space used.
4314+
has different results depending on the [=interpolation color space=] used.
43154315
Thus, different color spaces may be more appropriate for each interpolation use case.
43164316

43174317
* In some cases, the result of physically mixing two colored lights is desired.
@@ -4328,7 +4328,7 @@ Color Space for Interpolation</h3>
43284328

43294329
These features are collectively termed the <dfn export>host syntax</dfn>.
43304330
The host syntax should define
4331-
what the default interpolation space should be for each case,
4331+
what the default [=interpolation color space=] should be for each case,
43324332
and optionally provide syntax for authors to override this default.
43334333
If such syntax is part of a property value, it should use a <<color-interpolation-method>> token,
43344334
defined below for easy reference from other specifications.
@@ -4375,7 +4375,7 @@ Color Space for Interpolation</h3>
43754375
for at least one of their colors.
43764376

43774377
If the colors to be interpolated are outside the gamut
4378-
of the interpolation space,
4378+
of the [=interpolation color space=] ,
43794379
then once converted to that space,
43804380
they will contain out of range values.
43814381

@@ -4384,15 +4384,102 @@ Color Space for Interpolation</h3>
43844384
<h3 id="interpolation-missing">
43854385
Interpolating with Missing Components</h3>
43864386

4387-
If a color with a [=missing component=]
4387+
In the course of converting the two colors
4388+
to the [=interpolation color space=],
4389+
any [=missing components=]
4390+
will be replaced with the value 0.
4391+
4392+
Thus, the first stage in interpolating two colors
4393+
is to classify any [=missing components=]
4394+
in the input colors,
4395+
and compare them to the components of the
4396+
[=interpolation color space=].
4397+
If any analogous [=missing components=] are found,
4398+
they will be <strong>carried forward</strong>
4399+
and re-inserted in the converted color
4400+
before linear interpolation takes place.
4401+
4402+
The analogous components are as follows:
4403+
4404+
<table>
4405+
<tr>
4406+
<th>Category</th>
4407+
<th>Components</th>
4408+
</tr>
4409+
<tr>
4410+
<td>Reds</td>
4411+
<td>r,x</td>
4412+
</tr>
4413+
<tr>
4414+
<td>Greens</td>
4415+
<td>g,y</td>
4416+
</tr>
4417+
<tr>
4418+
<td>Blues</td>
4419+
<td>b,z</td>
4420+
</tr>
4421+
<tr>
4422+
<td>Lightness</td>
4423+
<td>L</td>
4424+
</tr>
4425+
<tr>
4426+
<td>Colorfulness</td>
4427+
<td>C, S</td>
4428+
</tr>
4429+
<tr>
4430+
<td>Hue</td>
4431+
<td>H</td>
4432+
</tr>
4433+
</table>
4434+
4435+
Note: for the purposes of this classification,
4436+
the XYZ spaces are considered super-saturated RGB spaces.
4437+
Also, despite Saturation being Lightness-dependent,
4438+
it falls in the same category as Chroma here.
4439+
The Whiteness and Blackness components of HWB
4440+
have no analogs in other color spaces.
4441+
4442+
<div class="example" id="ex-analogous-hue">
4443+
For example, if these two colors
4444+
are to be interpolated in OKLCH,
4445+
the missing hue in the CIE LCH color
4446+
is analogous to the hue component of OKLCH
4447+
and will be carried forward
4448+
while the missing blue component
4449+
in the second color
4450+
is not analogous to any OKLCH component
4451+
and will not be carried forward:
4452+
4453+
<pre>
4454+
<span class="swatch" style="--color: rgb(46.647% 46.628% 46.633%)"></span> lch(50% 0.02 none)</span>
4455+
<span class="swatch" style="--color: rgb(71.559% 49.813% 0%)"></span> color(display-p3 0.7 0.5 none)</span>
4456+
</pre>
4457+
4458+
which convert to
4459+
4460+
<pre>
4461+
<span class="swatch" style="--color: rgb(46.647% 46.628% 46.633%)"></span> oklch(56.897% 0.0001 0)</span>
4462+
<span class="swatch" style="--color: rgb(71.559% 49.813% 0%)"></span> oklch(63.612% 0.1522 78.748)</span>
4463+
</pre>
4464+
4465+
and with carried forward [=missing component=] re-inserted,
4466+
the two colors to be interpolated are:
4467+
4468+
<pre>
4469+
<span class="swatch" style="--color: rgb(46.647% 46.628% 46.633%)"></span> oklch(56.897% 0.0001 none)</span>
4470+
<span class="swatch" style="--color: rgb(71.559% 49.813% 0%)"></span> oklch(63.612% 0.1522 78.748)</span>
4471+
</pre>
4472+
</div>
4473+
4474+
If a color with a carried forward [=missing component=]
43884475
is interpolated
43894476
with another color
43904477
which is not missing that component,
43914478
the [=missing component=]
43924479
is treated as having
4393-
the other color's component value.
4480+
the <em>other color's</em> component value.
43944481

4395-
<div class="example" id="ex-">
4482+
<div class="example" id="ex-oklch-missing-hue">
43964483
For example, if these two colors are interpolated,
43974484
the second of which has a missing hue:
43984485

@@ -4412,7 +4499,7 @@ Interpolating with Missing Components</h3>
44124499

44134500
<pre>
44144501
<span class="swatch" style="--color: rgb(86.6% 62.7% 86.7%)"></span> oklch(78.3% 0.108 326.5)
4415-
<span class="swatch" style="--color: rgb(48.4% 0% 22.8%)"></span>oklch(39.2% 0.4 0)
4502+
<span class="swatch" style="--color: rgb(48.4% 0% 22.8%)"></span> oklch(39.2% 0.4 0)
44164503
</pre>
44174504
</div>
44184505

0 commit comments

Comments
 (0)