Image::Base::SVG -- SVG image file output
use Image::Base::SVG; my $image = Image::Base::SVG->new (-width => 100, -height => 100); $image->rectangle (0,0, 99,99, 'b'); $image->xy (20,20, 'o'); $image->line (50,50, 70,70, 'o'); $image->line (50,50, 70,70, 'o'); $image->save ('/some/filename.svg');
Image::Base::SVG is a subclass of Image::Base,
Image::Base::SVG
Image::Base
Image::Base Image::Base::SVG
Image::Base::SVG extends Image::Base to create or update SVG format image files using the SVG.pm module (see SVG::Manual).
SVG.pm
Image::Base is pixel oriented so isn't really the sort of thing SVG is meant for, but this module can direct some Image::Base style code at an SVG object. Of course the SVG module has many more features if used natively.
SVG
It's often fairly easy to spit out SVG directly too, and for instance the Image::Base::SVGout module can do that. The advantages of the SVG document object model comes when combining images or fragments, or going through elements for post-facto mangling.
Image::Base::SVGout
In the current code the SVG elements emitted assume some default style attributes such as stroke-width 1. Perhaps that should be set explicitly on each element.
Colour names are per the SVG spec, which is CSS style syntax
#RGB hex, 1 digit #RRGGBB hex, 2 digit rgb(255,255,255) integers 0 to 255 rgb(100%,100%,100%) percentages http://www.w3.org/TR/2008/REC-CSS2-20080411/syndata.html#value-def-color
plus extra names
http://www.w3.org/TR/2003/REC-SVG11-20030114/types.html#ColorKeywords
$image = Image::Base::SVG->new (key=>value,...)
Create and return a new image object. A new image can be started with just
$image = Image::Base::SVG->new;
Generally -width and -height should be set, but it works to do that later after creating.
-width
-height
Or an existing SVG object can be given,
my $svg = SVG->new; ... $image = Image::Base::SVG->new (-svg_object => $svg);
$image->xy ($x, $y, $colour)
$colour = $image->xy ($x, $y)
Get or set an individual pixel.
Currently for a get the return is always undef as there's no support for picking out elements etc from the SVG. Perhaps the simple elements drawn by this Image::Base::SVG could be read back, but arbitrary SVG from a load() would need a full rasterize in the worst case.
undef
load()
$image->load ()
$image->load ($filename)
Load an SVG file into $image, either from the current -file attribute, or set that to $filename then load.
$image
-file
$filename
This uses the SVG::Parser module. See that module for how to choose between Expat or SAX for its underlying XML parse, and in turn see XML::SAX for its further choice of libxml, pure perl, etc. LibXML might be unhelpfully strict.
SVG::Parser
$image->save ()
$image->save ($filename)
Save the image to an SVG file, either the current -file option, or set that option to $filename and save to there.
Setting -width or -height changes the SVG canvas size. In the current code it doesn't affect the elements already drawn to it. Is that how it should be?
Image::Base, SVG, SVG::Manual, SVG::Parser
http://user42.tuxfamily.org/image-base-svg/index.html
Image-Base-SVG is Copyright 2011 Kevin Ryde
Image-Base-SVG is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version.
Image-Base-SVG is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with Image-Base-SVG. If not, see <http://www.gnu.org/licenses/>.
To install Image::Base::SVG, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Image::Base::SVG
CPAN shell
perl -MCPAN -e shell install Image::Base::SVG
For more information on module installation, please visit the detailed CPAN module installation guide.