Re: [css3-images] We should use linear RGB color space when doing gradients (and transitions, and ...)

On 01-14 16:36, Tab Atkins Jr. wrote:
> On Sat, Jan 14, 2012 at 8:55 AM, Witold Baryluk
> <baryluk@smp.if.uj.edu.pl> wrote:
> > On 01-13 23:27, Tab Atkins Jr. wrote:
> >> Since everything currently uses sRGB, gradients should match that and
> >> stay how they are.
> >
> > I disagree. As you said, everything is sRGB, but doing linear gradients
> > in way they are currently done, are incorrect usage of sRGB. sRGB is
> > only usefull for transfering pixels colors, not performing ANY
> > operations on them other than displaying on devices using same color
> > space. Any operation like resampling, rescaling, generating gradients,
> > performing blending, performing any kind interpolation based on
> > position, time, or other parameters must be done in linear space to
> > produce correct sRGB result.
> >
> > This just means that CSS is not using sRGB, but mix of sRGB and RGB,
> > often interchanging them without doing proper conversion.
> 
> I agree that it's wrong.  However, it's better for everything to be
> wrong in a consistent way (which can be fixed later) than for things
> to be inconsistent, with some things working correctly and others
> incorrectly.
> 
> SVG *already has* a way to fix this, via the 'color-interpolation'
> property: <http://www.w3.org/TR/SVG/painting.html#ColorInterpolationProperties>.
>  SVG gradients pay attention to it, and it defaults to sRGB.  At some
> point we should pull it into general CSS so that it applies to CSS
> gradients as well
> 
> I won't be making this change - CSS gradients should be consistent
> with SVG gradients, CSS Transitions/Animations (and, I suspect, SVG
> animations as well, though I haven't tested it), and other things.
> SVG has a way to indicate that all of its things should use linearRGB
> instead, and CSS should adopt that in the future, but I don't want to
> add it to Image Values level 3.  It should be considered for either
> Image Values 4 or Colors 4.
> 
> Please indicate whether or not this resolution is acceptable.

Ok. I guess it can be hard to change existing implementations now, and
how people uses gradients already, so I can accept how current behaviour
works, despite being somehow incorrect. Consistency is good I agree, and
I will be waiting for color-interpolation equivalent in CSS to be
introduced in Image Values 4 and Color 4.

>From http://www.w3.org/TR/SVG/painting.html#ColorInterpolationProperties

  ''Value:   auto | sRGB | linearRGB | inherit''
  ...
  ''The ‘color-interpolation’ property specifies the color space for
  gradient interpolations, color animations and alpha compositing.''

So it looks precisly what is needed in CSS also.

I guess also in Image Values 4, will be some place for linear-gradients
based on other interpolation schemas than partially linear between
colors stops, like cubic splines (there is no such thing in SVG either
currently and can be somehow emulated by big number of color stops).
Usage of cubic splines instead of linear interpolation should produce
almost same result, but will make it slightly more smooth at color
stops.

Thanks you.

-- 
Witold Baryluk

Received on Sunday, 15 January 2012 20:25:55 UTC