All pastes #59950 Raw Edit

Something

public text v1 · immutable
#59950 ·published 2006-05-30 15:57 UTC
rendered paste body
#!/usr/bin/python

from mod_python import apache
import cairo
import cStringIO

WIDTH, HEIGHT = 400, 300

def handler (req):
        # generate a png with cairo
        surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, WIDTH, HEIGHT)
        ctx = cairo.Context(surface)

        ctx.move_to (200,100)
        ctx.line_to (200,200)

        ctx.stroke ()

        req.content_type = "image/png"

        surface.write_to_png(req)
        return apache.OK