Manipulate SVG 2D Graphics programmatically with GPAC
If you publish a scientific work based on GPAC thank you to mention in the article, mentioning "GPAC: open source multimedia framework" (DOI: 10.1145/1291233.1291452)
GPAC is a framework, focused on multimedia development, developed by Telecom ParisTech. GPAC is an Open Source project hosted on sourceforge.
GPAC has excellent SVG support. (look at the Show grid implementations of SVG).
This note is a start point for a series on the use of the GPAC library for manipulating SVG documents programmatically. The first note is about creating a SVG scene by C program and its backup as a file.
Create SVG
Create a scenegraph
Basically, a SceneGraph? is the object used by the Gpac library to manipulate a graphic scene. The same object is used for MPEG-4 BIFS, Laser, SVG.
Declaration:
GF_SceneGraph * sg;
Object creation:
sg = gf_sg_new ();
Now we are ready to put things in the sg object.
Create the root of the SVG document
SVG elements are handled in the GPAC type SVG_Element. We will create such an element, which we call root as the root SVG document.
Here, we show that we create the element in the scene graph sg created earlier and that the element created must be of type TAG_SVG_svg. The constants used are defined in the file nodes_svg.h. The constants name is constructed with the prefix TAG_SVG_ followed by the name of the corresponding SVG element. For example, TAG_SVG_circle for the element circle, TAG_SVG_text for the text element.
The object is created. As it is the root of our SVG document, this particular role must be reported to GPAC by the following call:
gf_sg_set_root_node(sg, (GF_Node *)root);
In addition, each object created should be recorded at its parent (we shall see later that this is useful in the reuse of objects). As the root has no parent, we pass NULL as parameter. The call is:
No comments:
Post a Comment