[cairo] thin antialiased lines

control H control.h at gmail.com
Sun Jul 15 04:12:54 PDT 2007

Hi all,

I'm busy in the process of changing my gtk chart plotting program from
GDK based to Cairo based. The good thing is that in general the code
becomes smaller and cleaner and simpler, the bad thing is that the
result is not exactly perfect for small, 'busy' graphs. In the chart
the plotted lines look very smooth since they're anti aliased, but the
drawback is that they are thicker than the gdk based lines. Even
though I set the line width to 1.0. This makes most graphs look odd,
except when I put it in full screen mode. But for small, tiny graphs,
the lines are just too thick. Since I also plot some vertical lines
and use the 0.5 offset thing to prevent smearing them out over 2
pixels, the other anti aliases lines are too thick compared too the
exactly vertical and horizontal ones, making the plot look odd as said

One solution is to thinner the lines by setting the line width to 0.5
for example. Indeed the lines look like I want them to regarding
thickness and also smoothness. However, the color is fading making it
impossible to draw for example black lines of width 0.5.

An other solution I tried was disabling the whole anti alias thing.
But that results in ugly lines; their width is inconsistent. It's a
bit hard to describe, I can send example charts to clarify it. Let's
put it this way: lines drawn with cairo (without AA) compared to the
old fashioned gdk_draw_line() are far inferior, having pixels at
places where I don't want them to be.

So my question is: is there a way to either draw _nice_ non anti
aliased lines with cairo, or to draw small anti aliased lines of 1
pixel thick and in the correct color? Or is there a way to change the
mode in which a line is drawn?

Thanks for your input.

PS I'm new to this list. Of course I've first been searching the
archives but couldn't find this problem/solution. If this has been
discussed before I'm sorry.

More information about the cairo mailing list