Objective Cairo

F

federico.pelloni

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?
 
P

Paul Boddie

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.
[...]

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.

What you've done looks interesting. However, before venturing too far,
I'd recommend looking at the other graphics APIs for Python and keeping
as compatible as possible to the way they do things (without offending
your sense of "Pythonicity" or conflicting with the Cairo mechanisms,
of course). Sadly, I'm not really up-to-date with what people use for
canvas-style drawing in Python - once upon a time there was the Piddle
project, renamed to Sping, and then seemingly abandoned - but I'm sure
a few people can suggest similar projects.

Keep up the good work, though!

Paul
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top