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

Tab Atkins Jr. jackalmage at gmail.com
Fri Jun 24 23:37:22 PDT 2011


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



More information about the whatwg mailing list