[whatwg] [Canvas] Behavior on non-invertable CTM

Ian Hickson ian at hixie.ch
Thu Jul 18 10:49:14 PDT 2013

On Tue, 29 Jan 2013, Dirk Schulze wrote:
> The spec doesn't have any wording about the behavior on non-invertible 
> CTMs on Canvas contexts. Is it still possible to add segments to the 
> current path once a CTM is not invertible anymore? Does the path get 
> rejected completely then? Implementations are fairly different.
> Here are two examples (code attached at the end of the mail as well):
> http://jsfiddle.net/Dghuh/1/
> http://jsfiddle.net/Dghuh/2/
> Note that the path is stroked after restoring the initial CTM in both 
> examples.
> The first one does scale(0), which should make the CTM non-invertibe, 
> WebKit still applies lineTo and closePath for some reason. IE and FF 
> refuse to draw anything.

scale(0) is invalid, and should throw an exception.

If you do scale(0,0), the browsers act the same as with your second test 
that uses setTransform() with 6 zeros.

> The second does setTransform(0,0,0,0,0,0), which should reset the CTM to 
> a zero matrix (again, not invertible). IE, Opera and FF draw a line to 
> 0,0 and close the path afterwards (which kind of makes sense, since the 
> universe is convoluted to one point). WebKit refuses the lineTo command 
> and closes the path as expected.

WebKit seems to just be wrong here, and the others right.

> This is an edge case, but should still be clarified in the spec.

I don't understand what there is to clarify. In both cases, the behaviour 
seems well-defined: if you're transforming everything to zero, that's what 
the result will be. Zero. Firefox's behaviour is the right one.

Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'

More information about the whatwg mailing list