[pygtk] Re: [cairo] pycairo - translate question
Carl Worth
cworth at cworth.org
Tue Nov 6 06:24:04 WST 2007
On Mon, 5 Nov 2007 19:57:58 +0200, Donn wrote:
> Thanks. Having fun so far!
That warms my heart.
> Is there a way to set the drawing origin of a set of <pycairo drawing
> commands> such that it starts at 0,0 but in the center of the "page"? (Or
> should that be "context", I am still fuzzy about that.)
Center of the "surface" is what I would have said, (a "context" is an
extra piece of state that allows one to direct drawing operations to a
particular surface).
> I guess this will be a width/2, height/2 extra transform, but I'm not sure.
Yes, after ctx.translate(width/2, height/2) a user-space coordinate of
(0,0) will map to a device-space position at the center of the target
surface.
Do note that in general cairo doesn't allow you to query for surface
dimensions, (though it does for an image surface), so you'll generally
need to hang on to the width and height yourself.
-Carl
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://www.daa.com.au/pipermail/pygtk/attachments/20071105/29321815/attachment-0001.pgp
More information about the pygtk
mailing list