Skip to content

Commit aba4ebb

Browse files
committed
[css-color-4] Don't force non-legacy colors to interpolate in a gamma-encoded space w3c#5883
1 parent 6b0b0d1 commit aba4ebb

1 file changed

Lines changed: 37 additions & 5 deletions

File tree

css-color-4/Overview.bs

Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4364,11 +4364,32 @@ Interpolation</h2>
43644364
animations, and
43654365
color mixing and color modification functions.
43664366

4367-
In general, interpolation between <<color>> values of the same [=colorspace=]
4367+
In general, interpolation between <<color>> values
43684368
occurs by linearly interpolating each component of the computed value of the color
4369-
separately, in that colorspace.
4370-
This provides Web compatibility; legacy sRGB content interpolates in the sRGB space by default.
4369+
separately, in Lab.
4370+
4371+
<!--
4372+
4373+
Historically the existing specifications used interpolation in gamma-encoded sRGB.
4374+
This gave poor results, and was sRGB-only.
4375+
This specification improves the situation by
4376+
4377+
- using a perceptually uniform interpolation space by default
4378+
- enabling interpolation between any color
4379+
(which has a colorimetric interpretation, which is all of them except for device-cmyk and even then, only in corner cases)
4380+
- allowing individual specifications to override this
4381+
(for example compositing should be in linear-light XYZ)
4382+
(for example, clor-mix defaults to LCH but allows other spaced to be explicitly specified)
4383+
- maintaining Web compat with special-case where all the colors to be interpolated use legacy sRGB
4384+
- providing an opt-in for sRGB colors
4385+
4386+
The legacy specifications will over time be updated to add support for non-sRGB colors
4387+
4388+
This is all in a comment because we don't make promises about future specifications
43714389

4390+
But rest assured, they are all being targeted.
4391+
4392+
-->
43724393

43734394
Interpolating to or from ''<color>/currentcolor'' is possible.
43744395
The numerical value used for this purpose is the used value.
@@ -4386,12 +4407,23 @@ Color space for interpolation</h3>
43864407

43874408
Issue: Should gamut mapping occur before or after interpolation?
43884409

4389-
If colors are not in the same color space,
4390-
they are first converted to Lab
4410+
Colors are first converted to Lab
43914411
and then interpolated as Lab colors.
43924412
Host syntax can override the interpolation color space and specify which color space is used for interpolation.
43934413
For example, 'color-mix' and 'color-adjust' override the default to LCH.
43944414

4415+
The exception is that if all the <<color>>s to be interpolated
4416+
are sRGB values, and they are all expressed in a legacy syntax
4417+
such as hex colors, named colors,
4418+
''rgb()'', ''hsl()'' or ''hwb()''
4419+
(and the equivalent alpha-including forms)
4420+
then they are interpolated in gamma-encoded sRGB space.
4421+
4422+
This provides Web compatibility; legacy sRGB content interpolates in the sRGB space by default.
4423+
4424+
This also means that authors can choose to opt-in to Lab interpolation
4425+
by using the non-legacy ''color(srgb r g b)'' form.
4426+
43954427
<h3 id="interpolation-alpha">
43964428
Interpolating with alpha</h3>
43974429

0 commit comments

Comments
 (0)