Skip to content

Commit 410b272

Browse files
committed
[css-color-4] add hue interpolation example
1 parent c14215d commit 410b272

1 file changed

Lines changed: 25 additions & 2 deletions

File tree

css-color-4/Overview.bs

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4432,7 +4432,7 @@ Interpolating with alpha</h3>
44324432
is divided by the interpolated alpha value.
44334433

44344434
<div class="example" id="ex-premultiplied-srgb">
4435-
For example, to interpolate the two sRGB colors
4435+
For example, to interpolate, in the sRGB colorspace, the two sRGB colors
44364436
<span class="swatch" style="--color: rgb(24%, 12%, 98%, 0.4)"></span> rgb(24% 12% 98% / 0.4)
44374437
and
44384438
<span class="swatch" style="--color: rgb(62% 26% 64% / 0.6)"></span> rgb(62% 26% 64% / 0.6)
@@ -4450,7 +4450,7 @@ Interpolating with alpha</h3>
44504450
</div>
44514451

44524452
<div class="example" id="ex-premultiplied-lab">
4453-
To interpolate two colors in lab
4453+
To interpolate, in the Lab colorspace, the two colors
44544454
<span class="swatch" style="--color: rgb(76%, 62%, 03%, 0.4)"></span> rgb(76% 62% 03% / 0.4)
44554455
and
44564456
<span class="swatch" style="--color: rgb(91.56%, 3.87%, 74.09%, 0.6)"></span> color(display-p3 0.84 0.19 0.72 / 0.6)
@@ -4469,6 +4469,29 @@ Interpolating with alpha</h3>
44694469
when premultiplication is undone.
44704470
</div>
44714471

4472+
<div class="example" id="ex-premultiplied-lab">
4473+
To interpolate, in the chroma-preserving LCH colorspace, the same two colors
4474+
<span class="swatch" style="--color: rgb(76%, 62%, 03%, 0.4)"></span> rgb(76% 62% 03% / 0.4)
4475+
and
4476+
<span class="swatch" style="--color: rgb(91.56%, 3.87%, 74.09%, 0.6)"></span> color(display-p3 0.84 0.19 0.72 / 0.6)
4477+
they are first converted to LCH
4478+
<span class="swatch" style="--color: rgb(76%, 62%, 03%, 0.4)"></span> lch(66.93% 68.79 85.94 / 0.4)
4479+
<span class="swatch" style="--color: rgb(91.56%, 3.87%, 74.09%, 0.6)"></span> lch(53.5% 89.35 337.7 / 0.6)
4480+
then the L and C coordinates (but not H) are premultiplied before interpolation
4481+
[26.771% 27.516 85.94]
4482+
and
4483+
[32.102% 53.61 337.7].
4484+
4485+
The midpoint of linearly interpolating these,
4486+
along the shorter hue arc (the default) would be
4487+
[29.4365% 40.563 63.64]
4488+
which, with an alpha value of 0.5,
4489+
is lch(58.873% 81.126 127.28) / 0.5)
4490+
when premultiplication is undone. This is within the display-p3 gamut, at color(display-p3 0.3535 0.6271 0.1369 / 0.5) but outside sRGB; the closest in-gamut color is
4491+
<span class="swatch oog" style="--color: rgb(87.604%, 38.956%, 51.753%, 0.5)"></span> rgb(23.92% 63.55% 0% / 0.5)
4492+
4493+
</div>
4494+
44724495
Issue(445):
44734496

44744497
<h3 id="hue-interpolation">

0 commit comments

Comments
 (0)