#!/usr/bin/python import cairo from math import pi SCALE = 25 ROTATE = 0 #ROTATE = pi / 4 # Create a 2x2 blue+red checker checker = cairo.ImageSurface(cairo.FORMAT_ARGB32, 2, 2) cr = cairo.Context(checker) cr.set_source_rgb(1, 0 ,0) # red cr.paint() cr.set_source_rgb(0, 0 ,1) # blue cr.rectangle(0, 1, 1, 1) cr.rectangle(1, 0, 1, 1) cr.fill() # Create the destination surface dest = cairo.ImageSurface(cairo.FORMAT_RGB24, 6 * SCALE, 6 * SCALE) cr = cairo.Context(dest) # Draw our surface scaled with EXTEND_NONE cr.save() cr.translate(3 * SCALE, 3 * SCALE) cr.scale(SCALE, SCALE) cr.rotate(ROTATE) cr.translate(-1, -1) cr.set_source_surface(checker, 0, 0) cr.paint() cr.restore() dest.write_to_png("extend-none.png")