[cairo] Cannot get transformations to work

Maarten Bosmans mkbosmans at gmail.com
Tue Oct 20 13:58:27 PDT 2009


2009/10/20  <ashley at ashleymills.com>:
> I see. I suppose you already guessed this: I was imagining that the path
> vertices themselves were being transformed.

May be the text on this page can help you understand the transformations better.
http://cairographics.org/tutorial/#L2linewidth
Note that how the path of both circles is transformed by the
cairo_scale call, but only the line width of the left one distorded.

> OK I'll just write it as a function instead for now. Thanks.

Tip: It is generally a good idea to start and end drawing functions
with a cairo_save and cairo_restore call, like in the example linked
above. This way you can apply the transformations you need to get the
arrow in the right place, without affecting other drawing routines
outside your arrow-function.

> I assume then that 3rd option would be the standard way to transform a
> bunch of points?

I would only choose this option if you need it for performance reasons.

> How would one go about copying the temporary surface back onto the
> original surface?

cairo_set_source_surface followed by a cairo_paint or a path fill.

>> The last option is probably going to be the fastest, but is also
>> subject to rasterization so the quality might not be satisfactory. The
>> second is what people usually do I think.
>
> What would be subject to rasterization? The printing onto the temporary
> surface? Oh I see, so then the surfaces would be combined by simply adding
> them together according to opacity?

Yep, or according to any other blend mode operator you choose.
Remember that you probably want whole pixel offsets when compositing
the temporary surface back on your drawing surface.

> Thanks
>
> Ashley

Maarten


More information about the cairo mailing list