@@ -4863,7 +4863,7 @@ Hue Interpolation</h3>
4863
4863
4864
4864
For color functions with a hue angle (LCH, HSL, HWB etc), there are multiple ways to interpolate.
4865
4865
As arcs greater than 360° are rarely desirable,
4866
- by default hue angles are fixed up prior to interpolation
4866
+ hue angles are fixed up prior to interpolation
4867
4867
so that per-component interpolation is done over less than 360°, often less than 180°.
4868
4868
4869
4869
Host syntax can specify any of the following algorithms for hue interpolation
@@ -4887,12 +4887,25 @@ Hue Interpolation</h3>
4887
4887
</wpt>
4888
4888
4889
4889
Note: As a reminder,
4890
- if the interpolating colors were not already in the specified interpolation syntax ,
4890
+ if the interpolating colors were not already in the specified interpolation color space ,
4891
4891
then converting them will turn any [=powerless components=] into [=missing components=] .
4892
4892
4893
4893
<h4 id="hue-shorter">
4894
4894
<dfn export>shorter</dfn></h4>
4895
4895
4896
+ Hue angles are interpolated to take the <em> shorter</em> of the two arcs
4897
+ between the starting and ending hues.
4898
+
4899
+ <div class="example" id="ex-shorter">
4900
+ For example, the midpoint when interpolating in Oklch from a red
4901
+ <span class="swatch" style="--color: rgb(93.22% 7.98% 0.485%)"></span> oklch(0.6 0.24 30) to a yellow
4902
+ <span class="swatch" style="--color: rgb(89.07% 72.28% 19.23%)"></span> oklch(0.8 0.15 90)
4903
+ would be at a hue angle of (30 + 90) / 2 = 60 degrees,
4904
+ along the shorter arc between the two colors,
4905
+ giving a deep orange
4906
+ <span class="swatch" style="--color: rgb(87.66% 51.96% 0%)"></span> oklch(0.7 0.195 60)
4907
+ </div>
4908
+
4896
4909
Angles are adjusted so that |θ₂ - θ₁| ∈ [-180, 180] . In pseudo-Javascript:
4897
4910
<pre>
4898
4911
if (θ₂ - θ₁ > 180) {
@@ -4906,6 +4919,19 @@ Hue Interpolation</h3>
4906
4919
<h4 id="hue-longer">
4907
4920
<dfn export>longer</dfn></h4>
4908
4921
4922
+ Hue angles are interpolated to take the <em> longer</em> of the two arcs
4923
+ between the starting and ending hues.
4924
+
4925
+ <div class="example" id="ex-longer">
4926
+ For example, the midpoint when interpolating in Oklch from a red
4927
+ <span class="swatch" style="--color: rgb(93.22% 7.98% 0.485%)"></span> oklch(0.6 0.24 30) to a yellow
4928
+ <span class="swatch" style="--color: rgb(89.07% 72.28% 19.23%)"></span> oklch(0.8 0.15 90)
4929
+ would be at a hue angle of (30 + 360 + 90) / 2 = 240 degrees,
4930
+ along the longer arc between the two colors,
4931
+ giving a sky blue
4932
+ <span class="swatch" style="--color: rgb(0% 66.25% 100%)"></span> oklch(0.7 0.195 240)
4933
+ </div>
4934
+
4909
4935
Angles are adjusted so that |θ₂ - θ₁| ∈ {(-360, -180], [180, 360)}. In pseudo-Javascript:
4910
4936
<pre>
4911
4937
if (0 < θ₂ - θ₁ < 180) {
@@ -4919,6 +4945,33 @@ Hue Interpolation</h3>
4919
4945
<h4 id="hue-increasing">
4920
4946
<dfn export>increasing</dfn></h4>
4921
4947
4948
+ Hue angles are interpolated so that,
4949
+ as they progress from the first color to the second,
4950
+ the angle is always <em> increasing</em> .
4951
+
4952
+ Depending on the difference between the two angles,
4953
+ this will either look the same as <em> shorter</em> or as <em> longer.</em>
4954
+ However, if one of the hue angles is being animated,
4955
+ and the hue angle difference passes through 180 degrees,
4956
+ the interpolation will not flip to the other arc.
4957
+
4958
+ <div class="example" id="ex-increasing">
4959
+ For example, the midpoint when interpolating in Oklch from a deep brown
4960
+ <span class="swatch" style="--color: rgb(57.92% 29.44% 25.11%)"></span> oklch(0.5 0.1 30) to a turquoise
4961
+ <span class="swatch" style="--color: rgb(26.29% 69.89% 67.49%)"></span> oklch(0.7 0.1 190)
4962
+ would be at a hue angle of (30 + 190) / 2 = 110 degrees,
4963
+ giving a khaki
4964
+ <span class="swatch" style="--color: rgb(51.73% 52.26% 22.03%)"></span> oklch(0.6 0.1 110).
4965
+
4966
+ However, if the hue of second color is animated to
4967
+ <span class="swatch" style="--color: rgb(33.09% 66.63% 81.81%)"></span> oklch(0.7 0.1 230),
4968
+ the midpoint of the interpolation will be (30 + 230) / 2 = 130 degrees,
4969
+ continuing in the same increasing direction,
4970
+ giving another green
4971
+ <span class="swatch" style="--color: rgb(42.44% 54.95% 28.93%)"></span> oklch(0.6 0.1 130)
4972
+ rather than flipping to the opponent color part-way through the animation.
4973
+ </div>
4974
+
4922
4975
Angles are adjusted so that |θ₂ - θ₁| ∈ [0, 360). In pseudo-Javascript:
4923
4976
<pre>
4924
4977
if (θ₂ < θ₁) {
@@ -4929,6 +4982,33 @@ Hue Interpolation</h3>
4929
4982
<h4 id="hue-decreasing">
4930
4983
<dfn export>decreasing</dfn></h4>
4931
4984
4985
+ Hue angles are interpolated so that,
4986
+ as they progress from the first color to the second,
4987
+ the angle is always <em> decreasing</em> .
4988
+
4989
+ Depending on the difference between the two angles,
4990
+ this will either look the same as <em> shorter</em> or as <em> longer.</em>
4991
+ However, if one of the hue angles is being animated,
4992
+ and the hue angle difference passes through 180 degrees,
4993
+ the interpolation will not flip to the other arc.
4994
+
4995
+ <div class="example" id="ex-decreasing">
4996
+ For example, the midpoint when interpolating in Oklch from a deep brown
4997
+ <span class="swatch" style="--color: rgb(57.92% 29.44% 25.11%)"></span> oklch(0.5 0.1 30) to a turquoise
4998
+ <span class="swatch" style="--color: rgb(26.29% 69.89% 67.49%)"></span> oklch(0.7 0.1 190)
4999
+ would be at a hue angle of (30 + 360 + 190) / 2 = 290 degrees,
5000
+ giving a purple
5001
+ <span class="swatch" style="--color: rgb(49.98% 46.03% 72.08%)"></span> oklch(0.6 0.1 290).
5002
+
5003
+ However, if the hue of second color is animated to
5004
+ <span class="swatch" style="--color: rgb(33.09% 66.63% 81.81%)"></span> oklch(0.7 0.1 230),
5005
+ the midpoint of the interpolation will be (30 +360 + 230) / 2 = 310 degrees,
5006
+ continuing in the same decreasing direction,
5007
+ giving another purple
5008
+ <span class="swatch" style="--color: rgb(57.47% 43.44% 67.8%)"></span> oklch(0.6 0.1 310)
5009
+ rather than flipping to the opponent color part-way through the animation.
5010
+ </div>
5011
+
4932
5012
Angles are adjusted so that |θ₂ - θ₁| ∈ (-360, 0]. In pseudo-Javascript:
4933
5013
<pre>
4934
5014
if (θ₁ < θ₂) {
0 commit comments