Objective Cairo

federico.pelloni at gmail.com federico.pelloni at gmail.com
Wed Mar 22 12:02:31 EST 2006


As pycairo is one of the less pythonish things I ever saw, it went into
my mind to create some sort of objective wrapper over its python api
making graphic manipulation much more coherent to the python way.

As of the moment, I can:
 - create (and reorder) multiple layers (this is not present in the
original cairo, but it is an easy addiction)
 - draw, move and delete Rectangles, Lines and (simple) Texts

This is particularly useful when combined with user interaction: I
wrote a simple demo that, without redrawing everything, allows me to
move a square up and down my canvas by pressing some buttons.

Before going on with more complex forms and objects, I was wondering if
this could be useful to anyone or if I'd better giving up.

A few example lines:

import objcairo
context = objcairo.Context()
layer = context.Layer()
rect = layer.Rectangle(10, 10, 200, 100)
rect.stroke((1,0,0))
rect.fill((0,1,0))
rect.move_down(20)
context.draw(some_cairo_context)

So, what do you think?




More information about the Python-list mailing list