[whatwg] Canvas rectangles

"The clearRect() method ... The fillRect() method ... The strokeRect()
method ..." - should say "clearRect(x, y, w, h)" etc, for consistency
with all the other function definitions.

"Shapes are ... subject to ... shadow effects, global alpha, ... and
global composition operators" is a bit confusing since clearRect isn't
subject to those things. (Actually, clearRect is subject to shadow
effects in Safari, and subject to composition operators in Opera, but
I'd say those are just bugs.)

strokeRect: The definition is vague about where line-joins occur, in
the normal case and in the "If only one of [width and height] is zero
..." case, since it doesn't really say that it's a closed path.

There is minor implementation disagreement in the zero-width case
(<http://canvex.lazyilluminati.com/misc/rects.html>) - in Safari it is
equivalent to drawing a rectangle with infinitesimal width (hence with
four line-joins connecting perpendicular edges), whereas in
FF/Opera/spec it's equivalent to a line (with two line-joins
connecting parallel edges). Also, Safari/FF3 draw stuff in the
width=height=0 case, though that's related to the more general
line-caps-on-zero-length-lines thing (as in
I believe it would be nice (for consistency and predictability) if
strokeRect worked the same as rect+stroke (and the same as
moveTo+lineTo+lineTo+lineTo+closePath+stroke) - that is what everyone
except Safari does, but it doesn't seem to be explicit or obvious in
the spec.

Perhaps it would be easier and most precise to define strokeRect in
terms of existing methods, like: "The strokeRect(x, y, w, h) method
must be equivalent to the following sequence of method calls:
beginPath(); rect(x, y, w, h); stroke(); except with the current path
after calling the strokeRect method remaining the same as before the

Philip Taylor
excors at gmail.com

Received on Saturday, 30 June 2007 16:06:25 UTC