Skip to content

Commit 8da9adc

Browse files
committed
[css-color-5] Add interpolation section, define hue angle interpolation there
Related to #4647 #4928 #4735
1 parent 6c03515 commit 8da9adc

File tree

1 file changed

+70
-1
lines changed

1 file changed

+70
-1
lines changed

css-color-5/Overview.bs

+70-1
Original file line numberDiff line numberDiff line change
@@ -713,6 +713,75 @@ When an origin color is present, the following keywords can also be used in this
713713
</pre>
714714
</div>
715715

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''.
784+
716785

717786
Security and Privacy Considerations {#SecPriv}
718787
===================================
@@ -725,4 +794,4 @@ Acessibility Considerations {#Ally}
725794
This specification introduces a new feature
726795
to help stylesheet authors
727796
write stylesheets which conform
728-
to WCAG 2.1 <a href="https://www.w3.org/TR/WCAG21/#contrast-minimum">section 1.4.3 Contrast (Minimum)</a>.
797+
to WCAG 2.1 <a href="https://www.w3.org/TR/WCAG21/#contrast-minimum">section 1.4.3 Contrast (Minimum)</a>.

0 commit comments

Comments
 (0)