[cairo] rsvg and colour
donn.ingle at gmail.com
Wed Apr 29 23:02:43 PDT 2009
Well, to keep talking to myself :) I have a partial solution that may help
someone else in the future:
This is based on my "Things" animation API, the action happens in the draw()
self.keys( "#------#", Props(),Props(x=100,y=20))
self.tint = [0,1,0,1] # r,g,b,a
def draw(self, ctx, fr):
# Get a 'pattern' of stuff drawn
BOS["CG:logo"].draw(ctx) # an rsvg render
ctx.rectangle(0,0,100,100) # a wee rectangle
p = ctx.pop_group() # store all that in p
ctx.set_source(p) # Choose p as the source
ctx.paint() # Draw it - full-on colour and all
ctx.set_source_rgba( *self.tint ) # Now make a 'tint' source.
ctx.mask(p) #Draw the tint THROUGH the pattern (p is draw again).
self.tint -= 0.1 # Shift the tint down to alpha 0
The idea is that it's drawn twice - the one underneath is gradually revealed
as the one (tinted green) is drawn with decreasing visibility (alpha gets
It's a bit heavy, but it's what I have figured-out so far.
Where I web: http://otherwise.relics.co.za/
Comics, tutorials, software and sundry
More information about the cairo