Re: NSBezierPath + thin lines + antialias = :(
Re: NSBezierPath + thin lines + antialias = :(
- Subject: Re: NSBezierPath + thin lines + antialias = :(
- From: Charles Jenkins <email@hidden>
- Date: Tue, 10 Feb 2015 08:36:06 -0500
This may explain why my purchase of a program that outputs code for vector images resulted in disappointment. I don't have a retina display, so I bought a program to make graphics code that would look good at any size/resolution in my Mac app, even for displays I have no experience with. What I got was images that look *terrible* even at the designed size when the output code uses beziers. So far the only solution is to export the images as PNGs, which I could've done without spending a hundred bucks on other software.
--
Charles
On February 9, 2015 at 16:39:21, Jens Alfke (email@hidden) wrote:
> On Feb 9, 2015, at 1:18 PM, Jerry Krinock <email@hidden> wrote:
>
> Is there a way to draw thin lines in code, and get good results on non-Retina displays? What should I read to learn how?
(The listserv strips image attachments, so we can’t see the pictures.)
The typical problem drawing thin horizontal/vertical lines is that the line gets split between pixels, so you get a 2-pixel-wide gray line when what you wanted was a 1-pixel black line. The reason this happens is that when you use integer coordinates the line is centered on a pixel boundary, so the left half of the line is in one pixel and the right half is in another.
Instead, to draw a one-point line, the coordinate on the axis perpendicular to the line should end in .5. For example, to draw a vertical line at x=100, the x coord of the line should be 100.5. That way you completely fill the pixels at x=100 and no others.
(This only applies to odd widths, though. For a 2pt line, you do want whole-number coords.)
(It gets more complicated if you’ve transformed the coordinate system, because the above considerations apply to device coords, so you’d have to transform your drawing coords into device coords, do the rounding/offset, and then back. This happens with scaling, but can also occur if you’ve scrolled/offset your coordinates by non-integral amounts.)
—Jens
_______________________________________________
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
_______________________________________________
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