You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: css-color-5/Overview.bs
+70-1
Original file line number
Diff line number
Diff line change
@@ -713,6 +713,75 @@ When an origin color is present, the following keywords can also be used in this
713
713
</pre>
714
714
</div>
715
715
716
+
Interpolation {#interpolation}
717
+
===================================
718
+
719
+
In general, interpolation between <<color>> values of the same color space occurs by linearly interpolating each component separately.
720
+
721
+
Issue: Should gamut mapping occur before or after interpolation?
722
+
723
+
Issue(4928): How to handle achromatic interpolation?
724
+
725
+
Color space for interpolation {#interpolation-space}
726
+
------------------------------
727
+
728
+
If colors are not in the same color space, they are first converted to LCH and and interpolated as LCH colors.
729
+
Host syntax can override the interpolation color space and specify which color space is used for interpolation.
730
+
731
+
Issue: Should the colors at 0% and 100% be serialized with their original color spaces or converted to the interpolation space?
732
+
733
+
Hue interpolation {#hue-interpolation}
734
+
-------------------
735
+
736
+
For color functions with a hue angle (LCH, HSL, HWB etc), there are multiple ways to interpolate.
737
+
We typically want to avoid arcs over 360, as they are rarely desirable,
738
+
so in most cases angles are fixed up prior to interpolation so that per-component interpolation is done over less than 360 degrees, often less than 180.
739
+
Host syntax can specify any of the following algorithms for hue interpolation
740
+
(angles in the following are in degrees, but the logic is the same regardless of how they are specified):
741
+
742
+
: ''shorter''
743
+
:: Angles are adjusted so that θ₂ - θ₁ ∈ [0, 180). In pseudo-Javascript:
744
+
<pre>
745
+
if (θ₂ - θ₁ >= 180) {
746
+
θ₁ += 360;
747
+
}
748
+
else if (θ₂ - θ₁ <= -180) {
749
+
θ₂ += 360;
750
+
}
751
+
</pre>
752
+
753
+
: ''longer''
754
+
:: Angles are adjusted so that θ₂ - θ₁ ∈ [180, 360). In pseudo-Javascript:
755
+
<pre>
756
+
if (θ₂ - θ₁ <= 180) {
757
+
θ₂ += 360;
758
+
}
759
+
else if (θ₂ - θ₁ >= -180) {
760
+
θ₁ += 360;
761
+
}
762
+
</pre>
763
+
764
+
: ''increasing''
765
+
:: Angles are adjusted so that θ₂ - θ₁ ∈ [0, 360) and θ₁ ≤ θ₂. In pseudo-Javascript:
766
+
<pre>
767
+
if (θ₂ < θ₁) {
768
+
θ₂ += 360;
769
+
}
770
+
</pre>
771
+
772
+
: ''decreasing''
773
+
:: Angles are adjusted so that θ₂ - θ₁ ∈ [0, 360) and θ₁ ≥ θ₂. In pseudo-Javascript:
774
+
<pre>
775
+
if (θ₁ < θ₂) {
776
+
θ₁ += 360;
777
+
}
778
+
</pre>
779
+
780
+
: ''specified''
781
+
:: No fixup is performed. Angles are interpolated in the same way as every other component.
782
+
783
+
Unless otherwise specified, if no specific hue interpolation algorithm is selected by the host syntax, the default is ''shorter''.
0 commit comments