@@ -4967,45 +4967,69 @@ Interpolation</h2>
49674967
49684968<h3 id="interpolation-space">
49694969Color space for interpolation</h3>
4970- Different color spaces may be more appropriate for each interpolation use case.
4971- For example,
4972- the perceptually uniform Lab works well for avoiding bunching up in gradients,
4973- and the chroma-preserving LCH works well for avoiding greying out in color mixing,
4974- while the linear-light XYZ is best for compositing
4975- and gamma-encoded sRGB, which is neither linear light nor perceptually uniform,
4976- will give overly dark mixes but is compatible with older Web content.
49774970
49784971 Various features in CSS depend on interpolating colors.
4979-
4980- <div class="example" id="ex-host-syntax">
49814972 Examples include:
49824973
49834974 * <<gradient>>
49844975 * 'filter'
49854976 * 'animation'
49864977 * 'transition'
4987- * ''color-mix()''
4988- </div>
4978+
4979+ Mixing or otherwise combining colors
4980+ has different results depending on the color space used.
4981+ Thus, different color spaces may be more appropriate for each interpolation use case.
4982+
4983+ * In some cases, the result of physically mixing two colored lights is desired.
4984+ In that case, the CIE XYZ color space is appropriate, because it is linear in light intensity.
4985+ * If colors need to be evenly spaced perceptually (such as in a gradient),
4986+ the OKLab color space (and the older Lab), are designed to be perceptually uniform.
4987+ * If avoiding graying out in color mixing is desired, i.e. maximizing chroma throughout the transition,
4988+ OKLCH (and the older LCH) work well for that.
4989+ * Lastly, compatibility with legacy Web content may be the most important consideration.
4990+ The sRGB color space, which is neither linear-light nor perceptually uniform, is the choice here,
4991+ even though it produces poorer results (overly dark or greyish mixes).
4992+
4993+
49894994
49904995 These features are collectively termed the <dfn export>host syntax</dfn> .
49914996 The host syntax should define
49924997 what the default interpolation space should be for each case,
49934998 and optionally provide syntax for authors to override this default.
4999+ If such syntax is part of a property value, it should use a <<color-interpolation-method>> token,
5000+ defined below for easy reference from other specifications.
5001+ This ensures consistency across CSS,
5002+ and that further customizations on how color interpolation is performed
5003+ can automatically percolate across all of CSS.
5004+
5005+ <pre class='prod'>
5006+ <dfn export><rectangular-color-space></dfn> = srgb | lab | oklab | xyz | xyz-d50 | xyz-d65
5007+ <dfn export><polar-color-space></dfn> = hsl | hwb lch | oklch
5008+ <dfn export><hue-interpolation-method></dfn> = [ shorter | longer | increasing | decreasing | specified ] hue
5009+ <dfn export><color-interpolation-method> = in [ <<rectangular-color-space>> | <<polar-color-space>> <<hue-interpolation-method>>? ]
5010+ </pre>
5011+
5012+ <p dfn-type=value dfn-for="<color-space>">
5013+ The keywords in the definitions of <<rectangular-color-space>> and <<polar-color-space>>
5014+ each refer to their corresponding color space,
5015+ represented in CSS either by the functional syntax with the same name,
5016+ or (if no such function is present), by the corresponding <<ident>> in the ''color()'' function.
5017+ </p>
49945018
49955019 If the host syntax does not define what color space
49965020 interpolation should take place in,
49975021 it defaults to OKLab.
49985022
4999- However, user agents will handle interpolation
5023+ However, user agents <em>may</em> handle interpolation
50005024 between legacy sRGB color formats
50015025 (hex colors, named colors,
50025026 ''rgb()'', ''hsl()'' or ''hwb()''
50035027 and the equivalent alpha-including forms)
50045028 in gamma-encoded sRGB space.
50055029 This provides Web compatibility; legacy sRGB content interpolates in the sRGB space by default.
50065030
5007- This also means that authors can choose to opt-in to Lab interpolation
5008- by using the non-legacy ''color(srgb r g b)'' form.
5031+ This also means that authors can choose to opt-in to better interpolation
5032+ by using the non-legacy ''color(srgb r g b)'' form for one of their colors .
50095033
50105034 If the colors to be interpolated are outside the gamut
50115035 of the interpolation space,
@@ -5104,6 +5128,8 @@ Hue interpolation</h3>
51045128
51055129 Host syntax can specify any of the following algorithms for hue interpolation
51065130 (angles in the following are in degrees, but the logic is the same regardless of how they are specified).
5131+ Specifying a hue interpolation strategy is already part of the <<color-interpolation-method>> syntax
5132+ via the <<hue-interpolation-method>> token.
51075133
51085134 Unless the type of hue interpolation is ''specified'', both angles need to be constrained to [0, 360) prior to interpolation.
51095135 One way to do this is <code><i>θ</i> = ((<i>θ</i> % 360) + 360) % 360</code>.
0 commit comments