[cairo] Change the coordinate system for drawing

Stefan Salewski mail at ssalewski.de
Fri Oct 21 04:02:04 PDT 2011


On Thu, 2011-10-20 at 23:02 -0300, craf wrote:
> [...]
> 
> As I understand it, the point (0,0) is located in the upper left of the
> control gtk.drawinarea.
> 

You may use cairo's scale and translate methods to change the origin,
with code like 

>cr.translate(0, @darea.allocation.height) # horizontally mirror our
>display to be compatible with gEDA/gschem 
>cr.scale(1, -1)

I did that when playing with a simple drawing application.
(http://www.ssalewski.de/PetEd.html.en)
Some more code was necessary to get zooming, scrolling and mouse user
input working. Of course there may exists much better solutions.




More information about the cairo mailing list