Skip to content

Commit 5f8c1c0

Browse files
committed
[css-color-5] second premul example
1 parent 57a344c commit 5f8c1c0

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

css-color-5/Overview.bs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -806,13 +806,34 @@ is divided by the interpolated alpha value.
806806
and
807807
[37.2% 15.6% 38.4%]
808808
before interpolation.
809+
809810
The midpoint of linearly interpolating these colors
810811
would be [23.4% 10.2% 38.8%]
811812
which, with an alpha value of 0.5,
812813
is <span class="swatch" style="--color: rgb(46.8%, 21.4%, 77.6%, 0.5)"></span> rgb(46.8% 20.4% 77.6% / 0.5)
813814
when premultiplication is undone.
814815
</div>
815816

817+
<div class="example" id="ex-premultiplied-lab">
818+
To interpolate two colors in lab
819+
<span class="swatch" style="--color: rgb(76%, 62%, 03%, 0.4)"></span> rgb(76% 62% 03% / 0.4)
820+
and
821+
<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)
822+
they are first converted to lab
823+
<span class="swatch" style="--color: rgb(76%, 62%, 03%, 0.4)"></span> lab(66.927% 4.873 68.622 / 0.4)
824+
<span class="swatch" style="--color: rgb(91.56%, 3.87%, 74.09%, 0.6)"></span> lab(53.503% 82.672 -33.901 / 0.6)
825+
then the L, a and b coordinates are premultiplied before interpolation
826+
[26.771% 1.949 27.449]
827+
and
828+
[32.102% 49.603 -20.341].
829+
830+
The midpoint of linearly interpolating these would be
831+
[29.4365% 25.776 3.554]
832+
which, with an alpha value of 0.5,
833+
is <span class="swatch" style="--color: rgb(87.604%, 38.956%, 51.753%, 0.5)"></span> lab(58.873% 51.552 7.108) / 0.5)
834+
when premultiplication is undone.
835+
</div>
836+
816837
Issue(445):
817838

818839
Hue interpolation {#hue-interpolation}

0 commit comments

Comments
 (0)