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

Aryeh Gregor Simetrical+w3c at gmail.com
Fri Jun 24 10:38:02 PDT 2011

On Fri, Jun 24, 2011 at 1:09 AM, Robert O'Callahan <robert at ocallahan.org> wrote:
> Consider this testcase:
> http://people.mozilla.org/~roc/SingularCanvasMatrix.html
> It sets up a rectangle to fill, then sets the current matrix to a singular
> matrix (yy=0 in this case), then fills with different fillStyles. It's not
> clear from the spec how this is supposed to behave, and there's not much
> interop:

There's an existing bug: http://www.w3.org/Bugs/Public/show_bug.cgi?id=12705

I'm not familiar enough with the canvas API to have an informed
opinion on what should happen here, but mathematically it makes sense
to me that nothing should be drawn ever if the transform matrix is
singular.  Everything will be collapsed to line or point in that case,
with zero width, so it's invisible.  Even if it's just a solid color,
conceptually you're collapsing the whole color-filled *plane* into
something with zero width, so it should still be invisible.

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.

More information about the whatwg mailing list