W3C home > Mailing lists > Public > whatwg@whatwg.org > May 2006

[whatwg] strokeRect() with zero heights or widths

From: Vladimir Vukicevic <vladimirv@gmail.com>
Date: Sun, 28 May 2006 11:38:09 +0200
Message-ID: <9540d010605280238q1bccc3b9gdefb54fda6a37796@mail.gmail.com>
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();

moveTo(x, 10);
lineTo(x, 20);
lineTo(x+0, 20);
lineTo(x+0, 10);

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/>
Received on Sunday, 28 May 2006 02:38:09 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:58:46 UTC