[pygtk] pycairo - translate question
Gustavo J. A. M. Carneiro
gjc at inescporto.pt
Tue Nov 6 02:09:32 WST 2007
On Seg, 2007-11-05 at 17:38 +0200, Donn wrote:
> Hi, not sure if this is the appropriate list.
>
> Can one, within a single cairo context, do this:
>
> while True:
> ctx.translate(0,0)
> <pycairo commands to draw a square at 0,0>
> ctx.translate(10,10)
> <pycairo commands to draw a circle at 0,0>
> ctx.translate(50,50)
> <pycairo commands to draw a Black Night at 11,44>
>
> The idea is to keep all the <drawing commands> relative to 0,0 and use
> translate (and scale etc later) to actually move the results around the
> canvas. I picture it a bit like a stamp that moves to (x,y) and then draws
> the vectors in <> down at that point, then moves on.
>
> My actual code is building a stack of pointers to draw() functions (in other
> objects) that gets run in a tight loop: pop, draw, pop, draw, etc.
>
> At the moment my tests are all over the place. Is there a way to reset the
> overall transform between each <> section?
Yes. Do stuff like this:
ctx.save()
ctx.translate(10,10)
<draw stuff>
ctx.restore()
--
Gustavo J. A. M. Carneiro
INESC Porto, Telecommunications and Multimedia Unit
"The universe is always one step beyond logic." -- Frank Herbert
More information about the pygtk
mailing list