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

David Björkevik david at bjorkevik.se
Fri Nov 7 16:58:35 PST 2008


Hello,  (my first post to the list)

Hakki Dogusan wrote:
> If you need some fun, look at my newbie solution:
> 
> double scale = 1/100.0;
> double linewidth = 2;
> 
> cairo_scale(cr, scale, scale);
> cairo_move_to(cr, 0, 8000);
> cairo_line_to(cr, 5000, 10500);
> cairo_close_path(cr);
> // cairo_set_line_width(cr, linewidth);
> cairo_set_line_width(cr, linewidth/scale);
> cairo_stroke(cr);


This raises another question: I usually employ such tricks to avoid 
having to do save and restore the entire cairo state, because it "feels" 
expensive. But is it?

Furthermore, Hakki, I could recommend you in this case to set the line 
width before you do cairo_scale. The pen used to stroke always uses the 
transofrmation matrix that is active when you do cairo_set_line_width.

Regards,
David


More information about the cairo mailing list