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

Robert O'Callahan robert at ocallahan.org
Fri Jun 24 19:52:00 PDT 2011

On Sat, Jun 25, 2011 at 5:38 AM, Aryeh Gregor <Simetrical+w3c at gmail.com>wrote:

> 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.

That's true if you call fillRect(), or fill() on a path that you've emitted
while the current matrix is singular; the rectangle or path collapses to a
single point (or line). I think it's completely clear browsers should draw
nothing in those cases.

However, my testcase emits a path while the matrix is non-singular, so the
canvas-space path is definitely not collapsed to a point or line, then makes
the matrix singular just for the fill operation. The question is then how
the singular matrix affects the way the source color, gradient or pattern
fills a non-empty path.

"If we claim to be without sin, we deceive ourselves and the truth is not in
us. If we confess our sins, he is faithful and just and will forgive us our
sins and purify us from all unrighteousness. If we claim we have not sinned,
we make him out to be a liar and his word is not in us." [1 John 1:8-10]

More information about the whatwg mailing list