Skip to content

Commit fbbfcf9

Browse files
SebastianZsvgeesus
authored andcommitted
[css-color-4] Fixed a few issues regarding hue interpolation
1 parent 95a3539 commit fbbfcf9

File tree

1 file changed

+31
-31
lines changed

1 file changed

+31
-31
lines changed

css-color-4/Overview.bs

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1085,12 +1085,12 @@ any achromatic color will have a [=powerless=] hue component.
10851085
to achieve an effect where you only <em>want</em>
10861086
to interpolate certain components of a color.
10871087

1088-
For example, to animate a color to "grayscale", no matter what the color is,
1088+
For example, to interpolate a color to "grayscale", no matter what the color is,
10891089
one can interpolate it with ''oklch(none 0 none)''.
10901090
This will take the hue and lightness from the starting color,
1091-
but animate its chroma down to 0,
1091+
but interpolate its chroma down to 0,
10921092
rendering it into an equal-lightness gray
1093-
with a steady hue across the whole animation.
1093+
with a steady hue across the whole interpolation.
10941094

10951095
Doing this manually would require
10961096
matching the hue and lightness of the starting color explicitly.
@@ -4964,15 +4964,15 @@ Hue Interpolation</h3>
49644964

49654965
<div class="example" id="ex-shorter">
49664966
For example, the midpoint when interpolating in Oklch from a red
4967-
<span class="swatch" style="--color: rgb(93.22% 7.98% 0.485%)"></span>&nbsp;oklch(0.6 0.24 30) to a yellow
4967+
<span class="swatch" style="--color: rgb(93.22% 7.98% 0.485%)"></span>&nbsp;oklch(0.6 0.24 30) to a yellow
49684968
<span class="swatch" style="--color: rgb(89.07% 72.28% 19.23%)"></span>&nbsp;oklch(0.8 0.15 90)
4969-
would be at a hue angle of (30 + 90) / 2 = 60 degrees,
4969+
would be at a hue angle of 30 + (90 - 30) * 0.5 = 60 degrees,
49704970
along the shorter arc between the two colors,
49714971
giving a deep orange
49724972
<span class="swatch" style="--color: rgb(87.66% 51.96% 0%)"></span>&nbsp;oklch(0.7 0.195 60)
49734973
</div>
49744974

