W3C home > Mailing lists > Public > whatwg@whatwg.org > June 2011

[whatwg] <canvas> drawing with singular transforms and zero-sized gradients

From: Tab Atkins Jr. <jackalmage@gmail.com>
Date: Fri, 24 Jun 2011 23:37:22 -0700
Message-ID: <BANLkTi=cw31KUy9xu1_V2H69yT+nL1fYAQ@mail.gmail.com>
On Fri, Jun 24, 2011 at 8:00 PM, Robert O'Callahan <robert at ocallahan.org> wrote:
> On Sat, Jun 25, 2011 at 5:38 AM, Aryeh Gregor <Simetrical+w3c at gmail.com>wrote:
>> If you define different behavior for solid colors or gradients,
>> doesn't that mean that they'll behave differently from if you used an
>> image that looked exactly the same? ?That seems bad.
>>
>
> If you set up a path covering the entire canvas, call ctx.scale(e, e) for
> infinitesimal e, and then fill with an image pattern, conceptually you're
> scaling the image to be incredibly small and then repeating it a very large
> number of times to fill the canvas. So I guess the logical behavior for e=0
> would be to compute the average color of the image pixels and do a solid
> fill with that color, which would give you that consistency you're asking
> for. But is that worth implementing? No-one does that today.

A similar problem exists in CSS gradients, specifically the
repeating-*-gradient case, when the "width" of the gradient (the
difference between the first and last color-stop) approaches 0.

At the moment, the editor's draft clamps the width of the repeating
gradients to a minimum of 1px wide.  The "compute the average color"
solution is another possible way to solve this, however.  I'm willing
to specify whatever the implementors are willing to do, and ideally
it'd be the same between CSS and <canvas> gradients.

~TJ
Received on Friday, 24 June 2011 23:37:22 UTC

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