[cairo] I don't see the pattern

Donn donn.ingle at gmail.com
Thu Dec 6 05:17:56 PST 2007


Okay, have had a look and I'm still not seeing it. Here's a quick breakdown of 
my situation. It's an API to perform animation via tweening and keyframes 
etc:

1. User makes a class that has a draw() method. They can look like this:

def draw(self, ctx, frame):
 #draw any cairo stuff
 ctx.set_source_rgb(1,0,0)
 ctx.rectangle(...)
 ctx.fill()

So, there are <cairo commands> within a draw() command. 

2. My main loop goes through all the user's objects and calls their draw() 
methods (very simplified here, I actually have matrixes and alpha going as it 
recurses down a tree of children):

Start timeout
ctx = widget.window.cairo_create() # this is a pyGTK  based app.
for obj in list:
 obj.draw(ctx,frame)
Loop to timeout

So, from frame to frame there is a new context and everything must be drawn 
again. 

I am trying to "record" the output of a draw() method to a cache (a var 
someplace, or (at worst) an image file) so that if frame 2 is no different 
from frame 1 then I will *not* call draw() but rather get the saved version 
from my var and draw that instead -- it would have to be much faster or 
there's no point.

So, something like this:

Start timeout
ctx = widget.window.cairo_create() # this is a pyGTK  based app.
for obj in list:
 if obj.hasChanged():
  obj.draw(ctx,frame)
 else:
  obj.<some other fancy trick to draw it as it was>
Loop to timeout

I see your line [c.renderctx(Rctx)] but I'm not sure what that method does 
within your c object.

I hope that helps you to help me!

\d


More information about the cairo mailing list