4975-
Angles are adjusted so that |θ₂ - θ₁| ∈ [-180, 180]. In pseudo-Javascript:
4975+
Interpolated angles are adjusted so that |θ₂ - θ₁| ∈ [-180, 180]. In pseudo-Javascript:
49764976
<pre>
49774977
if (θ₂ - θ₁ > 180) {
49784978
θ₁ += 360;
@@ -4985,14 +4985,14 @@ Hue Interpolation</h3>
49854985
<h4 id="hue-longer">
49864986
<dfn export>longer</dfn></h4>
49874987

4988-
Hue angles are interpolated to take the <em>longer</em> of the two arcs
4988+
Hue angles are interpolated to take the <em>longer</em> of the two arcs
49894989
between the starting and ending hues.
49904990

49914991
<div class="example" id="ex-longer">
49924992
For example, the midpoint when interpolating in Oklch from a red
49934993
<span class="swatch" style="--color: rgb(93.22% 7.98% 0.485%)"></span>&nbsp;oklch(0.6 0.24 30) to a yellow
49944994
<span class="swatch" style="--color: rgb(89.07% 72.28% 19.23%)"></span>&nbsp;oklch(0.8 0.15 90)
4995-
would be at a hue angle of (30 + 360 + 90) * 0.5 = 240 degrees,
4995+
would be at a hue angle of (30 + 360 + 90) * 0.5 = 240 degrees,
49964996
along the longer arc between the two colors,
49974997
giving a sky blue
49984998
<span class="swatch" style="--color: rgb(0% 66.25% 100%)"></span>&nbsp;oklch(0.7 0.195 240)
@@ -5019,25 +5019,25 @@ Hue Interpolation</h3>
50195019

50205020
Depending on the difference between the two angles,
50215021
this will either look the same as <em>shorter</em> or as <em>longer.</em>
5022-
However, if one of the hue angles is being animated,
5022+
However, if one of the hue angles is being interpolated,
50235023
and the hue angle difference passes through 180 degrees,
50245024
the interpolation will not flip to the other arc.
50255025

50265026
<div class="example" id="ex-increasing">
50275027
For example, the midpoint when interpolating in Oklch from a deep brown
50285028
<span class="swatch" style="--color: rgb(57.92% 29.44% 25.11%)"></span>&nbsp;oklch(0.5 0.1 30) to a turquoise
50295029
<span class="swatch" style="--color: rgb(26.29% 69.89% 67.49%)"></span>&nbsp;oklch(0.7 0.1 190)
5030-
would be at a hue angle of (30 + 190) * 0.5 = 110 degrees,
5030+
would be at a hue angle of (30 + 190) * 0.5 = 110 degrees,
50315031
giving a khaki
50325032
<span class="swatch" style="--color: rgb(51.73% 52.26% 22.03%)"></span>&nbsp;oklch(0.6 0.1 110).
50335033

5034-
However, if the hue of the second color is animated to
5034+
However, if the hue of the second color is interpolated to
50355035
<span class="swatch" style="--color: rgb(33.09% 66.63% 81.81%)"></span>&nbsp;oklch(0.7 0.1 230),
50365036
the midpoint of the interpolation will be (30 + 230) * 0.5 = 130 degrees,
50375037
continuing in the same increasing direction,
50385038
giving another green
50395039
<span class="swatch" style="--color: rgb(42.44% 54.95% 28.93%)"></span>&nbsp;oklch(0.6 0.1 130)
5040-
rather than flipping to the opponent color part-way through the animation.
5040+
rather than flipping to the opponent color part-way through the interpolation.
50415041
</div>
50425042

50435043
Angles are adjusted so that |θ₂ - θ₁| ∈ [0, 360). In pseudo-Javascript:
@@ -5050,34 +5050,34 @@ Hue Interpolation</h3>
50505050
<h4 id="hue-decreasing">
50515051
<dfn export>decreasing</dfn></h4>
50525052

5053-
Hue angles are interpolated so that,
5053+
Hue angles are interpolated so that,
50545054
as they progress from the first color to the second,
50555055
the angle is always <em>decreasing</em>.
50565056
If the angle decreases to 0 it is reset to 360,
50575057
and then continues decreasing.
50585058

5059-
Depending on the difference between the two angles,
5059+
Depending on the difference between the two angles,
50605060
this will either look the same as <em>shorter</em> or as <em>longer.</em>
5061-
However, if one of the hue angles is being animated,
5061+
However, if one of the hue angles is being interpolated,
50625062
and the hue angle difference passes through 180 degrees,
50635063
the interpolation will not flip to the other arc.
50645064

5065-
<div class="example" id="ex-decreasing">
5066-
For example, the midpoint when interpolating in Oklch from a deep brown
5067-
<span class="swatch" style="--color: rgb(57.92% 29.44% 25.11%)"></span>&nbsp;oklch(0.5 0.1 30) to a turquoise
5068-
<span class="swatch" style="--color: rgb(26.29% 69.89% 67.49%)"></span>&nbsp;oklch(0.7 0.1 190)
5069-
would be at a hue angle of (30 + 360 + 190) * 0.5 = 290 degrees,
5070-
giving a purple
5071-
<span class="swatch" style="--color: rgb(49.98% 46.03% 72.08%)"></span>&nbsp;oklch(0.6 0.1 290).
5072-
5073-
However, if the hue of the second color is animated to
5074-
<span class="swatch" style="--color: rgb(33.09% 66.63% 81.81%)"></span>&nbsp;oklch(0.7 0.1 230),
5075-
the midpoint of the interpolation will be (30 +360 + 230) * 0.5 = 310 degrees,
5076-
continuing in the same decreasing direction,
5077-
giving another purple
5078-
<span class="swatch" style="--color: rgb(57.47% 43.44% 67.8%)"></span>&nbsp;oklch(0.6 0.1 310)
5079-
rather than flipping to the opponent color part-way through the animation.
5080-
</div>
5065+
<div class="example" id="ex-decreasing">
5066+
For example, the midpoint when interpolating in Oklch from a deep brown
5067+
<span class="swatch" style="--color: rgb(57.92% 29.44% 25.11%)"></span>&nbsp;oklch(0.5 0.1 30) to a turquoise
5068+
<span class="swatch" style="--color: rgb(26.29% 69.89% 67.49%)"></span>&nbsp;oklch(0.7 0.1 190)
5069+
would be at a hue angle of (30 + 360 + 190) * 0.5 = 290 degrees,
5070+
giving a purple
5071+
<span class="swatch" style="--color: rgb(49.98% 46.03% 72.08%)"></span>&nbsp;oklch(0.6 0.1 290).
5072+
5073+
However, if the hue of the second color is interpolated to
5074+
<span class="swatch" style="--color: rgb(33.09% 66.63% 81.81%)"></span>&nbsp;oklch(0.7 0.1 230),
5075+
the midpoint of the interpolation will be (30 + 360 + 230) * 0.5 = 310 degrees,
5076+
continuing in the same decreasing direction,
5077+
giving another purple
5078+
<span class="swatch" style="--color: rgb(57.47% 43.44% 67.8%)"></span>&nbsp;oklch(0.6 0.1 310)
5079+
rather than flipping to the opponent color part-way through the interpolation.
5080+
</div>
50815081

50825082
Angles are adjusted so that |θ₂ - θ₁| ∈ (-360, 0]. In pseudo-Javascript:
50835083
<pre>

0 commit comments

Comments
 (0)