[cairo] Clipping and stroking

Carl Worth cworth at cworth.org
Fri Apr 29 18:17:00 PDT 2005

On Fri, 29 Apr 2005 18:06:35 -0700, Bill Spitzak wrote:
> As somebody who has made this mistake before, I'll have to be the first 
> to point out that this does not return the correct surrounding 
> rectangle, for instance if x=1.5 and width=2. The correct answer is:
> 	width = ceil(x+width)-floor(x);
> 	x = floor(x);
> 	height = ceil(y+height)-floor(y);
> 	y = floor(y);

Thanks for catching me, Bill.

I knew there was a gotcha in there, (and I knew I could get the right
answer by doing the rounding on coordinates and only converting to
width/height at the end). I botched it by only checking the direct
rounding of width/height near integers for x and width, (rather than
near half-integers).

> Therefore it may make sense to return the extents as coordinates so this 
> mistake is less likely.

Perhaps. Would we then also want to change cairo_rectangle to take a
pair of coordinates? (Which, admittedly, would feel somewhat awkward
to me).

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.freedesktop.org/archives/cairo/attachments/20050429/4e05c325/attachment.pgp

More information about the cairo mailing list