[cairo] rsvg and cairo alpha puzzle

Donn donn.ingle at gmail.com
Sat Jan 19 09:56:03 PST 2008


Dom & Bertram,
I'm pretty sure I have blundered, but near as I can tell right now it seems no 
different. I am in no-way used to C and makefiles etc. so the chances are 
high that it's my fault.

I fetched the librsvg-2.20.0 source and the gnome-python-desktop-2.21.2 
source. 
I compiled librsvg first, default configure. No errors.

Then I did the other gnome-python one. No errors.
The paths are screwball, but I moved the rsvg.so and .la files into 
my /usr/lib/python2.5/site-packages/gtk-2.0 directory

From the output of both make install, it *seems* that everything is pointing 
to the latest librsvg sources etc.

I can't get a version number from 'rsvg' via python, but rsvg.__file__ shows 
it's pointing to the expected rsvg.so file.

The code I am using to test this (in Python) is:

#! /usr/bin/env python
import pygtk
pygtk.require('2.0')
import gtk, gobject, cairo
import rsvg

class Screen(gtk.DrawingArea):
    __gsignals__ = { "expose-event": "override" }
    def do_expose_event(self, event):
        # Create the cairo context
        cr = self.window.cairo_create()
        self.draw(cr, *self.window.get_size())
def run ( Widget, w, h):
    window = gtk.Window()
    window.connect("delete-event", gtk.main_quit)
    window.set_size_request ( w, h )
    widget = Widget()
    widget.show()
    window.add(widget)
    window.present()
    gtk.main()

class Shapes ( Screen ):
    def draw(self, cr, width, height):
        cr.translate ( 200, 210 )
        # When you remark 1,2 & 3 below, the translate above
        # no longer works.
        #cr.push_group ( ) # 1. remark this
        obj.render_cairo ( cr )
        #cr.pop_group_to_source ( ) # 2. remark this
        #cr.paint_with_alpha ( 0.5 ) # 3. remark this
        
        
obj = rsvg.Handle ( "somefile.svg" )

run ( Shapes, 400, 400 )

HTH
\d


"The position I have always adopted is that much of animal nature is indeed 
altruistic, cooperative and even attended by benevolent subjective emotions, 
but that this follows from, rather than contradicts, selfishness at the 
genetic level."
-- Richard Dawkins

Fonty Python and other dev news at:
http://otherwiseingle.blogspot.com/


More information about the cairo mailing list