[cairo] DOM manipulation

Carl Worth cworth at east.isi.edu
Thu Mar 18 10:59:59 PST 2004


On Feb 28, Rob Kaper wrote:
 > I've got a quick question on Cairo features [...]

I'm sorry, but I'm afraid I didn't catch what your question is. Could
you restate it if necessary? I'll try to guess what it might have been
and answer as best I can.

 > I'm planning to utilize SVG to render the board layout of board games and
 > want to manipulate the DOM of an SVG image loaded from file to perform tasks
 > such as:

You should be able to write code to do this kind of thing using
cairo. We've already got one cairo-using SVG library (libsvg-cairo)
at:

	http://xsvg.org

It does not currently provide a DOM-like API, but that could be added
if someone were so inclined.

 > - changing the color of a certain element

I should mention here that cairo is an immediate-mode drawing API. So
at the level of the cairo interface, you don't have elements that have
been drawn whose colors could be changed, (instead there's just a
current color which will be used for the next object drawn).

But the kind of retained-mode interface you describe here could be
layered on top of cairo.

 > - requesting coordinates, as rendered, of an element, to calculate waypoints
 >   for tokens

If I understand this correctly, then the cairo_current_path function
should provide everything you need here. (Hmm... you might need
cairo_stroke_path too which has not yet been implemented).

 > KDE/Qt/C++ bindings would be a requirement of course, so hopefully showing
 > some interest in Cairo as KDE developer might motivate work in that area and
 > obviously I'm willing to do the necessary testing and debugging work.

I did see a reference one to C++ cairo bindings for KDE. But that code
was never contributed to the cairo CVS tree and I didn't save the link
to it. If someone has a reference to it, I'd be glad to add a pointer
to the web page.

-Carl




More information about the cairo mailing list