[cairo] Cannot get transformations to work
Behdad Esfahbod
behdad.esfahbod at gmail.com
Tue Nov 3 01:37:40 PST 2009
On 11/03/2009 04:24 AM, ashley at ashleymills.com wrote:
> I was thinking about this.
>
> I wrote a function in the end.
>
> Would it perhaps be useful to add this functionality to Cairo? It seems
> like it might be something which comes up quite a lot; the transformation
> of a set of points rather than the drawing surface.
You can do this already:
- cairo_save()
- transform
- add path
- cairo_restore()
- cairo_copy_path()
- cairo_new_path()
If you want the inverse, do the transform before copy_path().
behdad
> Would it be difficult to add this to the code base?
>
> Ashley
>
>> 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
>>
>
>
> _______________________________________________
> cairo mailing list
> cairo at cairographics.org
> http://lists.cairographics.org/mailman/listinfo/cairo
>
More information about the cairo
mailing list