Methods of Converting VG Graphics to SVG Graphics

       

       In the project, the tpl file created by Visual Graph , that is, the VG file, needs to be converted into the html general label file svg format, so a conversion tool is specially made. I can't find similar tools available on the Internet, maybe because there are too few projects in this area. Therefore, I invented a new method to convert VG graphics to SVG graphics, which solved the above technical problems.

 

       First, compare the VG file and SVG file:

      same:

       1. Both are based on xml syntax ( the xml syntax format will not be written here).

       2. The basic graphic definition names are common, for example, line , text , rect , circle , etc. are all the same name.

       3, are based on coordinate layout.

      different:

       1. The root element is different, one is vg and the other is svg .

       2. The relative points are different, vg is the origin coordinate like a spread out layout on all sides, svg is spread out with the upper left corner as the origin and the lower right corner.

       3. There are too many different attributes for different graphics attributes, which is also the core of the converter.

 

       Steps to implement the converter:

       1. Load the vg graphic file.

       2. Identify the scope of the vg graphic file and calculate the converted svg origin coordinates.

       3. Start to convert the vg graphic elements, and convert them into svg graphic elements according to the conversion rules .

       4. Create the svg file, add the converted elements to the new file, and output the new file.

 

       Detailed explanation of step 3:

       After obtaining the graphics, different graphics are processed differently, the coordinates of the graphics are converted according to the origin coordinates, and the style is rotated.

 

       The present invention forms a complete set of technologies by organically integrating generating SVG graphics. By loading VG graphics, to convert the corresponding SVG graphics. The key of the present invention is to read the content in the VG graphics, and to be able to intelligently identify each element. Then, through the rule base of the program , the SVG components in the rule base are compared. The comparison content includes component name, number, color, location, etc., and finally generates a new SVG image . To convert VG graphics, the method of SVG model file is successfully adopted , which can effectively unify technical specifications. The principle is to convert each VG graphic, put the data content into the model file, and finally generate a new SVG graphic uniformly. 

 

         Through the method, the problem that designers only have VG graphics but no SVG graphics required can be well solved, which brings many conveniences to designers .

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326600219&siteId=291194637