SVG::SVG2zinc - a module to display or convert svg files in scripts, classes, images...
use SVG::SVG2zinc; &SVG::SVG2zinc::parsefile('file.svg', 'Backend','file.svg', -out => 'outfile', -verbose => $verbose, -namespace => 0|1, -prefix => 'string', ); # to generate a Perl script: &SVG::SVG2zinc::parsefile('file.svg','PerlScript', -out => 'file.pl'); # to generate a Perl Class: &SVG::SVG2zinc::parsefile('file.svg','PerlClass', -out => 'Class.pm'); # to display a svgfile: &SVG::SVG2zinc::parsefile('file.svg', 'Display'); #To convert a svgfile in png/jpeg file: &SVG::SVG2zinc::parsefile('file.svg', 'Image', -out => 'file.jpg'); # to generate a Tcl script: &SVG::SVG2zinc::parsefile('file.svg','TclScript', -out => 'file.tcl');
Depending on the used Backend, &SVG::SVG2zinc::parsefile either generates a Perl Class, Perl script, Tcl Script, bitmap images or displays SVG files inside a Tk::Zinc widget.
SVG::SVG2zinc could be extended to generate Python scripts and/or classes, or other files, just by sub-classing SVG::SVG2zinc::Backend(3pm)
==head1 HOW IT WORKS
This converter creates some TkZinc items associated to most SVG tags. For example, <SVG> or <G> tags are transformed in TkZinc groups. <PATH> are converted in TkZinc curves.... many more to come...
==head2 TkZinc items tags
Every TkZinc item created by the parser get one or more tags. If the corresponding svg tag has an Id, this Id will be used as a tag, after some cleaning due to TkZinc limitation on tag values (no dot, star, etc...). If the corresponding svg tag has no Id, the parser add a tag of the following form : __<itemtype>__<integer>. If the parser is provided a -prefix option, the prefix is prepended to the tag: <prefix>__<itemtype>__<integer>
The TkZinc group associated to the top <SVG> tag has the following tag 'svg_top', as well as 'width=integer' 'heigth=integer' tags if width and height are defined in the top <SVG> tag. These tags can be used to find the group and to get its desired width and height.
==head2 RunTime code
There is currently on new Tk::Zinc method needed when executing perl code generated. This perl Tk::Zinc::adaptViewport function should be translated and included or imported in any script generated in an other scripting language (eg. Tcl or Python).
Some limitations are due to differences between Tk::Zinc and SVG graphic models :
Drawing width are zoomed in SVG but are not in Tk::Zinc where it is constant whatever the zoom factor is.
Gradient Transformation is not possible in Tk::Zinc. May be it could be implemented by the converter?
Rectangles cannot have rounded corners in Tk::Zinc. Could be implemented, by producing curve item rather than rectangles in Tk::zinc. Should be implemented in a future release of Tk::Zinc
Skew and Matrix transforms are not yet available in Tk::Zinc 3.295. Hopefully they should be available in a future release.
Text and tspan tags are very complex items in SVG, for example placement can be very precise and complex. Many such features are difficult to implement in Tk::Zinc and are not currently implemented
Font management is still limited. It will be rotatable and zoomable in future release of Tk::Zinc. SVG fonts included in a document are not readed, currently.
No image filtering functions are (and will be) available with Tk::Zinc, except if YOU want to contribute?
The SVG ClipPath tag is a bit more powerfull than Tk::Zinc clipping (clipper is limited to one item). So currently this is not implemented at all in SVG::SVG2zinc
There are also some limitations due to the early stage of the converter:
CSS in external url is not yet implemented
No animation is currently available, neither scripting in the SVG file. But Perl or Tcl are scripting languages,
The SVG switch tag is only partly implemented, but should work in most situations
href for images can only reference a file in the same directory than the SVG source file.
It was said there is still one hidden bug... but please patch and/or report it to the author! Any (simple ?)
SVG file not correctly rendered by this module (except for limitations listed previously) could be send to the author with little comments about the expected rendering and observed differences.
svg2zinc.pl(1) a sample script using and demonstrating SVG::SVG2zinc
SVG::SVG2zinc::Backend(3pm) to defined new backends.
Tk::Zinc(3) TkZinc is available at www.openatc.org/zinc/
Christophe Mertz <mertz@cena.fr>
many patches and extensions from Alexandre Lemort <lemort@intuilab.com>
helps from Celine Schlienger <celine@intuilab.com> and Stéphane Chatty <chatty@intuilab.com>
CENA (C) 2002-2003
This program is free software; you can redistribute it and/or modify it under the term of the LGPL licence.
1 POD Error
The following errors were encountered while parsing the POD:
Non-ASCII character seen before =encoding in 'Stéphane'. Assuming CP1252
To install SVG::SVG2zinc, copy and paste the appropriate command in to your terminal.
cpanm
cpanm SVG::SVG2zinc
CPAN shell
perl -MCPAN -e shell install SVG::SVG2zinc
For more information on module installation, please visit the detailed CPAN module installation guide.