View Single Post
Posts: 482 | Thanked: 550 times | Joined on Oct 2010
#226
Originally Posted by Mentalist Traceur View Post
It MAY be able to display an actual image though; I've been contemplating doing that for a while now, if possible.
I have used images in Cairo for a while now. Here is a piece of code to set an image as the source:
Code:
image = "/usr/share/icons/blender.png" #replace with path
surface = cairo.ImageSurface.create_from_png(image)
pattern = cairo.SurfacePattern(surface)
matrix = cairo.Matrix(x0=-x, y0=-y) #where (x,y) is the 
                                    #upper-left coordinates
                                    #of the image
pattern.set_matrix(matrix)
cr.set_source(pattern)              #replace cr with the name
                                    #of the cairo context

Last edited by skykooler; 2011-01-06 at 16:01.
 

The Following 2 Users Say Thank You to skykooler For This Useful Post: