Canvas SVG parser: Difference between revisions

Jump to navigation Jump to search
layout; moving up a suitable first section
m (http://forum.flightgear.org/viewtopic.php?f=71&t=25173&p=238173#p238173)
(layout; moving up a suitable first section)
Line 1: Line 1:
{{Stub}}
{{Infobox subsystem
{{Infobox subsystem
|name        = Scripted SVG parser for Canvas
|name        = Scripted SVG parser for Canvas
Line 13: Line 16:
{{Template:Canvas Navigation}}
{{Template:Canvas Navigation}}


=== Vector Image Support ===
{{Stub}}


The SVG parser basically just maps the xml structure to the property tree. It is implemented in Nasal on top of the XML parsing facilities already provided by FlightGear. Using separate canvas elements instead of a single image will always be slower as every little piece of the canvas hat to be triangulated and afterwards rendered every time the canvas gets updated instead of just copying an image. On the other hand you if you use the canvas you can dynamically update the contents of the image and also get (theoretically) unlimited resolution, even changeable at runtime. For SVG, already existing tools (Inkscape) can be used to create images and then just load them via Nasal and add some dynamic features to them.
The '''scripted SVG parser''' basically just maps the SVG xml structure to the property tree. It is implemented in Nasal on top of the XML parsing facilities already provided by FlightGear.
 
== Vector Image Support ==
Using separate canvas elements instead of a single image will always be slower as every little piece of the canvas hat to be triangulated and afterwards rendered every time the canvas gets updated instead of just copying an image. On the other hand you if you use the canvas you can dynamically update the contents of the image and also get (theoretically) unlimited resolution, even changeable at runtime. For SVG, already existing tools (Inkscape) can be used to create images and then just load them via Nasal and add some dynamic features to them.


If you find some SVG feature not working, please check the console for errors - our SVG parser is hand-written and only supports a limited subset of SVG instructions, so may need to be extended, or simply use supported inkscape primitives instead (see svg.nas). $FG_ROOT/Nasal/canvas/svg.nas is our existing example on populating a canvas procedurally by parsing an XML file.
If you find some SVG feature not working, please check the console for errors - our SVG parser is hand-written and only supports a limited subset of SVG instructions, so may need to be extended, or simply use supported inkscape primitives instead (see svg.nas). $FG_ROOT/Nasal/canvas/svg.nas is our existing example on populating a canvas procedurally by parsing an XML file.

Navigation menu