Re: Strange issue in stroking a bezier path
Re: Strange issue in stroking a bezier path
- Subject: Re: Strange issue in stroking a bezier path
- From: Kyle Sluder <email@hidden>
- Date: Sat, 05 May 2012 16:55:57 -0700
On May 5, 2012, at 4:46 PM, Jens Alfke <email@hidden> wrote:
>
> It does that, but the results may not always be exactly what you want. :) The default behavior is to antialias, so if you stroke a one-point-wide black rectangle on integer point boundaries (assuming the usual 1pt==1px scaling) you will in fact get a two-pixel wide gray rectangle. Which is probably not what you wanted. This is because the edges are on pixel boundaries so the strokes are going halfway through the pixels on either side. The solution as I said is to add 0.5 to the coordinates so that the stroke edges fall on pixel boundaries.
>
> (IIRC there are some AppKit geometry utility functions that will adjust coordinate values to fit pixel boundaries in a resolution-independent way. I don’t remember their names offhand.)
-centerScanRect:, -convertRectToBacking: and friends. Which if I understand correctly you should now *always* use instead of adding half pixels because of HiDPI.
>
> Someday every device will have retina-quality graphics and these details won’t matter
It still matters because coordinates in Quartz always refer to the infinitely thin space between device pixels.
--Kyle Sluder
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden