Practical Example Program import cairo import math WIDTH, HEIGHT = 400, 400 surface = cairo.ImageSurface (cairo.FORMAT_ARGB32, WIDTH, HEIGHT) ctx = cairo.Context (surface) # Blue rectangle translated ctx.translate (100, 50) ctx.rectangle (0,0,100,50); ctx.set_source_rgb (0,0,1); ctx.fill () ctx.identity_matrix () # reset transformations # Red rotated rectangle ctx.translate (200,200); ctx.rotate ( math.radians (45)) ctx.rectangle (-50,-25,100,50); ctx.set_source_rgb (1,0,0); ctx.fill () ctx.identity_matrix () # Green scaled rectangle ctx.save (); ctx.translate (50,300); ctx.scale (2,0.5) ctx.rectangle (0,0,50,50); ctx.set_source_rgb (0,1,0); ctx.fill (); ctx.restore () # Purple combined transform rectangle ctx.save (); ctx.translate (300,300); ctx.rotate ( math.radians (30)); ctx.scale (1.5,1) ctx.rectangle (-50,-25,100,50); ctx.set_source_rgb (0.5,0,0.5); ctx.fill (); ctx.restore () surface.write_to_png ('transformations.png')