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

Dirk Schulze dschulze at adobe.com
Mon Jul 22 21:55:03 PDT 2013

On Jul 18, 2013, at 7:49 PM, Ian Hickson <ian at hixie.ch> wrote:

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

I don't think that we want to throw an exception on scale(0). No browser does that today. WebKit did it in some places in the past but removed the exceptions.

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

In both cases the transformation matrix is not invertible. I do not disagree.

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

Since this is not written in the spec, it is not clear which behavior is correct. Especially regarding that you can building a path over different context states and transforms per context states the this should be specified.


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