[cairo] problem rotating svg

Russell Strong rstrong at bigpond.net.au
Fri Apr 1 01:28:29 PST 2005


Hi,

I've tried rotating some SVG images and found that parts of the image
aren't behaving correctly.  I'm not sure how to describe it except by
saying run the code and take a look.  The file home.svg comes from
cairo-demo/cairo_snippets/data.

Is it a bug or am I bone?

#!/usr/bin/env python

import gtk
import cairo
import cairo.gtk
import cairo.svg

angle = 0.0

ctx = cairo.svg.Context()
ctx.parse('./home.svg')
sx,sy = ctx.size

def expose_event(widget, event):
        cr = cairo.Context()
        cairo.gtk.set_target_drawable(cr, widget.window)
        cr.translate(400,400)
        cr.rotate(angle)
        cr.translate(-sx/2.0,-sy/2.0)
        ctx.render(cr)

def periodic():
        global angle
        angle = angle + 0.03
        da.queue_draw()
        return True

win = gtk.Window()
da = gtk.DrawingArea()
da.set_size_request(800,800)
win.add(da)
win.show_all()
win.connect('destroy', lambda x:gtk.main_quit())
da.connect('expose_event', expose_event)
gtk.timeout_add(100, periodic)
gtk.main()





More information about the cairo mailing list