[cairo] How to prevent disappear of lines when scaling?

Carl Worth cworth at cworth.org
Fri Nov 7 13:37:43 PST 2008


On Fri, 2008-11-07 at 13:03 +0200, Hakki Dogusan wrote:
> I found Carl's line-width-scale.c code about subject. It uses following 
> method:
...
> But I need different line widths in my do-drawings step. Is there a 
> solution for that usage?

Hello there,

I'm not exactly sure what your question is, so I'll try a couple of
different answers at the same time. :-)

If you are about to stroke a line and you want a line width of "width"
user-space units (that is, the width is modified by the current
transformation so it may be a different number of pixels), then do:

	cairo_set_line_width (cr, width);
	cairo_stroke (cr);

If you are about to stroke a line and you want a line width of "width"
device-space units (in other words, "width" pixels, independent of the
current transformation), then do:

	cairo_save (cr);
	cairo_identity_matrix (cr);
	cairo_set_line_width (cr, width);
	cairo_stroke (cr);
	cairo_restore (cr);

In other words, cairo_set_line_width *always* accepts a value in
user-space units, but you can arrange for user space to be identical to
device space with cairo_identity_matrix as desired.

Now, if you actually want something different than either of the above,
then please try asking again with more details, because I didn't catch
the question the first time.

Thanks,

-Carl

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://lists.cairographics.org/archives/cairo/attachments/20081107/a721a513/attachment.pgp 


More information about the cairo mailing list