Generating Bar Sets with Unix Scripts

   



Converting Proprietary Files to SVG with Perl

The text file  proprietary1.xyz (note the suffix of this file) in Listing 17.11 contains a proprietary format for a fictitious company.

Listing 17.11 proprietary1.xyz

start example
########################################## # This file is based on a proprietary # format for a fictitious company XYZ # # Supported objects include the following: # circle # rectangle # polygon # ########################################## START DEFINITION ID:   CIRCLE0 TYPE: CIRCLE centerx:100 centery:80 radius:20 style { fill:blue stroke:yellow stroke-width:2 } END DEFINITION START DEFINITION ID:   RECT0 TYPE: RECT width:200 height:100 xcoordinate:200 ycoordinate:200 style { fill:red stroke:green stroke-width:4 } END DEFINITION
end example

The SVG document in Listing 17.12 is generated when the Perl script  convert1.pl is invoked on the text file  proprietary1.xyz.

Listing 17.12 proprietary1.svg

start example
<svg width="100%" height="100%"> <g> <circle  style="stroke:yellow;fill:blue;stroke-width:2;" cx="100" cy="80" r="20" /> <rect  style="stroke:green;fill:red;stroke-width:4;" y="200" height="100" width="200" x="200" /> </g> </svg>
end example

Remarks

You can generate the SVG document from the following command:

perl -w convert1.pl >proprietary1.svg 

The Perl script  convert1.pl will not be covered because it contains 300 lines of code; it uses Perl arrays, hashes, functions, and file manipulation. If you read the Perl appendix, you will be able to understand the code. You can find this script in the folder for this chapter on the CD-ROM.



   



Fundamentals of SVG Programming. Concepts to Source Code
Fundamentals of SVG Programming: Concepts to Source Code (Graphics Series)
ISBN: 1584502983
EAN: 2147483647
Year: 2003
Pages: 362

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net