[cairo] Lander Game

Behdad Esfahbod behdad at behdad.org
Tue Jan 9 10:14:52 PST 2007


On Tue, 2007-01-09 at 15:30 +0100, Thomas Dybdahl Ahle wrote:
> man, 08 01 2007 kl. 18:38 -0500, skrev Behdad Esfahbod:
> > class Surface(__builtin__.object)
> >  |  Methods defined here:
> >  |  
> >  |  create_similar(...)
> >     ^^^^^^^^^^^^^^^^^^^
> > 
> > It takes the same args as the C API: content, width, height.  Use
> > cairo.CONTENT_COLOR_ALPHA for content.
> 
> surf = cairo.Surface.create_similar(cairo.CONTENT_COLOR_ALPHA, size,
> size)
> gives me
> TypeError: descriptor 'create_similar' requires a 'cairo.Surface' object
> but received a 'int'
> 
> Probably because it needs a surface to be similar to, but I simply get
> the cairo context using
> context = widget.window.cairo_create()
> 
> Where am I supposed to get a surface object??

context.get_target().

> But just to get on the technique. When I have created the surface, I use
> context.set_source_surface(surf) and paint my stuff. Then I save the
> surface somewhere, and next time I paint, I just
> context.mote_to(somewhere); context.set_source_surface(surf);
> context.fill() right?

Or paint() instead of fill().  fill() needs a path, so you should do a
rectangle() first.


-- 
behdad
http://behdad.org/

"Those who would give up Essential Liberty to purchase a little
 Temporary Safety, deserve neither Liberty nor Safety."
        -- Benjamin Franklin, 1759





More information about the cairo mailing list