[cairo] pycairo - translate question

Donn donn.ingle at gmail.com
Mon Nov 5 07:38:19 PST 2007


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?

/d


More information about the cairo mailing list