.\" Automatically generated by Pod::Man 2.28 (Pod::Simple 3.28)
.\"
.\" Standard preamble:
.\" ========================================================================
.de Sp \" Vertical space (when we can't use .PP)
.if t .sp .5v
.if n .sp
..
.de Vb \" Begin verbatim text
.ft CW
.nf
.ne \\$1
..
.de Ve \" End verbatim text
.ft R
.fi
..
.\" Set up some character translations and predefined strings. \*(-- will
.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
.\" double quote, and \*(R" will give a right double quote. \*(C+ will
.\" give a nicer C++. Capital omega is used to do unbreakable dashes and
.\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff,
.\" nothing in troff, for use with C<>.
.tr \(*W-
.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
.ie n \{\
. ds -- \(*W-
. ds PI pi
. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
. ds L" ""
. ds R" ""
. ds C` ""
. ds C' ""
'br\}
.el\{\
. ds -- \|\(em\|
. ds PI \(*p
. ds L" ``
. ds R" ''
. ds C`
. ds C'
'br\}
.\"
.\" Escape single quotes in literal strings from groff's Unicode transform.
.ie \n(.g .ds Aq \(aq
.el .ds Aq '
.\"
.\" If the F register is turned on, we'll generate index entries on stderr for
.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
.\" entries marked with X<> in POD. Of course, you'll have to process the
.\" output yourself in some meaningful fashion.
.\"
.\" Avoid warning from groff about undefined register 'F'.
.de IX
..
.nr rF 0
.if \n(.g .if rF .nr rF 1
.if (\n(rF:(\n(.g==0)) \{
. if \nF \{
. de IX
. tm Index:\\$1\t\\n%\t"\\$2"
..
. if !\nF==2 \{
. nr % 0
. nr F 2
. \}
. \}
.\}
.rr rF
.\"
.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
.\" Fear. Run. Save yourself. No user-serviceable parts.
. \" fudge factors for nroff and troff
.if n \{\
. ds #H 0
. ds #V .8m
. ds #F .3m
. ds #[ \f1
. ds #] \fP
.\}
.if t \{\
. ds #H ((1u-(\\\\n(.fu%2u))*.13m)
. ds #V .6m
. ds #F 0
. ds #[ \&
. ds #] \&
.\}
. \" simple accents for nroff and troff
.if n \{\
. ds ' \&
. ds ` \&
. ds ^ \&
. ds , \&
. ds ~ ~
. ds /
.\}
.if t \{\
. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
.\}
. \" troff and (daisy-wheel) nroff accents
.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
.ds ae a\h'-(\w'a'u*4/10)'e
.ds Ae A\h'-(\w'A'u*4/10)'E
. \" corrections for vroff
.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
. \" for low resolution devices (crt and lpr)
.if \n(.H>23 .if \n(.V>19 \
\{\
. ds : e
. ds 8 ss
. ds o a
. ds d- d\h'-1'\(ga
. ds D- D\h'-1'\(hy
. ds th \o'bp'
. ds Th \o'LP'
. ds ae ae
. ds Ae AE
.\}
.rm #[ #] #H #V #F C
.\" ========================================================================
.\"
.IX Title "SVG 3pm"
.TH SVG 3pm "2015-06-02" "perl v5.20.2" "User Contributed Perl Documentation"
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.if n .ad l
.nh
.SH "NAME"
SVG \- Perl extension for generating Scalable Vector Graphics (SVG) documents
.SH "SYNOPSIS"
.IX Header "SYNOPSIS"
.Vb 4
\& #!/usr/bin/perl
\& use strict;
\& use warnings;
\& use SVG;
\&
\& # create an SVG object
\& my $svg= SVG\->new( width => 200, height => 200);
\&
\& # use explicit element constructor to generate a group element
\& my $y = $svg\->group(
\& id => \*(Aqgroup_y\*(Aq,
\& style => {
\& stroke => \*(Aqred\*(Aq,
\& fill => \*(Aqgreen\*(Aq
\& },
\& );
\&
\& # add a circle to the group
\& $y\->circle( cx => 100, cy => 100, r => 50, id => \*(Aqcircle_in_group_y\*(Aq );
\&
\& # or, use the generic \*(Aqtag\*(Aq method to generate a group element by name
\& my $z = $svg\->tag(\*(Aqg\*(Aq,
\& id => \*(Aqgroup_z\*(Aq,
\& style => {
\& stroke => \*(Aqrgb(100,200,50)\*(Aq,
\& fill => \*(Aqrgb(10,100,150)\*(Aq
\& }
\& );
\&
\& # create and add a circle using the generic \*(Aqtag\*(Aq method
\& $z\->tag(\*(Aqcircle\*(Aq, cx => 50, cy => 50, r => 100, id => \*(Aqcircle_in_group_z\*(Aq);
\&
\& # create an anchor on a rectangle within a group within the group z
\& my $k = $z\->anchor(
\& id => \*(Aqanchor_k\*(Aq,
\& \-href => \*(Aqhttp://test.hackmare.com/\*(Aq,
\& target => \*(Aqnew_window_0\*(Aq
\& )\->rectangle(
\& x => 20, y => 50,
\& width => 20, height => 30,
\& rx => 10, ry => 5,
\& id => \*(Aqrect_k_in_anchor_k_in_group_z\*(Aq
\& );
\&
\& # now render the SVG object, implicitly use svg namespace
\& print $svg\->xmlify;
\&
\& # or render a child node of the SVG object without rendering the entire object
\& print $k\->xmlify; #renders the anchor $k above containing a rectangle, but does not
\& #render any of the ancestor nodes of $k
\&
\&
\& # or, explicitly use svg namespace and generate a document with its own DTD
\& print $svg\->xmlify(\-namespace=>\*(Aqsvg\*(Aq);
\&
\& # or, explicitly use svg namespace and generate an inline docunent
\& print $svg\->xmlify(
\& \-namespace => "svg",
\& \-pubid => "\-//W3C//DTD SVG 1.0//EN",
\& \-inline => 1
\& );
.Ve
.PP
See the other modules in this distribution:
\&\s-1SVG::DOM\s0,
\&\s-1SVG::XML\s0,
SVG::Element,
SVG::Parser,
SVG::Extension
.SS "Converting \s-1SVG\s0 to \s-1PNG\s0 and other raster image formats"
.IX Subsection "Converting SVG to PNG and other raster image formats"
The \fBconvert\fR command of (also via Image::Magick ) can convert \s-1SVG\s0 files to \s-1PNG\s0
and other formats.
.PP
Image::LibRSVG can convert \s-1SVG\s0 to other format.
.SH "EXAMPLES"
.IX Header "EXAMPLES"
examples/circle.pl generates the following image:
.PP
.Vb 9
\&
\&
\&
.Ve
.PP
That you can either embed directly into \s-1HTML\s0 or can include it using:
.PP
.Vb 1
\&
.Ve
.PP
(The image was converted to png using Image::LibRSVG. See the svg2png.pl script in the examples directory.)
.PP
See also the \fBexamples\fR directory in this distribution which contain several fully documented examples.
.SH "DESCRIPTION"
.IX Header "DESCRIPTION"
\&\s-1SVG\s0 is a 100% Perl module which generates a nested data structure containing the
\&\s-1DOM\s0 representation of an \s-1SVG \s0(Scalable Vector Graphics) image. Using \s-1SVG,\s0 you
can generate \s-1SVG\s0 objects, embed other \s-1SVG\s0 instances into it, access the \s-1DOM\s0
object, create and access javascript, and generate \s-1SMIL\s0 animation content.
.SS "General Steps to generating an \s-1SVG\s0 document"
.IX Subsection "General Steps to generating an SVG document"
Generating \s-1SVG\s0 is a simple three step process:
.IP "1 Construct a new \s-1SVG\s0 object with new." 4
.IX Item "1 Construct a new SVG object with new."
.PD 0
.IP "2 Call element constructors such as circle and path to create \s-1SVG\s0 elements." 4
.IX Item "2 Call element constructors such as circle and path to create SVG elements."
.IP "3 Render the \s-1SVG\s0 object into \s-1XML\s0 using the xmlify method." 4
.IX Item "3 Render the SVG object into XML using the xmlify method."
.PD
.PP
The xmlify method takes a number of optional arguments that control how \s-1SVG\s0
renders the object into \s-1XML,\s0 and in particular determine whether a standalone
\&\s-1SVG\s0 document or an inline \s-1SVG\s0 document fragment is generated:
.SS "\-standalone"
.IX Subsection "-standalone"
A complete \s-1SVG\s0 document with its own associated \s-1DTD. A\s0 namespace for the \s-1SVG\s0
elements may be optionally specified.
.SS "\-inline"
.IX Subsection "-inline"
An inline \s-1SVG\s0 document fragment with no \s-1DTD\s0 that be embedded within other \s-1XML\s0
content. As with standalone documents, an alternate namespace may be specified.
.PP
No \s-1XML\s0 content is generated until the third step is reached. Up until this
point, all constructed element definitions reside in a DOM-like data structure
from which they can be accessed and modified.
.SS "\s-1EXPORTS\s0"
.IX Subsection "EXPORTS"
None. However, \s-1SVG\s0 permits both options and additional element methods to be
specified in the import list. These options and elements are then available
for all \s-1SVG\s0 instances that are created with the \*(L"new\*(R" constructor. For example,
to change the indent string to two spaces per level:
.PP
.Vb 1
\& use SVG (\-indent => " ");
.Ve
.PP
With the exception of \-auto, all options may also be specified to the \*(L"new\*(R"
constructor. The currently supported options and their default value are:
.PP
.Vb 4
\& # processing options
\& \-auto => 0, # permit arbitrary autoloading of all unrecognised elements
\& \-printerror => 1, # print error messages to STDERR
\& \-raiseerror => 1, # die on errors (implies \-printerror)
\&
\& # rendering options
\& \-indent => "\et", # what to indent with
\& \-elsep => "\en", # element line (vertical) separator
\& # (note that not all agents ignor trailing blanks)
\& \-nocredits => 0, # enable/disable credit note comment
\& \-namespace => \*(Aq\*(Aq, # The root element\*(Aqs (and it\*(Aqs children\*(Aqs) namespace prefix
\&
\& # XML and Doctype declarations
\& \-inline => 0, # inline or stand alone
\& \-docroot => \*(Aqsvg\*(Aq, # The document\*(Aqs root element
\& \-version => \*(Aq1.0\*(Aq,
\& \-extension => \*(Aq\*(Aq,
\& \-encoding => \*(AqUTF\-8\*(Aq,
\& \-xml_svg => \*(Aqhttp://www.w3.org/2000/svg\*(Aq, # the svg xmlns attribute
\& \-xml_xlink => \*(Aqhttp://www.w3.org/1999/xlink\*(Aq, # the svg tag xmlns:xlink attribute
\& \-standalone => \*(Aqyes\*(Aq,
\& \-pubid => "\-//W3C//DTD SVG 1.0//EN", # formerly \-identifier
\& \-sysid => \*(Aqhttp://www.w3.org/TR/2001/REC\-SVG\-20010904/DTD/svg10.dtd\*(Aq, # the system id
.Ve
.PP
\&\s-1SVG\s0 also allows additional element generation methods to be specified in the
import list. For example to generate 'star' and 'planet' element methods:
.PP
.Vb 1
\& use SVG qw(star planet);
.Ve
.PP
or:
.PP
.Vb 1
\& use SVG ("star","planet");
.Ve
.PP
This will add 'star' to the list of elements supported by \s-1SVG\s0.pm (but not of
course other \s-1SVG\s0 parsers...). Alternatively the '\-auto' option will allow
any unknown method call to generate an element of the same name:
.PP
.Vb 1
\& use SVG (\-auto => 1, "star", "planet");
.Ve
.PP
Any elements specified explicitly (as 'star' and 'planet' are here) are
predeclared; other elements are defined as and when they are seen by Perl. Note
that enabling '\-auto' effectively disables compile-time syntax checking for
valid method names.
.PP
.Vb 7
\& use SVG (
\& \-auto => 0,
\& \-indent => " ",
\& \-raiseerror => 0,
\& \-printerror => 1,
\& "star", "planet", "moon"
\& );
.Ve
.SS "Default \s-1SVG\s0 tag"
.IX Subsection "Default SVG tag"
The Default \s-1SVG\s0 tag will generate the following \s-1XML:\s0
.PP
.Vb 2
\& $svg = SVG\->new;
\& print $svg\->xmlify;
.Ve
.PP
Resulting \s-1XML\s0 snippet:
.PP
.Vb 8
\&
\&
\&