Thursday, October 13, 2016

Drawing Hairlines

Joshua Emmons:

Or, graphically, for any Y in the shaded area, we need to either round it up to the top dashed line or round it down to the bottom dashed line to draw a perfect non-antialiased line.

How do we choose if we want to draw above or below our given coordinate? It depends on the situation. If we’re trying to draw a line at the very top of a clipping view, we’ll want to draw slightly below the Y we give it. Otherwise it will clip and not be visible. The same goes in reverse for drawing at the bottom of a view.


Sadly, we don’t want to draw perfect single point lines. We want to draw perfect single pixel lines. On non-retina devices, those are the same thing. But on everything else, each point is made up of several pixels.

“Plus” model iPhones, for example, actually have three pixels per point, represented by the yellow lines here.

Update (2016-10-13): Previously: iPhone 6 Pixel Peeping (via Ole Begemann).

Comments RSS · Twitter

Leave a Comment