NAME
Image::Base::SVG -- SVG image file output
SYNOPSIS
use Image::Base::SVG;
my $image = Image::Base::SVG->new (-width => 100,
-height => 100);
$image->rectangle (0,0, 99,99, 'black');
$image->xy (20,20, 'green');
$image->line (50,50, 70,70, 'red');
$image->line (50,50, 70,70, 'blue');
$image->save ('/some/filename.svg');
CLASS HIERARCHY
Image::Base::SVG is a subclass of Image::Base,
Image::Base
Image::Base::SVG
DESCRIPTION
Image::Base::SVG extends Image::Base to create or update SVG format image files using the SVG module. The SVG module holds the contents of an SVG file in memory as an object which can be variously manipulated. See SVG::Manual for details.
Image::Base is pixel oriented so isn't really the sort of thing SVG is meant for, but this module can direct Image::Base style code at an SVG object. The SVG module has many more features if used natively.
It's often fairly easy to spit out SVG directly too, and for instance the Image::Base::SVGout module can do that. The advantage of the SVG object comes when combining images or fragments, or going through elements for post-facto mangling.
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.
Colours
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
FUNCTIONS
See "FUNCTIONS" in Image::Base for the behaviour common to all Image-Base classes.
$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
-widthand-heightshould be set, but it works to do that later after creating.Or an existing
SVGobject 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
undefas there's no support for picking out elements etc from the SVG. Perhaps the simple elements drawn by thisImage::Base::SVGcould be read back, but arbitrary SVG from aload()would need a full rasterize in the worst case. $image->load ()$image->load ($filename)-
Load an SVG file into
$image, either from the current-fileattribute, or set that to$filenamethen load.This uses the
SVG::Parsermodule. See that module for how to choose between Expat or SAX for its underlying XML parse, and see in turn XML::SAX for its further choice of libxml, pure perl, etc. LibXML might be unhelpfully strict. $image->save ()$image->save ($filename)-
Save the image to an SVG file, either the current
-fileoption, or set that option to$filenameand save to there.
ATTRIBUTES
-width(integer)-height(integer)-
Setting
-widthor-heightchanges the SVG canvas size. In the current code it doesn't affect the elements already drawn to it. Is that how it should be?
SEE ALSO
Image::Base, SVG, SVG::Manual, SVG::Parser
HOME PAGE
http://user42.tuxfamily.org/image-base-svg/index.html
LICENSE
Image-Base-SVG is Copyright 2011, 2012, 2019 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/>.