W3C home > Mailing lists > Public > whatwg@whatwg.org > April 2014

Re: [whatwg] Canvas normalize rect() and strokeRect()

From: Rik Cabanier <cabanier@gmail.com>
Date: Sat, 5 Apr 2014 18:23:06 -0700
Message-ID: <CAGN7qDDqFcZVX2hk1gc_AOGb7cCTRxqwVS2-mu1QuZ0pqAopPQ@mail.gmail.com>
To: Dirk Schulze <dschulze@adobe.com>
Cc: WHAT Working Group <whatwg@whatwg.org>
On Sat, Apr 5, 2014 at 9:01 AM, Dirk Schulze <dschulze@adobe.com> wrote:

> Hi,
>
> I looked at the behavior of negative width or height for the rect() and
> strokeRect() functions.
>
> All browsers normalize the passed parameters for strokeRect() to have
> positive width and height.
>
> strokeRect(90,10,-80,80) --> strokeRect(10,10,80,80)
>
> http://jsfiddle.net/za945/


It also seems that only firefox is following the spec [1] when width or
height are 0: http://jsfiddle.net/za945/2/
I'm unsure why such a rectangle is defined as a straight line.


> Just WebKit seems to normalize for rect() as well:
>
> http://jsfiddle.net/VT4MG/
>
> The behavior of normalizing is not specified. Especially it seems odd that
> the behavior for fillRect()/strokeRect() should differ from rect(). So we
> should either normalize for all functions or don't do it for all IMO.
>
> Note: fillRect() and clearRect() are not affected. The behavior for rect()
> is important for filling with different winding rules as well. It is not
> just stroking with dash arrays that is effected.
>

yes, the spec needs to say "in that order" as it does for fillRect and
strokeRect.

1:
http://www.whatwg.org/specs/web-apps/current-work/multipage/the-canvas-element.html#dom-context-2d-fillrect
Received on Sunday, 6 April 2014 01:23:37 UTC

This archive was generated by hypermail 2.3.1 : Monday, 13 April 2015 23:09:28 UTC