[whatwg] strokeRect() with zero heights or widths

Vladimir Vukicevic vladimirv at gmail.com
Sun May 28 02:38:09 PDT 2006


Doesn't a zero-width (or zero-height, as long as it's only one)
degenerate into a vertical (horizontal) line when stroked, due to the
line width?  A filled rectangle doesn't, because the area to fill is
defined exactly by the rectangular path (which has 0 thickness),
whereas a stroked path takes the line width into account to compute
the area to fill.  Now, to be fair, I don't really care either way,
just looking for consistency... should using fillRect/strokeRect be
defined as convenience functions doing the same job as creating a
rectangular path and calling fill/stroke?

I'd expect the following to give me a 10 pixel line, the same as if I
had just done moveTo(x, 10); lineTo(x,20); stroke();

beginPath();
moveTo(x, 10);
lineTo(x, 20);
lineTo(x+0, 20);
lineTo(x+0, 10);
closePath();
stroke();

Otherwise, we end up with different results for what is logically the
same operation, I'd think?

    - Vlad

On 5/20/06, Anne van Kesteren <fora at annevankesteren.nl> wrote:
> I think http://whatwg.org/specs/web-apps/current-work/#strokerect must
> have no effect when it has a zero height or width (or both). Currently
> Safari, Firefox and Opera act that way when they are both zero and
> Safari acts that way for all cases. Firefox and Opera draw a small
> line when either is larger than zero but that can easily be changed.
> It also makes the method more consistent with the other two.
>
> For those "If either height or width are zero, this method has no
> effect." should probably be changed to "If either height or width are
> zero, this method must have no effect."
>
>
> --
> Anne van Kesteren
> <http://annevankesteren.nl/>
>
>



More information about the whatwg mailing list