[cairo] Editing SVG content with Cairo

影月 零 kagetsuki at gmail.com
Sun Jan 5 04:11:04 PST 2014


OK, that sort of clears things up for me. It still confuses me how an SVG
can be loaded with this:
http://cairographics.org/documentation/cairomm/reference/classCairo_1_1SvgSurface.html
and rendered by Cairo without actually breaking down the DOM at some point
and, if that is happening, why it isn't converted into native objects or
data structures which would be accessible.

What I need isn't necessarily a scene graph in whole as I need no actual
rendering capability. I really just need to be able to manipulate the SVG
data and I would like to do that in an object-oriented and language-native
way, rather than hacking through XML with an XML library like Nokogiri.
That no library like this seems to exist surprises me. I was really
expecting to find something like COLLADA DOM (but hopefully easier to use)
for SVG.

For now I'll just hack the XML as I really only need to change colors. It
feels like a poor way to do it but I guess I have no choice. Thanks for the
help anyway!

-Rei


2014/1/5 David Young <dyoung at pobox.com>

> On Sat, Jan 04, 2014 at 12:46:58PM +0900, 影月 零 wrote:
> > I mean open the SVG, then iterate through all the vector objects in it
> and
> > alter them somehow; like change the color attribute or make all their
> lines
> > into dashed lines.
> >
> > To be more sepcific, I would like to be able to open an SVG, iterate
> > through each vector object in it applying some change along the way, then
> > write out a new SVG.
> >
> > At the moment I'm using RSVG[2] and Cairo, but I'm assuming it's Cairo
> that
> > does all the actual image manipulation. I guess my question could also be
> > re-phrased as:
> > Does Cairo or any other library re-instantiate objects from items in the
> > DOM of an SVG file when it opens them? If so where are they and how can I
> > iterate over them?
>
> It sounds like you're looking for the "scene graph,"
> <http://en.wikipedia.org/wiki/Scene_graph>, corresponding to the SVG.
> AFAIK, Cairo isn't based on a scene graph.
>
> Dave
>
> --
> David Young
> dyoung at pobox.com    Urbana, IL    (217) 721-9981
> --
> cairo mailing list
> cairo at cairographics.org
> http://lists.cairographics.org/mailman/listinfo/cairo
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cairographics.org/archives/cairo/attachments/20140105/7f27d23e/attachment.html>


More information about the cairo mailing list