question regarding use of inkscape for my own project
hello happy community,
I'm new-to/mixed-up-with SVG, and I'm starting my own SVG-friendly application. I need to load SVG files, modify/generate objects and their properties via API calls and render it in a buffer. While looking at cairo and librsvg to render SVG graphics, I realized (correct me if I'm wrong) their API didn't provide calls to access individual objects or their properties. Then I figured out using some existant app would be much smarter, as open source is starting to kick some serious mellons.
Then I saw inkscape and got very excited, because as a bonus, we get SVG extensions and automatic rendering technology updates and so on..
So my plan is to strip inkscape from its GUI part, or simply link the relevant CVS dirs to my own CVS, but this seems a bit harcodre to me and I'd like to hear your wisdom speak about this. (ex : which dirs/classes ? )
another thing I'd like is a table that looks like this :
loads SVG renders SVG has API to modify objects ksvg cairo libart librsvg
Just to make things as clear as possible, I need to :
- load svg files - access/transform individual objects through API (not GUI, I don't have one) ex : rotate(MyCube, 123)
- render it in some 32 bit pixel buffer (RGBA)
BTW, why is everyone is moving away from libart (inkscape, sodipodi)?
thanks, Julien Keable
On Tue, 8 Jun 2004, Julien Keable wrote:
hello happy community,
Hi Julien,
I'm new-to/mixed-up-with SVG, and I'm starting my own SVG-friendly application. I need to load SVG files, modify/generate objects and their properties via API calls and render it in a buffer. While looking at cairo and librsvg to render SVG graphics, I realized (correct me if I'm wrong) their API didn't provide calls to access individual objects or their properties. Then I figured out using some existant app would be much smarter, as open source is starting to kick some serious mellons.
That's correct, librsvg strives to be an efficient one-pass renderer.
I don't know exactly what you're shooting for, but another option would be to use an SVG generator like Perl's SVG.pm module, which provides access to generate and modify SVG objects, and then when you need to render it, save to a file and call librsvg to render it. Obviously, this would work ok for some needs but not for others.
Then I saw inkscape and got very excited, because as a bonus, we get SVG extensions and automatic rendering technology updates and so on..
So my plan is to strip inkscape from its GUI part, or simply link the relevant CVS dirs to my own CVS, but this seems a bit harcodre to me and I'd like to hear your wisdom speak about this. (ex : which dirs/classes ? )
Yes, it's quite hardcore but we'd definitely encourage this - breaking out the renderer from the GUI has been a longstanding TODO item.
Start by looking at the architectural diagram on the main website (in the docs area) as well as the SubsystemRearchitecture link in our Wiki. http://www.inkscape.org/cgi-bin/wiki.pl?SubsystemRearchitecture
another thing I'd like is a table that looks like this :
loads SVG renders SVG has API to modify objects
ksvg cairo libart librsvg
Just to make things as clear as possible, I need to :
- load svg files
- access/transform individual objects through API (not GUI, I don't have
one) ex : rotate(MyCube, 123)
Hmm, I would suggest you check out the Perl SVG.pm module before you get too far into Inkscape's internals. If you can make use of that, it'd save you a considerable amount of effort.
- render it in some 32 bit pixel buffer (RGBA)
BTW, why is everyone is moving away from libart (inkscape, sodipodi)?
It's got a lot of little gotchas and issues. For instance, there are error messages it prints to stderr that the application has no control over, so random things get spewed to stdout. In addition it's rendering code has proven unsatisfactory. Don't read too much into both sodipodi and inkscape moving away from it; this was something that we decided back before inkscape split from sodipodi.
Bryce
Thanks for the quick reply. I looked into SVG.pm and found no way to 1- load and 2- apply transformations to existing objects. Most important, I forgot to mention all this must be done in real time (~25fps) sparing the cpu as much as possible, so using perl is not an option (yes, I know about SVG animation but I can't use it... read on).
Ok, it's time to clarify things a bit :
I have an app that has it's own GUI. Basically, you connect modules together, building a dataflow graph with the nodes acting as filter/generators/renderers, and the connections carrying pieces of SVG information. Here's an example :
[square generator] --------> [rotate] --------> [renderer] ^ | [some changing control value] -|
when the graph is complete you press play and watch.
I already know about the concept SVG animations, however I cannot rely on them since the animation speed is fixed (eg : I want to be able to, say, rotate a box at a speed that is a sinusoidal wave, not constant). This kinda clashes with my concept of animation, but anyway... So what I want to do is animate with API calls like
setRotationAngle(MyBox, sin(time) ) (or myBox.setRotationAngle..... )
I think I said enough so you can tell me if using inkscape would be appropriate, and if so could you answer these questions please :
- am I correct when I assume inkscape already has all the API calls I'm looking for ? - how is the internal representation of the graphical objects organised ? As an XML document would be ? A tree? - how to strip the GUI part from the core of inkscape ? - when inkscape moves to cairo for rendering, will it use glitz ? if not, why so?
thanks again Julien
So bottom line, I guess I'll be joining the inkscape dev-team :). For now, I see my own roadmap like this :
- make a clear separation between GUI and core. (arghh.. will need help on that one.. ) - get an API that
On Tue, 8 Jun 2004, Julien Keable wrote:
hello happy community,
Hi Julien,
I'm new-to/mixed-up-with SVG, and I'm starting my own SVG-friendly application. I need to load SVG files, modify/generate objects and their properties via API calls and render it in a buffer. While looking at cairo and librsvg to render SVG graphics, I realized (correct me if I'm wrong) their API didn't provide calls to access individual objects or their properties. Then I figured out using some existant app would be much smarter, as open source is starting to kick some serious mellons.
That's correct, librsvg strives to be an efficient one-pass renderer.
I don't know exactly what you're shooting for, but another option would be to use an SVG generator like Perl's SVG.pm module, which provides access to generate and modify SVG objects, and then when you need to render it, save to a file and call librsvg to render it. Obviously, this would work ok for some needs but not for others.
Then I saw inkscape and got very excited, because as a bonus, we get SVG extensions and automatic rendering technology updates and so on..
So my plan is to strip inkscape from its GUI part, or simply link the relevant CVS dirs to my own CVS, but this seems a bit harcodre to me and I'd like to hear your wisdom speak about this. (ex : which dirs/classes ? )
Yes, it's quite hardcore but we'd definitely encourage this - breaking out the renderer from the GUI has been a longstanding TODO item.
Start by looking at the architectural diagram on the main website (in the docs area) as well as the SubsystemRearchitecture link in our Wiki. http://www.inkscape.org/cgi-bin/wiki.pl?SubsystemRearchitecture
another thing I'd like is a table that looks like this :
loads SVG renders SVG has API to modify objects
ksvg cairo libart librsvg
Just to make things as clear as possible, I need to :
- load svg files
- access/transform individual objects through API (not GUI, I don't have
one) ex : rotate(MyCube, 123)
Hmm, I would suggest you check out the Perl SVG.pm module before you get too far into Inkscape's internals. If you can make use of that, it'd save you a considerable amount of effort.
- render it in some 32 bit pixel buffer (RGBA)
BTW, why is everyone is moving away from libart (inkscape, sodipodi)?
It's got a lot of little gotchas and issues. For instance, there are error messages it prints to stderr that the application has no control over, so random things get spewed to stdout. In addition it's rendering code has proven unsatisfactory. Don't read too much into both sodipodi and inkscape moving away from it; this was something that we decided back before inkscape split from sodipodi.
Bryce
On Tue, 8 Jun 2004, Julien Keable wrote:
Thanks for the quick reply. I looked into SVG.pm and found no way to 1- load and 2- apply transformations to existing objects. Most important, I forgot to mention all this must be done in real time (~25fps) sparing the cpu as much as possible, so using perl is not an option (yes, I know about SVG animation but I can't use it... read on).
Ah, yes, in that circumstance SVG.pm wouldn't work for what you need. Have you tried using Cairo? Perhaps that is better suited?
Ok, it's time to clarify things a bit :
I have an app that has it's own GUI. Basically, you connect modules together, building a dataflow graph with the nodes acting as filter/generators/renderers, and the connections carrying pieces of SVG information. Here's an example :
[square generator] --------> [rotate] --------> [renderer] ^ | [some changing control value] -|
when the graph is complete you press play and watch.
I already know about the concept SVG animations, however I cannot rely on them since the animation speed is fixed (eg : I want to be able to, say, rotate a box at a speed that is a sinusoidal wave, not constant). This kinda clashes with my concept of animation, but anyway... So what I want to do is animate with API calls like
setRotationAngle(MyBox, sin(time) ) (or myBox.setRotationAngle..... )
I think I said enough so you can tell me if using inkscape would be appropriate, and if so could you answer these questions please :
- am I correct when I assume inkscape already has all the API calls I'm
looking for ?
It does have calls for performing manipulations like this, yes, but it would not really be honest to describe them as API's. There is no interface document, nor ways to easily access the calls external from Inkscape. So unfortunately the best answer would be, "No, not without a lot of digging..."
- how is the internal representation of the graphical objects organised
? As an XML document would be ? A tree?
Yes, and in fact this internal representation is one of the codebases' very interesting features. It is implemented as a DOM 'repr' that contains everything in an object tree, including attributes and references. It's quite sophisticated and powerful. There is some documentation about this but not nearly as much as one would need.
- how to strip the GUI part from the core of inkscape ?
Mental and Nathan have tried stripping the GUI part off of it once before; they'd be the best to answer this. As I understand it, there is not a sufficiently clean separation between the interface and the renderer to make this trivial, but it did not sound impossible.
- when inkscape moves to cairo for rendering, will it use glitz ? if
not, why so?
I don't know; Mental might know, but to be honest we haven't dug very far into investigating Cairo yet. If you choose to use Cairo we'd be very interested in hearing about your experiences with it.
Bryce
On Tue, 2004-06-08 at 20:30, Bryce Harrington wrote:
[some changing control value] -|
when the graph is complete you press play and watch.
I already know about the concept SVG animations, however I cannot rely on them since the animation speed is fixed (eg : I want to be able to, say, rotate a box at a speed that is a sinusoidal wave, not constant). This kinda clashes with my concept of animation, but anyway... So what I want to do is animate with API calls like
setRotationAngle(MyBox, sin(time) ) (or myBox.setRotationAngle..... )
If you're not familiar with the SVG DOM (http://www.w3.org/TR/SVG11/svgdom.html) I think that's basically what you want. (though the interface for many things is not so simple)
We don't implement any W3C DOM yet.
- am I correct when I assume inkscape already has all the API calls I'm
looking for ?
It does have calls for performing manipulations like this, yes, but it would not really be honest to describe them as API's. There is no interface document, nor ways to easily access the calls external from Inkscape. So unfortunately the best answer would be, "No, not without a lot of digging..."
There is some of this, but the APIs we inherited from Sodipodi require a lot of direct manipulation of textual attributes, and we are only slowly adding more convenient interfaces on top ourselves.
- how is the internal representation of the graphical objects organised
? As an XML document would be ? A tree?
Yes, and in fact this internal representation is one of the codebases' very interesting features. It is implemented as a DOM 'repr' that contains everything in an object tree, including attributes and references. It's quite sophisticated and powerful. There is some documentation about this but not nearly as much as one would need.
Any given SVG object is represented by three classes:
SPRepr (xml syntax) ["backing store" as XML data]
SPObject (SVG semantics) [cache for efficient editing/rendering]
NRArenaItem (simple renderable object) [one per view]
- how to strip the GUI part from the core of inkscape ?
Mental and Nathan have tried stripping the GUI part off of it once before; they'd be the best to answer this. As I understand it, there is not a sufficiently clean separation between the interface and the renderer to make this trivial, but it did not sound impossible.
It really depends on how much of Inkscape he wants. I think the entire SPObject/SPDocument layer, SPRepr layer, libnr/libnrtype, inkscape-livarot, and NRArena layer can be extracted together _relatively_ cleanly.
(though I've not tried it)
Trying to extract smaller pieces would likely prove very difficult.
Also be aware that our internal APIs are currently under heavy flux, and will probably continue to be until version ~0.9 or so.
- when inkscape moves to cairo for rendering, will it use glitz ? if
not, why so?
I don't know; Mental might know, but to be honest we haven't dug very far into investigating Cairo yet. If you choose to use Cairo we'd be very interested in hearing about your experiences with it.
I would like us to use cairo with glitz someday if we could. Neither it nor our own code is mature enough yet to attempt it, however. Hardware acceleration (could) be a big win.
For now we're probably best off using our own renderer (which seems to be fast enough for most users), until we implement the complete set of rendering features required by SVG (notably things like filter effects). system.
-mental
MenTaLguY wrote:
- how to strip the GUI part from the core of inkscape ?
Mental and Nathan have tried stripping the GUI part off of it once before; they'd be the best to answer this. As I understand it, there is not a sufficiently clean separation between the interface and the renderer to make this trivial, but it did not sound impossible.
It really depends on how much of Inkscape he wants. I think the entire SPObject/SPDocument layer, SPRepr layer, libnr/libnrtype, inkscape-livarot, and NRArena layer can be extracted together _relatively_ cleanly.
(though I've not tried it)
Trying to extract smaller pieces would likely prove very difficult.
Also be aware that our internal APIs are currently under heavy flux, and will probably continue to be until version ~0.9 or so.
On the other hand, if someone made the effort to cleanly separate the two, I think we could make the effort to maintain the separation.
njh
Julien Keable wrote:
hello happy community,
I'm new-to/mixed-up-with SVG, and I'm starting my own SVG-friendly application. I need to load SVG files, modify/generate objects and their properties via API calls and render it in a buffer. While looking at cairo and librsvg to render SVG graphics, I realized (correct me if I'm wrong) their API didn't provide calls to access individual objects or their properties. Then I figured out using some existant app would be much smarter, as open source is starting to kick some serious mellons.
Have you considered Apache Batik? If you're able to use java then it is designed for just what you want, and has pretty much the fullest implementation of SVG you'll find. http://xml.apache.org/batik/
John
Julien Keable wrote:
hello happy community,
I'm new-to/mixed-up-with SVG, and I'm starting my own SVG-friendly application. I need to load SVG files, modify/generate objects and their properties via API calls and render it in a buffer. While looking at cairo and librsvg to render SVG graphics, I realized (correct me if I'm wrong) their API didn't provide calls to access individual objects or their properties. Then I figured out using some existant app would be much smarter, as open source is starting to kick some serious mellons.
Have you considered Apache Batik? If you're able to use java then it is just what you want, and has pretty much the fullest implementation of SVG you'll find. http://xml.apache.org/batik/
John
On Tue, 2004-06-08 at 04:59, John Pybus wrote:
Have you considered Apache Batik? If you're able to use java then it is just what you want, and has pretty much the fullest implementation of SVG you'll find. http://xml.apache.org/batik/
Batik is very complete and very much what he wants ... the only caveat is that it's quite slow :/
-mental
participants (5)
-
Bryce Harrington
-
John Pybus
-
Julien Keable
-
MenTaLguY
-
Nathan Hurst