W3C home > Mailing lists > Public > whatwg@whatwg.org > November 2010

[whatwg] Canvas gradients color interpolation - change to premultiplied?

From: Jonas Sicking <jonas@sicking.cc>
Date: Tue, 23 Nov 2010 14:40:31 -0800
Message-ID: <AANLkTimW=xigw=SNYr8khE4yPd_WXu=7-zW2i-Khf=vJ@mail.gmail.com>
On Tue, Nov 23, 2010 at 2:09 PM, Philip Taylor <excors+whatwg at gmail.com> wrote:
> On Tue, Nov 23, 2010 at 8:43 PM, Tab Atkins Jr. <jackalmage at gmail.com> wrote:
>> Right now, canvas gradients interpolate their colors in
>> non-premultiplied space; that is, the raw values of r, g, b, and a are
>> interpolated independently. ?This has the unfortunate effect that
>> colors darken as they transition to transparent, as "transparent" is
>> defined as "rgba(0,0,0,0)", a transparent black. ?Under this scheme,
>> the color halfway between "yellow" and "transparent" is
>> "rgba(127,127,0,.5)", a partially-transparent dark yellow, rather than
>> "rgba(255,255,0,.5)".*
> If you define the gradient as interpolating from solid yellow to
> transparent black, I'd expect that it *should* be semi-transparent
> blackish-yellow in the middle.
> If you want it to be pure yellow, don't use a keyword which is
> explicitly specified as transparent black - define the gradient from
> rgba(255,255,0,1) to rgba(255,255,0,0) instead. Then you'll get
> rgba(255,255,0,0.5) in the middle.

For what it's worth, I suspect most people don't think of
"transparent" as "transparent black", but rather as "fully

/ Jonas
Received on Tuesday, 23 November 2010 14:40:31 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:59:28 UTC