[cairo] Getting started

Vladimir Vukicevic vladimirv at gmail.com
Mon Jul 25 07:54:09 PDT 2005

On 7/25/05, Behdad Esfahbod <behdad at cs.toronto.edu> wrote:
>   - Do not translate.
>   - For drawing lines, set width to 1 and add +0.5,+0.5 to all
> points.

You don't want +0.5,+0.5 to all points though, especially not for
horizontal/vertical lines.  (See my original reply.)  However, in
thinking about it, if you use CAIRO_LINE_CAP_SQUARE (instead of the
default BUTT), then adding +0.5,+0.5 should give you correct (and
still fast) results.

>   - When drawing filled stroked rectangles, do not use the same
> path for both fill and stroke.  Use integer coordinates for the
> fill, and half-off coordinates for the stroke.  This is the only
> way to avoid alpha-blending.
> I wish there was a way to have a fill+stroke to use the same path
> and still be fast, but I that's only an issue with axis-aligned
> rectangles.

Yeah, this is a bit of a pain.  To be more accurate, you want integer
coordinates for fill or for even line widths, and you want offset
coordinates for odd line widths.  I don't think there's a good way
around this though, unfortunately.

    - Vlad

More information about the cairo mailing list