Python 3 bindings for the Cairo graphics library
Python 3 bindings for the Cairo graphics library
py3cairo$ python3 -c "import cairo; surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, 100, 100); ctx = cairo.Context(surface); ctx.arc(50, 50, 40, 0, 6.28); ctx.stroke(); surface.write_to_png('circle.png')"$ python3 -c "import cairo; surface = cairo.PDFSurface('output.pdf', 200, 200); ctx = cairo.Context(surface); ctx.set_font_size(20); ctx.move_to(10, 30); ctx.show_text('Hello Cairo'); surface.finish()"$ python3 -c "import cairo; s = cairo.ImageSurface(cairo.FORMAT_ARGB32, 200, 200); c = cairo.Context(s); c.set_source_rgb(0.5, 0.2, 0.8); c.rectangle(20, 20, 160, 160); c.fill(); s.write_to_png('rect.png')"