[cairo] cairo_surface_create_similar / create_similar for SVGSurface

Eric Holmberg eric at omnicurious.com
Mon Jun 30 21:47:03 PDT 2008


I'm using multiple surfaces to render some diagrams to an SVG, but the SVG
surface doesn't seem to support the create_similar method for the CONTENT_COLOR
or CONTENT_COLOR_ALPHA options.  Is there an option that I'm missing?

Thanks,

Eric

# this works fine
s = cairo.ImageSurface(cairo.FORMAT_ARGB32, 400, 400)

# this fails when I tried to call the create_similar
s = cairo.SVGSurface(strFileName, 400, 400)

ctx = cairo.Context(s)

target  = ctx.get_target()
layer0 = target.create_similar(cairo.CONTENT_COLOR_ALPHA, 400, 400)
layer1 = target.create_similar(cairo.CONTENT_COLOR_ALPHA, 400, 400)

# render layers
# ...

# Add the layers back to the original surface
ctx.set_operator(cairo.OPERATOR_OVER)
ctx.set_source_surface(layer0, 0, 0)
ctx.paint()

ctx.set_operator(cairo.OPERATOR_OVER)
ctx.set_source_surface(layer1, 0, 0)
ctx.paint()



More information about the cairo mailing list