[cairo] Rotation around a point

Dirk Schönberger dirk.schoenberger at sz-online.de
Sat Nov 24 11:07:47 PST 2007


> Hello again,
>  I've been looking around and I can't find much on this. How can I go
about
> setting an x,y within a shape so that it can be rotated (via matrixes)
around
> that point?

> For some background:
> Each of the things I draw gets this before it:
> ThingMatrix = cairo.Matrix ( prop.sx, 0, 0, prop.sy, prop.x, prop.y )
> cairo.Matrix.rotate( ThingMatrix, prop.rot )
> self.context.transform ( ThingMatrix )

I have no idea on the API you use (I assume pycairo), but I would try to do
something like

cairo.Matrix.translate( ThingMatrix, prop.x, prop.y )
cairo.Matrix.scale( ThingMatrix, prop.sx, prop.sy )
cairo.Matrix.rotate( ThingMatrix, prop.rot )

If you add a second

cairo.Matrix.translate( ThingMatrix, x, y ) somewhere, it should be rotated
around this point.
The x and y values may be negated.

Regards
Dirk




More information about the cairo mailing list