[cairo] Line widths and coordinate system transformations

Holger Berndt berndth at gmx.de
Thu Jun 5 06:01:32 PDT 2008

For my gtkmm-based application, I am writing a custom xy-plot widget
into which I can draw some lines and curves using cairomm. To get rid of
permanent manual coordinate transformations, it is very handy to
translate and scale the drawing coordinate system into alignment with
the plot axis. This works very well.

I have, however, a problem with the resulting line width. Usually, x
and y axis are not equally scaled which results in the pen having
different widths depending on the direction of the line.

I have attached a sample screenshot to illustrate the problem (I hope
that's okay with the list -- it's really tiny). In this example, the
horizontal axis goes from 0 to 9, whereas the vertical axis goes from 0
to 1. Consequently, lines that are drawn horizontally are much thicker
than vertical lines (the requested line width with
Cairo::Context::set_line_width() remained unchanged).

What I would like to have constant user-visible line widths in all

As a bonus, it would also be nice to specify a constant line width in
pixels, completely independant of the scaling. But that'd really be a
bonus -- for now, I'd already be happy with scale-dependant but
direction-independant line widths.

I am aware that I could achieve that by using the same scale in x and y
direction. However, that would make drawing much harder, as I would
have to do the transformations for each point individually and
manually, which is something that I'd really, really like to avoid.

In particular, this very same effect seems to imply that it is not
possible to draw an ellipse outline with constant line width with
Cairo. Is that correct?

Thanks in advance for any comments,

PS: This mail was originally sent to the gtkmm mailing list, but the
lack of feedback made me believe that it's actually a cairo question,
not a gtk question.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: line_width.png
Type: image/png
Size: 1708 bytes
Desc: not available
Url : http://lists.cairographics.org/archives/cairo/attachments/20080605/d0cf69dc/attachment.png 

More information about the cairo mailing list