471,055 Members | 1,891 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,055 software developers and data experts.

Objective Cairo

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?

Mar 22 '06 #1
1 1442
fe**************@gmail.com wrote:
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

Mar 22 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by j_mckitrick | last post: by
2 posts views Thread by David | last post: by
reply views Thread by Michax | last post: by
reply views Thread by _wolf | last post: by
2 posts views Thread by flagos | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.