[cairo] Pixels Are Not Little Squares

Lawrence D'Oliveiro ldo at geek-central.gen.nz
Fri Apr 22 04:05:12 UTC 2016


The explanation of how to draw sharp single-pixel-wide lines
<http://cairographics.org/FAQ/#sharp_lines> could be better phrased.
The claim

    When some people hear pixels described as little squares it sets
    their teeth on edge.

is nonsense. Saying this doesn’t set anyone’s “teeth on edge” (not of
knowledgeable people, anyway), it is simply wrong
<http://www.alvyray.com/Memos/MemosCG.htm#PixelIsNotSquare>.

The explanation could be expressed simply as an issue of where to
position the pixels* with respect to the coordinate system. In my Cairo
Gotchas notebook
<https://github.com/ldo/qahirah_notebooks/blob/master/Cairo%20Gotchas.ipynb>,
I currently say

    Cairo locates pixels at integer+½ units in device coordinates. This
    way, adjacent filled areas which share the same integer-coordinate
    boundary will abut nicely without overlaps or gaps. So if you want
    to draw lines that don’t get smeared across extra pixels, you will
    have to position them at coordinates n such that n mod 1 = ½

which is a much more direct way of putting it, don’t you think? And
completely avoiding any misleading comments about “little squares”.

*Note I said “pixels”, not “pixel centres”.


More information about the cairo mailing list