[cairo] 1px line with (very) different x/y scaling

Erik Saule godrik at mandragor.org
Fri Mar 12 21:04:42 PST 2010

Hello everybody,

I am a new user of cairo trying to implement a 2d 'gnuplot-like'
renderer. I encounter a problem while trying to draw 1px wide curves
provided my current transformation matrix. Cairo's tutorial suggests
to set the width using the following code :

double ux=1, uy=1;
cairo_device_to_user_distance (cr, &ux, &uy);
if (ux < uy)
    ux = uy;
cairo_set_line_width (cr, ux);

However, my transformation matrix is such that the ratio between ux
and uy is huge which makes my line 1px wide but 40px high. 

Changing the scale just before the stroke operation (and putting it
back afterwards) seems to solve the problem. But this looks to me
closer to a hack than to a solution.

What is the proper way of displaying a 1px line with very different
x/y scale factor ?

Thank you.

More information about the cairo mailing list