| 1 | package SVG; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 30 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 30 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 30 | ▶ | use SVG::XML; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 30 | ▶ | use parent qw(SVG::Element SVG::Extension); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 30 | ▶ | use Scalar::Util qw/weaken/; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 30 | our $VERSION = '2.89'; | |||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | =pod | ||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | =encoding UTF-8 | ||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | =head1 NAME | ||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | SVG - Perl extension for generating Scalable Vector Graphics (SVG) documents. | ||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | #!/usr/bin/perl | ||||||||||||||||||||||||||||
| 23 | use strict; | ||||||||||||||||||||||||||||
| 24 | use warnings; | ||||||||||||||||||||||||||||
| 25 | use SVG; | ||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | # create an SVG object | ||||||||||||||||||||||||||||
| 28 | my $svg= SVG->new( width => 200, height => 200); | ||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | # use explicit element constructor to generate a group element | ||||||||||||||||||||||||||||
| 31 | my $y = $svg->group( | ||||||||||||||||||||||||||||
| 32 | id => 'group_y', | ||||||||||||||||||||||||||||
| 33 | style => { | ||||||||||||||||||||||||||||
| 34 | stroke => 'red', | ||||||||||||||||||||||||||||
| 35 | fill => 'green' | ||||||||||||||||||||||||||||
| 36 | }, | ||||||||||||||||||||||||||||
| 37 | ); | ||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | # add a circle to the group | ||||||||||||||||||||||||||||
| 40 | $y->circle( cx => 100, cy => 100, r => 50, id => 'circle_in_group_y' ); | ||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | # or, use the generic 'tag' method to generate a group element by name | ||||||||||||||||||||||||||||
| 43 | my $z = $svg->tag('g', | ||||||||||||||||||||||||||||
| 44 | id => 'group_z', | ||||||||||||||||||||||||||||
| 45 | style => { | ||||||||||||||||||||||||||||
| 46 | stroke => 'rgb(100,200,50)', | ||||||||||||||||||||||||||||
| 47 | fill => 'rgb(10,100,150)' | ||||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||
| 49 | ); | ||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | # create and add a circle using the generic 'tag' method | ||||||||||||||||||||||||||||
| 52 | $z->tag('circle', cx => 50, cy => 50, r => 100, id => 'circle_in_group_z'); | ||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | # create an anchor on a rectangle within a group within the group z | ||||||||||||||||||||||||||||
| 55 | my $k = $z->anchor( | ||||||||||||||||||||||||||||
| 56 | id => 'anchor_k', | ||||||||||||||||||||||||||||
| 57 | -href => 'http://test.hackmare.com/', | ||||||||||||||||||||||||||||
| 58 | target => 'new_window_0' | ||||||||||||||||||||||||||||
| 59 | )->rectangle( | ||||||||||||||||||||||||||||
| 60 | x => 20, y => 50, | ||||||||||||||||||||||||||||
| 61 | width => 20, height => 30, | ||||||||||||||||||||||||||||
| 62 | rx => 10, ry => 5, | ||||||||||||||||||||||||||||
| 63 | id => 'rect_k_in_anchor_k_in_group_z' | ||||||||||||||||||||||||||||
| 64 | ); | ||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | # now render the SVG object, implicitly use svg namespace | ||||||||||||||||||||||||||||
| 67 | print $svg->xmlify; | ||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | # or render a child node of the SVG object without rendering the entire object | ||||||||||||||||||||||||||||
| 70 | print $k->xmlify; #renders the anchor $k above containing a rectangle, but does not | ||||||||||||||||||||||||||||
| 71 | #render any of the ancestor nodes of $k | ||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | # or, explicitly use svg namespace and generate a document with its own DTD | ||||||||||||||||||||||||||||
| 75 | print $svg->xmlify(-namespace=>'svg'); | ||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | # or, explicitly use svg namespace and generate an inline docunent | ||||||||||||||||||||||||||||
| 78 | print $svg->xmlify( | ||||||||||||||||||||||||||||
| 79 | -namespace => "svg", | ||||||||||||||||||||||||||||
| 80 | -pubid => "-//W3C//DTD SVG 1.0//EN", | ||||||||||||||||||||||||||||
| 81 | -inline => 1 | ||||||||||||||||||||||||||||
| 82 | ); | ||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | See the other modules in this distribution: | ||||||||||||||||||||||||||||
| 86 | L<SVG::DOM>, | ||||||||||||||||||||||||||||
| 87 | L<SVG::XML>, | ||||||||||||||||||||||||||||
| 88 | L<SVG::Element>, | ||||||||||||||||||||||||||||
| 89 | and L<SVG::Extension>. | ||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||
| 91 | See L<SVG::Parser> for reading SVG files as C<SVG> objects. | ||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||
| 93 | =head2 Converting SVG to PNG and other raster image formats | ||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||
| 95 | The B<convert> command of L<http://www.imagemagick.org/> (also via L<Image::Magick> ) can convert SVG files to PNG | ||||||||||||||||||||||||||||
| 96 | and other formats. | ||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | L<Image::LibRSVG> can convert SVG to other format. | ||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||
| 100 | =head1 EXAMPLES | ||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | examples/circle.pl generates the following image: | ||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | <?xml version="1.0" encoding="UTF-8" standalone="yes"?> | ||||||||||||||||||||||||||||
| 105 | <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd"> | ||||||||||||||||||||||||||||
| 106 | <svg height="200" width="200" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> | ||||||||||||||||||||||||||||
| 107 | <title >I am a title</title> | ||||||||||||||||||||||||||||
| 108 | <g id="group_y" style="fill: green; stroke: red"> | ||||||||||||||||||||||||||||
| 109 | <circle cx="100" cy="100" id="circle_in_group_y" r="50" /> | ||||||||||||||||||||||||||||
| 110 | <!-- This is a comment --> | ||||||||||||||||||||||||||||
| 111 | </g> | ||||||||||||||||||||||||||||
| 112 | </svg> | ||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||
| 114 | That you can either embed directly into HTML or can include it using: | ||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||
| 116 | <object data="file.svg" type="image/svg+xml"></object> | ||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||
| 118 | =for HTML <p><img src="http://szabgab.com/img/SVG/circle.png" alt="SVG example circle" /></p> | ||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||
| 120 | (The image was converted to png using L<Image::LibRSVG>. See the svg2png.pl script in the examples directory.) | ||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||
| 122 | =for HTML <p><img src="http://perlmaven.com/img/svg/circle.svg" alt="SVG example circle" /></p> | ||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||
| 124 | See also the B<examples> directory in this distribution which contains several fully documented examples. | ||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||
| 126 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||
| 128 | SVG is a 100% Perl module which generates a nested data structure containing the | ||||||||||||||||||||||||||||
| 129 | DOM representation of an SVG (Scalable Vector Graphics) image. Using SVG, you | ||||||||||||||||||||||||||||
| 130 | can generate SVG objects, embed other SVG instances into it, access the DOM | ||||||||||||||||||||||||||||
| 131 | object, create and access javascript, and generate SMIL animation content. | ||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||
| 133 | =head2 General Steps to generating an SVG document | ||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||
| 135 | Generating SVG is a simple three step process: | ||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||
| 137 | =over 4 | ||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||
| 139 | =item 1 Construct a new SVG object with L<"new">. | ||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||
| 141 | =item 2 Call element constructors such as L<"circle"> and L<"path"> to create SVG elements. | ||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||
| 143 | =item 3 Render the SVG object into XML using the L<"xmlify"> method. | ||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||
| 145 | =back | ||||||||||||||||||||||||||||
| 146 | |||||||||||||||||||||||||||||
| 147 | The L</xmlify> method takes a number of optional arguments that control how SVG | ||||||||||||||||||||||||||||
| 148 | renders the object into XML, and in particular determine whether a standalone | ||||||||||||||||||||||||||||
| 149 | SVG document or an inline SVG document fragment is generated: | ||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||
| 151 | =head2 -standalone | ||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||
| 153 | A complete SVG document with its own associated DTD. A namespace for the SVG | ||||||||||||||||||||||||||||
| 154 | elements may be optionally specified. | ||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||
| 156 | =head2 -inline | ||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||
| 158 | An inline SVG document fragment with no DTD that is embedded within other XML | ||||||||||||||||||||||||||||
| 159 | content. As with standalone documents, an alternate namespace may be specified. | ||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||
| 161 | No XML content is generated until the third step is reached. Up until this | ||||||||||||||||||||||||||||
| 162 | point, all constructed element definitions reside in a DOM-like data structure | ||||||||||||||||||||||||||||
| 163 | from which they can be accessed and modified. | ||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||
| 165 | =head2 EXPORTS | ||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||
| 167 | None. However, SVG permits both options and additional element methods to be | ||||||||||||||||||||||||||||
| 168 | specified in the import list. These options and elements are then available | ||||||||||||||||||||||||||||
| 169 | for all SVG instances that are created with the L</new> constructor. For example, | ||||||||||||||||||||||||||||
| 170 | to change the indent string to two spaces per level: | ||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||
| 172 | use SVG (-indent => " "); | ||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||
| 174 | With the exception of -auto, all options may also be specified to the L</new> | ||||||||||||||||||||||||||||
| 175 | constructor. The currently supported options and their default value are: | ||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||
| 177 | # processing options | ||||||||||||||||||||||||||||
| 178 | -auto => 0, # permit arbitrary autoloading of all unrecognised elements | ||||||||||||||||||||||||||||
| 179 | -printerror => 1, # print error messages to STDERR | ||||||||||||||||||||||||||||
| 180 | -raiseerror => 1, # die on errors (implies -printerror) | ||||||||||||||||||||||||||||
| 181 | |||||||||||||||||||||||||||||
| 182 | # rendering options | ||||||||||||||||||||||||||||
| 183 | -indent => "\t", # what to indent with | ||||||||||||||||||||||||||||
| 184 | -elsep => "\n", # element line (vertical) separator | ||||||||||||||||||||||||||||
| 185 | # (note that not all agents ignor trailing blanks) | ||||||||||||||||||||||||||||
| 186 | -nocredits => 0, # enable/disable credit note comment | ||||||||||||||||||||||||||||
| 187 | -namespace => '', # The root element's (and it's children's) namespace prefix | ||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||
| 189 | # XML and Doctype declarations | ||||||||||||||||||||||||||||
| 190 | -inline => 0, # inline or stand alone | ||||||||||||||||||||||||||||
| 191 | -docroot => 'svg', # The document's root element | ||||||||||||||||||||||||||||
| 192 | -version => '1.0', | ||||||||||||||||||||||||||||
| 193 | -extension => '', | ||||||||||||||||||||||||||||
| 194 | -encoding => 'UTF-8', | ||||||||||||||||||||||||||||
| 195 | -xml_svg => 'http://www.w3.org/2000/svg', # the svg xmlns attribute | ||||||||||||||||||||||||||||
| 196 | -xml_xlink => 'http://www.w3.org/1999/xlink', # the svg tag xmlns:xlink attribute | ||||||||||||||||||||||||||||
| 197 | -standalone => 'yes', | ||||||||||||||||||||||||||||
| 198 | -pubid => "-//W3C//DTD SVG 1.0//EN", # formerly -identifier | ||||||||||||||||||||||||||||
| 199 | -sysid => 'http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd', # the system id | ||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||
| 201 | SVG also allows additional element generation methods to be specified in the | ||||||||||||||||||||||||||||
| 202 | import list. For example to generate 'star' and 'planet' element methods: | ||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||
| 204 | use SVG qw(star planet); | ||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||
| 206 | or: | ||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||
| 208 | use SVG ("star","planet"); | ||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||
| 210 | This will add 'star' to the list of elements supported by SVG.pm (but not of | ||||||||||||||||||||||||||||
| 211 | course other SVG parsers...). Alternatively the '-auto' option will allow | ||||||||||||||||||||||||||||
| 212 | any unknown method call to generate an element of the same name: | ||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||
| 214 | use SVG (-auto => 1, "star", "planet"); | ||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||
| 216 | Any elements specified explicitly (as 'star' and 'planet' are here) are | ||||||||||||||||||||||||||||
| 217 | predeclared; other elements are defined as and when they are seen by Perl. Note | ||||||||||||||||||||||||||||
| 218 | that enabling '-auto' effectively disables compile-time syntax checking for | ||||||||||||||||||||||||||||
| 219 | valid method names. | ||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||
| 221 | use SVG ( | ||||||||||||||||||||||||||||
| 222 | -auto => 0, | ||||||||||||||||||||||||||||
| 223 | -indent => " ", | ||||||||||||||||||||||||||||
| 224 | -raiseerror => 0, | ||||||||||||||||||||||||||||
| 225 | -printerror => 1, | ||||||||||||||||||||||||||||
| 226 | "star", "planet", "moon" | ||||||||||||||||||||||||||||
| 227 | ); | ||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||
| 229 | =head2 Default SVG tag | ||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||
| 231 | The Default SVG tag will generate the following XML: | ||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||
| 233 | $svg = SVG->new; | ||||||||||||||||||||||||||||
| 234 | print $svg->xmlify; | ||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||
| 236 | Resulting XML snippet: | ||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||
| 238 | <?xml version="1.0" encoding="UTF-8" standalone="yes"?> | ||||||||||||||||||||||||||||
| 239 | <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd"> | ||||||||||||||||||||||||||||
| 240 | <svg height="100%" width="100%" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> | ||||||||||||||||||||||||||||
| 241 | <!-- | ||||||||||||||||||||||||||||
| 242 | Generated using the Perl SVG Module V2.50 | ||||||||||||||||||||||||||||
| 243 | by Ronan Oger | ||||||||||||||||||||||||||||
| 244 | --> | ||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||
| 246 | =head1 METHODS | ||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||
| 248 | SVG provides both explicit and generic element constructor methods. Explicit | ||||||||||||||||||||||||||||
| 249 | generators are generally (with a few exceptions) named for the element they | ||||||||||||||||||||||||||||
| 250 | generate. If a tag method is required for a tag containing hyphens, the method | ||||||||||||||||||||||||||||
| 251 | name replaces the hyphen with an underscore. ie: to generate tag <column-heading id="new"> | ||||||||||||||||||||||||||||
| 252 | you would use method $svg->column_heading(id=>'new'). | ||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||
| 255 | All element constructors take a hash of element attributes and options; | ||||||||||||||||||||||||||||
| 256 | element attributes such as 'id' or 'border' are passed by name, while options for the | ||||||||||||||||||||||||||||
| 257 | method (such as the type of an element that supports multiple alternate forms) | ||||||||||||||||||||||||||||
| 258 | are passed preceded by a hyphen, e.g '-type'. Both types may be freely | ||||||||||||||||||||||||||||
| 259 | intermixed; see the L<"fe"> method and code examples throughout the documentation | ||||||||||||||||||||||||||||
| 260 | for more examples. | ||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||
| 262 | =head2 new (constructor) | ||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||
| 264 | $svg = SVG->new(%attributes) | ||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||
| 266 | Creates a new SVG object. Attributes of the document SVG element be passed as | ||||||||||||||||||||||||||||
| 267 | an optional list of key value pairs. Additionally, SVG options (prefixed with | ||||||||||||||||||||||||||||
| 268 | a hyphen) may be set on a per object basis: | ||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||
| 270 | my $svg1 = SVG->new; | ||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||
| 272 | my $svg2 = SVG->new(id => 'document_element'); | ||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||
| 274 | my $svg3 = SVG->new( | ||||||||||||||||||||||||||||
| 275 | -printerror => 1, | ||||||||||||||||||||||||||||
| 276 | -raiseerror => 0, | ||||||||||||||||||||||||||||
| 277 | -indent => ' ', | ||||||||||||||||||||||||||||
| 278 | -docroot => 'svg', #default document root element (SVG specification assumes svg). Defaults to 'svg' if undefined | ||||||||||||||||||||||||||||
| 279 | -sysid => 'abc', #optional system identifyer | ||||||||||||||||||||||||||||
| 280 | -pubid => "-//W3C//DTD SVG 1.0//EN", #public identifyer default value is "-//W3C//DTD SVG 1.0//EN" if undefined | ||||||||||||||||||||||||||||
| 281 | -namespace => 'mysvg', | ||||||||||||||||||||||||||||
| 282 | -inline => 1 | ||||||||||||||||||||||||||||
| 283 | id => 'document_element', | ||||||||||||||||||||||||||||
| 284 | width => 300, | ||||||||||||||||||||||||||||
| 285 | height => 200, | ||||||||||||||||||||||||||||
| 286 | ); | ||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||
| 288 | B<SVG instance represents the document and not the C<E<lt>svgE<gt>> root element.> | ||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||
| 290 | Default SVG options may also be set in the import list. See L<"EXPORTS"> above | ||||||||||||||||||||||||||||
| 291 | for more on the available options. | ||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||
| 293 | Furthermore, the following options: | ||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||
| 296 | -version | ||||||||||||||||||||||||||||
| 297 | -encoding | ||||||||||||||||||||||||||||
| 298 | -standalone | ||||||||||||||||||||||||||||
| 299 | -namespace Defines the document or element level namespace. The order of assignment priority is element,document . | ||||||||||||||||||||||||||||
| 300 | -inline | ||||||||||||||||||||||||||||
| 301 | -identifier | ||||||||||||||||||||||||||||
| 302 | -nostub | ||||||||||||||||||||||||||||
| 303 | -dtd (standalone) | ||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||
| 305 | may also be set in xmlify, overriding any corresponding values set in the SVG->new declaration | ||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||
| 307 | |||||||||||||||||||||||||||||
| 308 | =head2 xmlify (alias: to_xml render serialise serialize) | ||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||
| 310 | $string = $svg->xmlify(%attributes); | ||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||
| 312 | Returns xml representation of svg document. | ||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||
| 314 | B<XML Declaration> | ||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||
| 316 | Name Default Value | ||||||||||||||||||||||||||||
| 317 | -version '1.0' | ||||||||||||||||||||||||||||
| 318 | -encoding 'UTF-8' | ||||||||||||||||||||||||||||
| 319 | -standalone 'yes' | ||||||||||||||||||||||||||||
| 320 | -namespace 'svg' - namespace for elements | ||||||||||||||||||||||||||||
| 321 | -inline '0' - If '1', then this is an inline document. | ||||||||||||||||||||||||||||
| 322 | -pubid '-//W3C//DTD SVG 1.0//EN'; | ||||||||||||||||||||||||||||
| 323 | -dtd (standalone) 'http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd' | ||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||
| 326 | =head2 tag (alias: element) | ||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||
| 328 | $tag = $svg->tag($name, %attributes) | ||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||
| 330 | Generic element generator. Creates the element named $name with the attributes | ||||||||||||||||||||||||||||
| 331 | specified in %attributes. This method is the basis of most of the explicit | ||||||||||||||||||||||||||||
| 332 | element generators. | ||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||
| 334 | my $tag = $svg->tag('g', transform=>'rotate(-45)'); | ||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||
| 337 | =head2 anchor | ||||||||||||||||||||||||||||
| 338 | |||||||||||||||||||||||||||||
| 339 | $tag = $svg->anchor(%attributes) | ||||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||
| 341 | Generate an anchor element. Anchors are put around objects to make them | ||||||||||||||||||||||||||||
| 342 | 'live' (i.e. clickable). It therefore requires a drawn object or group element | ||||||||||||||||||||||||||||
| 343 | as a child. | ||||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||
| 345 | =head3 optional anchor attributes | ||||||||||||||||||||||||||||
| 346 | |||||||||||||||||||||||||||||
| 347 | The following attributes are expected for anchor tags (any any tags which use -href links): | ||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||
| 349 | =head2 -href required | ||||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||
| 351 | =head2 -type optional | ||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||
| 353 | =head2 -role optional | ||||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||
| 355 | =head2 -title optional | ||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||
| 357 | =head2 -show optional | ||||||||||||||||||||||||||||
| 358 | |||||||||||||||||||||||||||||
| 359 | =head2 -arcrole optional | ||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||
| 361 | =head2 -actuate optional | ||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||
| 363 | =head2 target optional | ||||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||
| 365 | For more information on the options, refer to the w3c XLink specification at | ||||||||||||||||||||||||||||
| 366 | L<http://www.w3.org/TR/xlink/> | ||||||||||||||||||||||||||||
| 367 | |||||||||||||||||||||||||||||
| 368 | B<Example:> | ||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||
| 370 | # generate an anchor | ||||||||||||||||||||||||||||
| 371 | $tag = $SVG->anchor( | ||||||||||||||||||||||||||||
| 372 | -href=>'http://here.com/some/simpler/SVG.SVG' | ||||||||||||||||||||||||||||
| 373 | -title => 'new window 2 example title', | ||||||||||||||||||||||||||||
| 374 | -actuate => 'onLoad', | ||||||||||||||||||||||||||||
| 375 | -show=> 'embed', | ||||||||||||||||||||||||||||
| 376 | |||||||||||||||||||||||||||||
| 377 | ); | ||||||||||||||||||||||||||||
| 378 | |||||||||||||||||||||||||||||
| 379 | For more information about the options above, refer to Link section in the SVG recommendation: L<http://www.w3.org/TR/SVG11/linking.html#Links> | ||||||||||||||||||||||||||||
| 380 | |||||||||||||||||||||||||||||
| 381 | # add a circle to the anchor. The circle can be clicked on. | ||||||||||||||||||||||||||||
| 382 | $tag->circle(cx => 10, cy => 10, r => 1); | ||||||||||||||||||||||||||||
| 383 | |||||||||||||||||||||||||||||
| 384 | # more complex anchor with both URL and target | ||||||||||||||||||||||||||||
| 385 | $tag = $SVG->anchor( | ||||||||||||||||||||||||||||
| 386 | -href => 'http://somewhere.org/some/other/page.html', | ||||||||||||||||||||||||||||
| 387 | target => 'new_window' | ||||||||||||||||||||||||||||
| 388 | ); | ||||||||||||||||||||||||||||
| 389 | |||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||
| 391 | # generate an anchor | ||||||||||||||||||||||||||||
| 392 | $tag = $svg->anchor( | ||||||||||||||||||||||||||||
| 393 | -href=>'http://here.com/some/simpler/svg.svg' | ||||||||||||||||||||||||||||
| 394 | ); | ||||||||||||||||||||||||||||
| 395 | # add a circle to the anchor. The circle can be clicked on. | ||||||||||||||||||||||||||||
| 396 | $tag->circle(cx => 10, cy => 10, r => 1); | ||||||||||||||||||||||||||||
| 397 | |||||||||||||||||||||||||||||
| 398 | # more complex anchor with both URL and target | ||||||||||||||||||||||||||||
| 399 | $tag = $svg->anchor( | ||||||||||||||||||||||||||||
| 400 | -href => 'http://somewhere.org/some/other/page.html', | ||||||||||||||||||||||||||||
| 401 | target => 'new_window' | ||||||||||||||||||||||||||||
| 402 | ); | ||||||||||||||||||||||||||||
| 403 | |||||||||||||||||||||||||||||
| 404 | =head2 circle | ||||||||||||||||||||||||||||
| 405 | |||||||||||||||||||||||||||||
| 406 | $tag = $svg->circle(%attributes) | ||||||||||||||||||||||||||||
| 407 | |||||||||||||||||||||||||||||
| 408 | Draw a circle at (cx,cy) with radius r. | ||||||||||||||||||||||||||||
| 409 | |||||||||||||||||||||||||||||
| 410 | my $tag = $svg->circle(cx => 4, cy => 2, r => 1); | ||||||||||||||||||||||||||||
| 411 | |||||||||||||||||||||||||||||
| 412 | =head2 ellipse | ||||||||||||||||||||||||||||
| 413 | |||||||||||||||||||||||||||||
| 414 | $tag = $svg->ellipse(%attributes) | ||||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||
| 416 | Draw an ellipse at (cx,cy) with radii rx,ry. | ||||||||||||||||||||||||||||
| 417 | |||||||||||||||||||||||||||||
| 418 | use SVG; | ||||||||||||||||||||||||||||
| 419 | |||||||||||||||||||||||||||||
| 420 | # create an SVG object | ||||||||||||||||||||||||||||
| 421 | my $svg= SVG->new( width => 200, height => 200); | ||||||||||||||||||||||||||||
| 422 | |||||||||||||||||||||||||||||
| 423 | my $tag = $svg->ellipse( | ||||||||||||||||||||||||||||
| 424 | cx => 10, | ||||||||||||||||||||||||||||
| 425 | cy => 10, | ||||||||||||||||||||||||||||
| 426 | rx => 5, | ||||||||||||||||||||||||||||
| 427 | ry => 7, | ||||||||||||||||||||||||||||
| 428 | id => 'ellipse', | ||||||||||||||||||||||||||||
| 429 | style => { | ||||||||||||||||||||||||||||
| 430 | 'stroke' => 'red', | ||||||||||||||||||||||||||||
| 431 | 'fill' => 'green', | ||||||||||||||||||||||||||||
| 432 | 'stroke-width' => '4', | ||||||||||||||||||||||||||||
| 433 | 'stroke-opacity' => '0.5', | ||||||||||||||||||||||||||||
| 434 | 'fill-opacity' => '0.2', | ||||||||||||||||||||||||||||
| 435 | } | ||||||||||||||||||||||||||||
| 436 | ); | ||||||||||||||||||||||||||||
| 437 | |||||||||||||||||||||||||||||
| 438 | See The B<example/ellipse.pl> | ||||||||||||||||||||||||||||
| 439 | |||||||||||||||||||||||||||||
| 440 | =for HTML <p><img src="http://perlmaven.com/img/svg/ellipse.svg" alt="SVG example ellipse" /></p> | ||||||||||||||||||||||||||||
| 441 | |||||||||||||||||||||||||||||
| 442 | =head2 rectangle (alias: rect) | ||||||||||||||||||||||||||||
| 443 | |||||||||||||||||||||||||||||
| 444 | $tag = $svg->rectangle(%attributes) | ||||||||||||||||||||||||||||
| 445 | |||||||||||||||||||||||||||||
| 446 | Draw a rectangle at (x,y) with width 'width' and height 'height' and side radii | ||||||||||||||||||||||||||||
| 447 | 'rx' and 'ry'. | ||||||||||||||||||||||||||||
| 448 | |||||||||||||||||||||||||||||
| 449 | $tag = $svg->rectangle( | ||||||||||||||||||||||||||||
| 450 | x => 10, | ||||||||||||||||||||||||||||
| 451 | y => 20, | ||||||||||||||||||||||||||||
| 452 | width => 4, | ||||||||||||||||||||||||||||
| 453 | height => 5, | ||||||||||||||||||||||||||||
| 454 | rx => 5.2, | ||||||||||||||||||||||||||||
| 455 | ry => 2.4, | ||||||||||||||||||||||||||||
| 456 | id => 'rect_1' | ||||||||||||||||||||||||||||
| 457 | ); | ||||||||||||||||||||||||||||
| 458 | |||||||||||||||||||||||||||||
| 459 | =head2 image | ||||||||||||||||||||||||||||
| 460 | |||||||||||||||||||||||||||||
| 461 | $tag = $svg->image(%attributes) | ||||||||||||||||||||||||||||
| 462 | |||||||||||||||||||||||||||||
| 463 | Draw an image at (x,y) with width 'width' and height 'height' linked to image | ||||||||||||||||||||||||||||
| 464 | resource '-href'. See also L<"use">. | ||||||||||||||||||||||||||||
| 465 | |||||||||||||||||||||||||||||
| 466 | $tag = $svg->image( | ||||||||||||||||||||||||||||
| 467 | x => 100, | ||||||||||||||||||||||||||||
| 468 | y => 100, | ||||||||||||||||||||||||||||
| 469 | width => 300, | ||||||||||||||||||||||||||||
| 470 | height => 200, | ||||||||||||||||||||||||||||
| 471 | '-href' => "image.png", #may also embed SVG, e.g. "image.svg" | ||||||||||||||||||||||||||||
| 472 | id => 'image_1' | ||||||||||||||||||||||||||||
| 473 | ); | ||||||||||||||||||||||||||||
| 474 | |||||||||||||||||||||||||||||
| 475 | B<Output:> | ||||||||||||||||||||||||||||
| 476 | |||||||||||||||||||||||||||||
| 477 | <image xlink:href="image.png" x="100" y="100" width="300" height="200"/> | ||||||||||||||||||||||||||||
| 478 | |||||||||||||||||||||||||||||
| 479 | =head2 use | ||||||||||||||||||||||||||||
| 480 | |||||||||||||||||||||||||||||
| 481 | $tag = $svg->use(%attributes) | ||||||||||||||||||||||||||||
| 482 | |||||||||||||||||||||||||||||
| 483 | Retrieve the content from an entity within an SVG document and apply it at | ||||||||||||||||||||||||||||
| 484 | (x,y) with width 'width' and height 'height' linked to image resource '-href'. | ||||||||||||||||||||||||||||
| 485 | |||||||||||||||||||||||||||||
| 486 | $tag = $svg->use( | ||||||||||||||||||||||||||||
| 487 | x => 100, | ||||||||||||||||||||||||||||
| 488 | y => 100, | ||||||||||||||||||||||||||||
| 489 | width => 300, | ||||||||||||||||||||||||||||
| 490 | height => 200, | ||||||||||||||||||||||||||||
| 491 | '-href' => "pic.svg#image_1", | ||||||||||||||||||||||||||||
| 492 | id => 'image_1' | ||||||||||||||||||||||||||||
| 493 | ); | ||||||||||||||||||||||||||||
| 494 | |||||||||||||||||||||||||||||
| 495 | B<Output:> | ||||||||||||||||||||||||||||
| 496 | |||||||||||||||||||||||||||||
| 497 | <use xlink:href="pic.svg#image_1" x="100" y="100" width="300" height="200"/> | ||||||||||||||||||||||||||||
| 498 | |||||||||||||||||||||||||||||
| 499 | According to the SVG specification, the 'use' element in SVG can point to a | ||||||||||||||||||||||||||||
| 500 | single element within an external SVG file. | ||||||||||||||||||||||||||||
| 501 | |||||||||||||||||||||||||||||
| 502 | =head2 polygon | ||||||||||||||||||||||||||||
| 503 | |||||||||||||||||||||||||||||
| 504 | $tag = $svg->polygon(%attributes) | ||||||||||||||||||||||||||||
| 505 | |||||||||||||||||||||||||||||
| 506 | Draw an n-sided polygon with vertices at points defined by a string of the form | ||||||||||||||||||||||||||||
| 507 | 'x1,y1,x2,y2,x3,y3,... xy,yn'. The L<"get_path"> method is provided as a | ||||||||||||||||||||||||||||
| 508 | convenience to generate a suitable string from coordinate data. | ||||||||||||||||||||||||||||
| 509 | |||||||||||||||||||||||||||||
| 510 | # a five-sided polygon | ||||||||||||||||||||||||||||
| 511 | my $xv = [0, 2, 4, 5, 1]; | ||||||||||||||||||||||||||||
| 512 | my $yv = [0, 0, 2, 7, 5]; | ||||||||||||||||||||||||||||
| 513 | |||||||||||||||||||||||||||||
| 514 | my $points = $svg->get_path( | ||||||||||||||||||||||||||||
| 515 | x => $xv, | ||||||||||||||||||||||||||||
| 516 | y => $yv, | ||||||||||||||||||||||||||||
| 517 | -type =>'polygon' | ||||||||||||||||||||||||||||
| 518 | ); | ||||||||||||||||||||||||||||
| 519 | |||||||||||||||||||||||||||||
| 520 | my $poly = $svg->polygon( | ||||||||||||||||||||||||||||
| 521 | %$points, | ||||||||||||||||||||||||||||
| 522 | id => 'pgon1', | ||||||||||||||||||||||||||||
| 523 | style => \%polygon_style | ||||||||||||||||||||||||||||
| 524 | ); | ||||||||||||||||||||||||||||
| 525 | |||||||||||||||||||||||||||||
| 526 | SEE ALSO: | ||||||||||||||||||||||||||||
| 527 | |||||||||||||||||||||||||||||
| 528 | L<"polyline">, L<"path">, L<"get_path">. | ||||||||||||||||||||||||||||
| 529 | |||||||||||||||||||||||||||||
| 530 | =head2 polyline | ||||||||||||||||||||||||||||
| 531 | |||||||||||||||||||||||||||||
| 532 | $tag = $svg->polyline(%attributes) | ||||||||||||||||||||||||||||
| 533 | |||||||||||||||||||||||||||||
| 534 | Draw an n-point polyline with points defined by a string of the form | ||||||||||||||||||||||||||||
| 535 | 'x1,y1,x2,y2,x3,y3,... xy,yn'. The L<"get_path"> method is provided as a | ||||||||||||||||||||||||||||
| 536 | convenience to generate a suitable string from coordinate data. | ||||||||||||||||||||||||||||
| 537 | |||||||||||||||||||||||||||||
| 538 | # a 10-pointsaw-tooth pattern | ||||||||||||||||||||||||||||
| 539 | my $xv = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; | ||||||||||||||||||||||||||||
| 540 | my $yv = [0, 1, 0, 1, 0, 1, 0, 1, 0, 1]; | ||||||||||||||||||||||||||||
| 541 | |||||||||||||||||||||||||||||
| 542 | my $points = $svg->get_path( | ||||||||||||||||||||||||||||
| 543 | x => $xv, | ||||||||||||||||||||||||||||
| 544 | y => $yv, | ||||||||||||||||||||||||||||
| 545 | -type => 'polyline', | ||||||||||||||||||||||||||||
| 546 | -closed => 'true' #specify that the polyline is closed. | ||||||||||||||||||||||||||||
| 547 | ); | ||||||||||||||||||||||||||||
| 548 | |||||||||||||||||||||||||||||
| 549 | my $tag = $svg->polyline ( | ||||||||||||||||||||||||||||
| 550 | %$points, | ||||||||||||||||||||||||||||
| 551 | id =>'pline_1', | ||||||||||||||||||||||||||||
| 552 | style => { | ||||||||||||||||||||||||||||
| 553 | 'fill-opacity' => 0, | ||||||||||||||||||||||||||||
| 554 | 'stroke' => 'rgb(250,123,23)' | ||||||||||||||||||||||||||||
| 555 | } | ||||||||||||||||||||||||||||
| 556 | ); | ||||||||||||||||||||||||||||
| 557 | |||||||||||||||||||||||||||||
| 558 | =head2 line | ||||||||||||||||||||||||||||
| 559 | |||||||||||||||||||||||||||||
| 560 | $tag = $svg->line(%attributes) | ||||||||||||||||||||||||||||
| 561 | |||||||||||||||||||||||||||||
| 562 | Draw a straight line between two points (x1,y1) and (x2,y2). | ||||||||||||||||||||||||||||
| 563 | |||||||||||||||||||||||||||||
| 564 | my $tag = $svg->line( | ||||||||||||||||||||||||||||
| 565 | id => 'l1', | ||||||||||||||||||||||||||||
| 566 | x1 => 0, | ||||||||||||||||||||||||||||
| 567 | y1 => 10, | ||||||||||||||||||||||||||||
| 568 | x2 => 10, | ||||||||||||||||||||||||||||
| 569 | y2 => 0, | ||||||||||||||||||||||||||||
| 570 | ); | ||||||||||||||||||||||||||||
| 571 | |||||||||||||||||||||||||||||
| 572 | To draw multiple connected lines, use L<"polyline">. | ||||||||||||||||||||||||||||
| 573 | |||||||||||||||||||||||||||||
| 574 | =head2 text | ||||||||||||||||||||||||||||
| 575 | |||||||||||||||||||||||||||||
| 576 | $text = $svg->text(%attributes)->cdata(); | ||||||||||||||||||||||||||||
| 577 | |||||||||||||||||||||||||||||
| 578 | $text_path = $svg->text(-type=>'path'); | ||||||||||||||||||||||||||||
| 579 | $text_span = $text_path->text(-type=>'span')->cdata('A'); | ||||||||||||||||||||||||||||
| 580 | $text_span = $text_path->text(-type=>'span')->cdata('B'); | ||||||||||||||||||||||||||||
| 581 | $text_span = $text_path->text(-type=>'span')->cdata('C'); | ||||||||||||||||||||||||||||
| 582 | |||||||||||||||||||||||||||||
| 583 | Define the container for a text string to be drawn in the image. | ||||||||||||||||||||||||||||
| 584 | |||||||||||||||||||||||||||||
| 585 | B<Input:> | ||||||||||||||||||||||||||||
| 586 | |||||||||||||||||||||||||||||
| 587 | -type = path type (path | polyline | polygon) | ||||||||||||||||||||||||||||
| 588 | -type = text element type (path | span | normal [default]) | ||||||||||||||||||||||||||||
| 589 | |||||||||||||||||||||||||||||
| 590 | my $text1 = $svg->text( | ||||||||||||||||||||||||||||
| 591 | id => 'l1', | ||||||||||||||||||||||||||||
| 592 | x => 10, | ||||||||||||||||||||||||||||
| 593 | y => 10 | ||||||||||||||||||||||||||||
| 594 | )->cdata('hello, world'); | ||||||||||||||||||||||||||||
| 595 | |||||||||||||||||||||||||||||
| 596 | my $text2 = $svg->text( | ||||||||||||||||||||||||||||
| 597 | id => 'l1', | ||||||||||||||||||||||||||||
| 598 | x => 10, | ||||||||||||||||||||||||||||
| 599 | y => 10, | ||||||||||||||||||||||||||||
| 600 | -cdata => 'hello, world', | ||||||||||||||||||||||||||||
| 601 | ); | ||||||||||||||||||||||||||||
| 602 | |||||||||||||||||||||||||||||
| 603 | my $text = $svg->text( | ||||||||||||||||||||||||||||
| 604 | id => 'tp', | ||||||||||||||||||||||||||||
| 605 | x => 10, | ||||||||||||||||||||||||||||
| 606 | y => 10, | ||||||||||||||||||||||||||||
| 607 | -type => path, | ||||||||||||||||||||||||||||
| 608 | ) | ||||||||||||||||||||||||||||
| 609 | ->text(id=>'ts' -type=>'span') | ||||||||||||||||||||||||||||
| 610 | ->cdata('hello, world'); | ||||||||||||||||||||||||||||
| 611 | |||||||||||||||||||||||||||||
| 612 | SEE ALSO: | ||||||||||||||||||||||||||||
| 613 | |||||||||||||||||||||||||||||
| 614 | L<"desc">, L<"cdata">. | ||||||||||||||||||||||||||||
| 615 | |||||||||||||||||||||||||||||
| 616 | =head2 title | ||||||||||||||||||||||||||||
| 617 | |||||||||||||||||||||||||||||
| 618 | $tag = $svg->title(%attributes) | ||||||||||||||||||||||||||||
| 619 | |||||||||||||||||||||||||||||
| 620 | Generate the title of the image. | ||||||||||||||||||||||||||||
| 621 | |||||||||||||||||||||||||||||
| 622 | my $tag = $svg->title(id=>'document-title')->cdata('This is the title'); | ||||||||||||||||||||||||||||
| 623 | |||||||||||||||||||||||||||||
| 624 | =head2 desc | ||||||||||||||||||||||||||||
| 625 | |||||||||||||||||||||||||||||
| 626 | $svg->desc(id => 'image-description')->cdata('This image shows a red circle'); | ||||||||||||||||||||||||||||
| 627 | |||||||||||||||||||||||||||||
| 628 | Add a description element to the SVG document. The <desc> element provides a | ||||||||||||||||||||||||||||
| 629 | text-accessible description of the container or graphics element. It is | ||||||||||||||||||||||||||||
| 630 | primarily used for accessibility (screen readers) and is not rendered visually. | ||||||||||||||||||||||||||||
| 631 | |||||||||||||||||||||||||||||
| 632 | =head2 comment | ||||||||||||||||||||||||||||
| 633 | |||||||||||||||||||||||||||||
| 634 | $svg->comment('Single comment'); | ||||||||||||||||||||||||||||
| 635 | $svg->comment('Part 1', 'Part 2', 'Part 3'); | ||||||||||||||||||||||||||||
| 636 | |||||||||||||||||||||||||||||
| 637 | Add a comment to the SVG document. Comments are rendered as standard XML | ||||||||||||||||||||||||||||
| 638 | comments. If multiple strings are provided, they are concatenated with | ||||||||||||||||||||||||||||
| 639 | spaces. Unlike the 'desc' element, comments are generally ignored by user | ||||||||||||||||||||||||||||
| 640 | agents and are not part of the DOM tree for accessibility. | ||||||||||||||||||||||||||||
| 641 | |||||||||||||||||||||||||||||
| 642 | =head2 pi (Processing Instruction) | ||||||||||||||||||||||||||||
| 643 | |||||||||||||||||||||||||||||
| 644 | $tag = $svg->pi(@pi) | ||||||||||||||||||||||||||||
| 645 | |||||||||||||||||||||||||||||
| 646 | Generate a set of processing instructions | ||||||||||||||||||||||||||||
| 647 | |||||||||||||||||||||||||||||
| 648 | my $tag = $svg->pi('instruction one','instruction two','instruction three'); | ||||||||||||||||||||||||||||
| 649 | |||||||||||||||||||||||||||||
| 650 | returns: | ||||||||||||||||||||||||||||
| 651 | <lt>?instruction one?<gt> | ||||||||||||||||||||||||||||
| 652 | <lt>?instruction two?<gt> | ||||||||||||||||||||||||||||
| 653 | <lt>?instruction three?<gt> | ||||||||||||||||||||||||||||
| 654 | |||||||||||||||||||||||||||||
| 655 | =head2 script | ||||||||||||||||||||||||||||
| 656 | |||||||||||||||||||||||||||||
| 657 | $tag = $svg->script(%attributes) | ||||||||||||||||||||||||||||
| 658 | |||||||||||||||||||||||||||||
| 659 | Generate a script container for dynamic (client-side) scripting using | ||||||||||||||||||||||||||||
| 660 | ECMAscript, Javascript or other compatible scripting language. | ||||||||||||||||||||||||||||
| 661 | |||||||||||||||||||||||||||||
| 662 | my $tag = $svg->script(-type=>"text/ecmascript"); | ||||||||||||||||||||||||||||
| 663 | #or my $tag = $svg->script(); | ||||||||||||||||||||||||||||
| 664 | #note that type ecmascript is not Mozilla compliant | ||||||||||||||||||||||||||||
| 665 | |||||||||||||||||||||||||||||
| 666 | # populate the script tag with cdata | ||||||||||||||||||||||||||||
| 667 | # be careful to manage the javascript line ends. | ||||||||||||||||||||||||||||
| 668 | # Use qq{text} or q{text} as appropriate. | ||||||||||||||||||||||||||||
| 669 | # make sure to use the CAPITAL CDATA to poulate the script. | ||||||||||||||||||||||||||||
| 670 | $tag->CDATA(qq{ | ||||||||||||||||||||||||||||
| 671 | function d() { | ||||||||||||||||||||||||||||
| 672 | //simple display function | ||||||||||||||||||||||||||||
| 673 | for(cnt = 0; cnt < d.length; cnt++) | ||||||||||||||||||||||||||||
| 674 | document.write(d[cnt]);//end for loop | ||||||||||||||||||||||||||||
| 675 | document.write("<BR>");//write a line break | ||||||||||||||||||||||||||||
| 676 | } | ||||||||||||||||||||||||||||
| 677 | }); | ||||||||||||||||||||||||||||
| 678 | |||||||||||||||||||||||||||||
| 679 | =head2 path | ||||||||||||||||||||||||||||
| 680 | |||||||||||||||||||||||||||||
| 681 | $tag = $svg->path(%attributes) | ||||||||||||||||||||||||||||
| 682 | |||||||||||||||||||||||||||||
| 683 | Draw a path element. The path vertices may be provided as a parameter or | ||||||||||||||||||||||||||||
| 684 | calculated using the L<"get_path"> method. | ||||||||||||||||||||||||||||
| 685 | |||||||||||||||||||||||||||||
| 686 | # a 10-pointsaw-tooth pattern drawn with a path definition | ||||||||||||||||||||||||||||
| 687 | my $xv = [0,1,2,3,4,5,6,7,8,9]; | ||||||||||||||||||||||||||||
| 688 | my $yv = [0,1,0,1,0,1,0,1,0,1]; | ||||||||||||||||||||||||||||
| 689 | |||||||||||||||||||||||||||||
| 690 | $points = $svg->get_path( | ||||||||||||||||||||||||||||
| 691 | x => $xv, | ||||||||||||||||||||||||||||
| 692 | y => $yv, | ||||||||||||||||||||||||||||
| 693 | -type => 'path', | ||||||||||||||||||||||||||||
| 694 | -closed => 'true' #specify that the polyline is closed | ||||||||||||||||||||||||||||
| 695 | ); | ||||||||||||||||||||||||||||
| 696 | |||||||||||||||||||||||||||||
| 697 | $tag = $svg->path( | ||||||||||||||||||||||||||||
| 698 | %$points, | ||||||||||||||||||||||||||||
| 699 | id => 'pline_1', | ||||||||||||||||||||||||||||
| 700 | style => { | ||||||||||||||||||||||||||||
| 701 | 'fill-opacity' => 0, | ||||||||||||||||||||||||||||
| 702 | 'fill' => 'green', | ||||||||||||||||||||||||||||
| 703 | 'stroke' => 'rgb(250,123,23)' | ||||||||||||||||||||||||||||
| 704 | } | ||||||||||||||||||||||||||||
| 705 | ); | ||||||||||||||||||||||||||||
| 706 | |||||||||||||||||||||||||||||
| 707 | |||||||||||||||||||||||||||||
| 708 | SEE ALSO: L<"get_path">. | ||||||||||||||||||||||||||||
| 709 | |||||||||||||||||||||||||||||
| 710 | =head2 get_path | ||||||||||||||||||||||||||||
| 711 | |||||||||||||||||||||||||||||
| 712 | $path = $svg->get_path(%attributes) | ||||||||||||||||||||||||||||
| 713 | |||||||||||||||||||||||||||||
| 714 | Returns the text string of points correctly formatted to be incorporated into | ||||||||||||||||||||||||||||
| 715 | the multi-point SVG drawing object definitions (path, polyline, polygon) | ||||||||||||||||||||||||||||
| 716 | |||||||||||||||||||||||||||||
| 717 | B<Input:> attributes including: | ||||||||||||||||||||||||||||
| 718 | |||||||||||||||||||||||||||||
| 719 | -type = path type (path | polyline | polygon) | ||||||||||||||||||||||||||||
| 720 | x = reference to array of x coordinates | ||||||||||||||||||||||||||||
| 721 | y = reference to array of y coordinates | ||||||||||||||||||||||||||||
| 722 | |||||||||||||||||||||||||||||
| 723 | B<Output:> a hash reference consisting of the following key-value pair: | ||||||||||||||||||||||||||||
| 724 | |||||||||||||||||||||||||||||
| 725 | points = the appropriate points-definition string | ||||||||||||||||||||||||||||
| 726 | -type = path|polygon|polyline | ||||||||||||||||||||||||||||
| 727 | -relative = 1 (define relative position rather than absolute position) | ||||||||||||||||||||||||||||
| 728 | -closed = 1 (close the curve - path and polygon only) | ||||||||||||||||||||||||||||
| 729 | |||||||||||||||||||||||||||||
| 730 | #generate an open path definition for a path. | ||||||||||||||||||||||||||||
| 731 | my ($points,$p); | ||||||||||||||||||||||||||||
| 732 | $points = $svg->get_path(x=>\@x,y=>\@y,-relative=>1,-type=>'path'); | ||||||||||||||||||||||||||||
| 733 | |||||||||||||||||||||||||||||
| 734 | #add the path to the SVG document | ||||||||||||||||||||||||||||
| 735 | my $p = $svg->path(%$path, style=>\%style_definition); | ||||||||||||||||||||||||||||
| 736 | |||||||||||||||||||||||||||||
| 737 | #generate an closed path definition for a a polyline. | ||||||||||||||||||||||||||||
| 738 | $points = $svg->get_path( | ||||||||||||||||||||||||||||
| 739 | x=>\@x, | ||||||||||||||||||||||||||||
| 740 | y=>\@y, | ||||||||||||||||||||||||||||
| 741 | -relative=>1, | ||||||||||||||||||||||||||||
| 742 | -type=>'polyline', | ||||||||||||||||||||||||||||
| 743 | -closed=>1 | ||||||||||||||||||||||||||||
| 744 | ); # generate a closed path definition for a polyline | ||||||||||||||||||||||||||||
| 745 | |||||||||||||||||||||||||||||
| 746 | # add the polyline to the SVG document | ||||||||||||||||||||||||||||
| 747 | $p = $svg->polyline(%$points, id=>'pline1'); | ||||||||||||||||||||||||||||
| 748 | |||||||||||||||||||||||||||||
| 749 | B<Note:> The attribute returned depends on the element type: | ||||||||||||||||||||||||||||
| 750 | C<-type =E<gt> 'path'> returns C<< { d => ... } >>, | ||||||||||||||||||||||||||||
| 751 | while C<-type =E<gt> 'polygon'> and C<-type =E<gt> 'polyline'> | ||||||||||||||||||||||||||||
| 752 | return C<< { points => ... } >>. | ||||||||||||||||||||||||||||
| 753 | |||||||||||||||||||||||||||||
| 754 | B<Aliases:> get_path set_path | ||||||||||||||||||||||||||||
| 755 | |||||||||||||||||||||||||||||
| 756 | |||||||||||||||||||||||||||||
| 757 | =head2 animate | ||||||||||||||||||||||||||||
| 758 | |||||||||||||||||||||||||||||
| 759 | $tag = $svg->animate(%attributes) | ||||||||||||||||||||||||||||
| 760 | |||||||||||||||||||||||||||||
| 761 | Generate an SMIL animation tag. This is allowed within any nonempty tag. Refer | ||||||||||||||||||||||||||||
| 762 | to the W3C for detailed information on the subtleties of the animate SMIL | ||||||||||||||||||||||||||||
| 763 | commands. | ||||||||||||||||||||||||||||
| 764 | |||||||||||||||||||||||||||||
| 765 | B<Inputs:> -method = Transform | Motion | Color | ||||||||||||||||||||||||||||
| 766 | |||||||||||||||||||||||||||||
| 767 | my $an_ellipse = $svg->ellipse( | ||||||||||||||||||||||||||||
| 768 | cx => 30, | ||||||||||||||||||||||||||||
| 769 | cy => 150, | ||||||||||||||||||||||||||||
| 770 | rx => 10, | ||||||||||||||||||||||||||||
| 771 | ry => 10, | ||||||||||||||||||||||||||||
| 772 | id => 'an_ellipse', | ||||||||||||||||||||||||||||
| 773 | stroke => 'rgb(130,220,70)', | ||||||||||||||||||||||||||||
| 774 | fill =>'rgb(30,20,50)' | ||||||||||||||||||||||||||||
| 775 | ); | ||||||||||||||||||||||||||||
| 776 | |||||||||||||||||||||||||||||
| 777 | $an_ellipse-> animate( | ||||||||||||||||||||||||||||
| 778 | attributeName => "cx", | ||||||||||||||||||||||||||||
| 779 | values => "20; 200; 20", | ||||||||||||||||||||||||||||
| 780 | dur => "10s", | ||||||||||||||||||||||||||||
| 781 | repeatDur => 'indefinite' | ||||||||||||||||||||||||||||
| 782 | ); | ||||||||||||||||||||||||||||
| 783 | |||||||||||||||||||||||||||||
| 784 | $an_ellipse-> animate( | ||||||||||||||||||||||||||||
| 785 | attributeName => "rx", | ||||||||||||||||||||||||||||
| 786 | values => "10;30;20;100;50", | ||||||||||||||||||||||||||||
| 787 | dur => "10s", | ||||||||||||||||||||||||||||
| 788 | repeatDur => 'indefinite', | ||||||||||||||||||||||||||||
| 789 | ); | ||||||||||||||||||||||||||||
| 790 | |||||||||||||||||||||||||||||
| 791 | $an_ellipse-> animate( | ||||||||||||||||||||||||||||
| 792 | attributeName => "ry", | ||||||||||||||||||||||||||||
| 793 | values => "30;50;10;20;70;150", | ||||||||||||||||||||||||||||
| 794 | dur => "15s", | ||||||||||||||||||||||||||||
| 795 | repeatDur => 'indefinite', | ||||||||||||||||||||||||||||
| 796 | ); | ||||||||||||||||||||||||||||
| 797 | |||||||||||||||||||||||||||||
| 798 | $an_ellipse-> animate( | ||||||||||||||||||||||||||||
| 799 | attributeName=>"rx",values=>"30;75;10;100;20;20;150", | ||||||||||||||||||||||||||||
| 800 | dur=>"20s", repeatDur=>'indefinite'); | ||||||||||||||||||||||||||||
| 801 | |||||||||||||||||||||||||||||
| 802 | $an_ellipse-> animate( | ||||||||||||||||||||||||||||
| 803 | attributeName=>"fill",values=>"red;green;blue;cyan;yellow", | ||||||||||||||||||||||||||||
| 804 | dur=>"5s", repeatDur=>'indefinite'); | ||||||||||||||||||||||||||||
| 805 | |||||||||||||||||||||||||||||
| 806 | $an_ellipse-> animate( | ||||||||||||||||||||||||||||
| 807 | attributeName=>"fill-opacity",values=>"0;1;0.5;0.75;1", | ||||||||||||||||||||||||||||
| 808 | dur=>"20s",repeatDur=>'indefinite'); | ||||||||||||||||||||||||||||
| 809 | |||||||||||||||||||||||||||||
| 810 | $an_ellipse-> animate( | ||||||||||||||||||||||||||||
| 811 | attributeName=>"stroke-width",values=>"1;3;2;10;5", | ||||||||||||||||||||||||||||
| 812 | dur=>"20s",repeatDur=>'indefinite'); | ||||||||||||||||||||||||||||
| 813 | |||||||||||||||||||||||||||||
| 814 | =head2 group | ||||||||||||||||||||||||||||
| 815 | |||||||||||||||||||||||||||||
| 816 | $tag = $svg->group(%attributes) | ||||||||||||||||||||||||||||
| 817 | |||||||||||||||||||||||||||||
| 818 | Define a group of objects with common properties. Groups can have style, | ||||||||||||||||||||||||||||
| 819 | animation, filters, transformations, and mouse actions assigned to them. | ||||||||||||||||||||||||||||
| 820 | |||||||||||||||||||||||||||||
| 821 | $tag = $svg->group( | ||||||||||||||||||||||||||||
| 822 | id => 'xvs000248', | ||||||||||||||||||||||||||||
| 823 | style => { | ||||||||||||||||||||||||||||
| 824 | 'font' => [ qw( Arial Helvetica sans ) ], | ||||||||||||||||||||||||||||
| 825 | 'font-size' => 10, | ||||||||||||||||||||||||||||
| 826 | 'fill' => 'red', | ||||||||||||||||||||||||||||
| 827 | }, | ||||||||||||||||||||||||||||
| 828 | transform => 'rotate(-45)' | ||||||||||||||||||||||||||||
| 829 | ); | ||||||||||||||||||||||||||||
| 830 | |||||||||||||||||||||||||||||
| 831 | =head2 defs | ||||||||||||||||||||||||||||
| 832 | |||||||||||||||||||||||||||||
| 833 | $tag = $svg->defs(%attributes) | ||||||||||||||||||||||||||||
| 834 | |||||||||||||||||||||||||||||
| 835 | define a definition segment. A Defs requires children when defined using SVG.pm | ||||||||||||||||||||||||||||
| 836 | |||||||||||||||||||||||||||||
| 837 | $tag = $svg->defs(id => 'def_con_one',); | ||||||||||||||||||||||||||||
| 838 | |||||||||||||||||||||||||||||
| 839 | =head2 style | ||||||||||||||||||||||||||||
| 840 | |||||||||||||||||||||||||||||
| 841 | $svg->tag('style', %styledef); | ||||||||||||||||||||||||||||
| 842 | |||||||||||||||||||||||||||||
| 843 | Sets/adds style-definition for the following objects being created. | ||||||||||||||||||||||||||||
| 844 | |||||||||||||||||||||||||||||
| 845 | Style definitions apply to an object and all its children for all properties for | ||||||||||||||||||||||||||||
| 846 | which the value of the property is not redefined by the child. | ||||||||||||||||||||||||||||
| 847 | |||||||||||||||||||||||||||||
| 848 | $tag = $SVG->style(%attributes) | ||||||||||||||||||||||||||||
| 849 | |||||||||||||||||||||||||||||
| 850 | Generate a style container for inline or xlink:href based styling instructions | ||||||||||||||||||||||||||||
| 851 | |||||||||||||||||||||||||||||
| 852 | my $tag = $SVG->style(type=>"text/css"); | ||||||||||||||||||||||||||||
| 853 | |||||||||||||||||||||||||||||
| 854 | # Populate the style tag with cdata. | ||||||||||||||||||||||||||||
| 855 | # Be careful to manage the line ends. | ||||||||||||||||||||||||||||
| 856 | # Use qq{text}, where text is the script | ||||||||||||||||||||||||||||
| 857 | |||||||||||||||||||||||||||||
| 858 | $tag1->CDATA(qq{ | ||||||||||||||||||||||||||||
| 859 | rect fill:red;stroke:green; | ||||||||||||||||||||||||||||
| 860 | circle fill:red;stroke:orange; | ||||||||||||||||||||||||||||
| 861 | ellipse fill:none;stroke:yellow; | ||||||||||||||||||||||||||||
| 862 | text fill:black;stroke:none; | ||||||||||||||||||||||||||||
| 863 | }); | ||||||||||||||||||||||||||||
| 864 | |||||||||||||||||||||||||||||
| 865 | # Create a external CSS stylesheet reference | ||||||||||||||||||||||||||||
| 866 | my $tag2 = $SVG->style(type=>"text/css", -href="/resources/example.css"); | ||||||||||||||||||||||||||||
| 867 | |||||||||||||||||||||||||||||
| 868 | =head2 mouseaction | ||||||||||||||||||||||||||||
| 869 | |||||||||||||||||||||||||||||
| 870 | $svg->mouseaction(%attributes) | ||||||||||||||||||||||||||||
| 871 | |||||||||||||||||||||||||||||
| 872 | Sets/Adds mouse action definitions for tag | ||||||||||||||||||||||||||||
| 873 | |||||||||||||||||||||||||||||
| 874 | =head2 attrib | ||||||||||||||||||||||||||||
| 875 | |||||||||||||||||||||||||||||
| 876 | $svg->attrib($name, $value) | ||||||||||||||||||||||||||||
| 877 | |||||||||||||||||||||||||||||
| 878 | Sets/adds attributes of an element. | ||||||||||||||||||||||||||||
| 879 | |||||||||||||||||||||||||||||
| 880 | Retrieve an attribute: | ||||||||||||||||||||||||||||
| 881 | |||||||||||||||||||||||||||||
| 882 | $svg->attrib($name); | ||||||||||||||||||||||||||||
| 883 | |||||||||||||||||||||||||||||
| 884 | Set a scalar attribute: | ||||||||||||||||||||||||||||
| 885 | |||||||||||||||||||||||||||||
| 886 | $SVG->attrib $name, $value | ||||||||||||||||||||||||||||
| 887 | |||||||||||||||||||||||||||||
| 888 | Set a list attribute: | ||||||||||||||||||||||||||||
| 889 | |||||||||||||||||||||||||||||
| 890 | $SVG->attrib $name, \@value | ||||||||||||||||||||||||||||
| 891 | |||||||||||||||||||||||||||||
| 892 | Set a hash attribute (i.e. style definitions): | ||||||||||||||||||||||||||||
| 893 | |||||||||||||||||||||||||||||
| 894 | $SVG->attrib $name, \%value | ||||||||||||||||||||||||||||
| 895 | |||||||||||||||||||||||||||||
| 896 | Remove an attribute: | ||||||||||||||||||||||||||||
| 897 | |||||||||||||||||||||||||||||
| 898 | $svg->attrib($name,undef); | ||||||||||||||||||||||||||||
| 899 | |||||||||||||||||||||||||||||
| 900 | B<Aliases:> attr attribute | ||||||||||||||||||||||||||||
| 901 | |||||||||||||||||||||||||||||
| 902 | Sets/replaces attributes for a tag. | ||||||||||||||||||||||||||||
| 903 | |||||||||||||||||||||||||||||
| 904 | =head2 cdata | ||||||||||||||||||||||||||||
| 905 | |||||||||||||||||||||||||||||
| 906 | $svg->cdata($text) | ||||||||||||||||||||||||||||
| 907 | |||||||||||||||||||||||||||||
| 908 | Sets cdata to $text. SVG.pm allows you to set cdata for any tag. If the tag is | ||||||||||||||||||||||||||||
| 909 | meant to be an empty tag, SVG.pm will not complain, but the rendering agent will | ||||||||||||||||||||||||||||
| 910 | fail. In the SVG DTD, cdata is generally only meant for adding text or script | ||||||||||||||||||||||||||||
| 911 | content. | ||||||||||||||||||||||||||||
| 912 | |||||||||||||||||||||||||||||
| 913 | $svg->text( | ||||||||||||||||||||||||||||
| 914 | style => { | ||||||||||||||||||||||||||||
| 915 | 'font' => 'Arial', | ||||||||||||||||||||||||||||
| 916 | 'font-size' => 20 | ||||||||||||||||||||||||||||
| 917 | })->cdata('SVG.pm is a perl module on CPAN!'); | ||||||||||||||||||||||||||||
| 918 | |||||||||||||||||||||||||||||
| 919 | my $text = $svg->text( style => { 'font' => 'Arial', 'font-size' => 20 } ); | ||||||||||||||||||||||||||||
| 920 | $text->cdata('SVG.pm is a perl module on CPAN!'); | ||||||||||||||||||||||||||||
| 921 | |||||||||||||||||||||||||||||
| 922 | B<Result:> | ||||||||||||||||||||||||||||
| 923 | |||||||||||||||||||||||||||||
| 924 | <text style="font: Arial; font-size: 20">SVG.pm is a perl module on CPAN!</text> | ||||||||||||||||||||||||||||
| 925 | |||||||||||||||||||||||||||||
| 926 | SEE ALSO: | ||||||||||||||||||||||||||||
| 927 | |||||||||||||||||||||||||||||
| 928 | L<"CDATA">, L<"desc">, L<"title">, L<"text">, L<"script">. | ||||||||||||||||||||||||||||
| 929 | |||||||||||||||||||||||||||||
| 930 | =head2 cdata_noxmlesc | ||||||||||||||||||||||||||||
| 931 | |||||||||||||||||||||||||||||
| 932 | $script = $svg->script(); | ||||||||||||||||||||||||||||
| 933 | $script->cdata_noxmlesc($text); | ||||||||||||||||||||||||||||
| 934 | |||||||||||||||||||||||||||||
| 935 | Generates cdata content for text and similar tags which do not get xml-escaped. | ||||||||||||||||||||||||||||
| 936 | In othe words, does not parse the content and inserts the exact string into the cdata location. | ||||||||||||||||||||||||||||
| 937 | |||||||||||||||||||||||||||||
| 938 | =head2 CDATA | ||||||||||||||||||||||||||||
| 939 | |||||||||||||||||||||||||||||
| 940 | $script = $svg->script(); | ||||||||||||||||||||||||||||
| 941 | $script->CDATA($text); | ||||||||||||||||||||||||||||
| 942 | |||||||||||||||||||||||||||||
| 943 | Generates a <![CDATA[ ... ]]> tag with the contents of $text rendered exactly as supplied. SVG.pm allows you to set cdata for any tag. If the tag is | ||||||||||||||||||||||||||||
| 944 | meant to be an empty tag, SVG.pm will not complain, but the rendering agent will | ||||||||||||||||||||||||||||
| 945 | fail. In the SVG DTD, cdata is generally only meant for adding text or script | ||||||||||||||||||||||||||||
| 946 | content. | ||||||||||||||||||||||||||||
| 947 | |||||||||||||||||||||||||||||
| 948 | my $text = qq{ | ||||||||||||||||||||||||||||
| 949 | var SVGDoc; | ||||||||||||||||||||||||||||
| 950 | var groups = new Array(); | ||||||||||||||||||||||||||||
| 951 | var last_group; | ||||||||||||||||||||||||||||
| 952 | |||||||||||||||||||||||||||||
| 953 | /***** | ||||||||||||||||||||||||||||
| 954 | * | ||||||||||||||||||||||||||||
| 955 | * init | ||||||||||||||||||||||||||||
| 956 | * | ||||||||||||||||||||||||||||
| 957 | * Find this SVG's document element | ||||||||||||||||||||||||||||
| 958 | * Define members of each group by id | ||||||||||||||||||||||||||||
| 959 | * | ||||||||||||||||||||||||||||
| 960 | *****/ | ||||||||||||||||||||||||||||
| 961 | function init(e) { | ||||||||||||||||||||||||||||
| 962 | SVGDoc = e.getTarget().getOwnerDocument(); | ||||||||||||||||||||||||||||
| 963 | append_group(1, 4, 6); // group 0 | ||||||||||||||||||||||||||||
| 964 | append_group(5, 4, 3); // group 1 | ||||||||||||||||||||||||||||
| 965 | append_group(2, 3); // group 2 | ||||||||||||||||||||||||||||
| 966 | }}; | ||||||||||||||||||||||||||||
| 967 | $svg->script()->CDATA($text); | ||||||||||||||||||||||||||||
| 968 | |||||||||||||||||||||||||||||
| 969 | |||||||||||||||||||||||||||||
| 970 | B<Result:> | ||||||||||||||||||||||||||||
| 971 | |||||||||||||||||||||||||||||
| 972 | E<lt>script E<gt> | ||||||||||||||||||||||||||||
| 973 | <gt>![CDATA[ | ||||||||||||||||||||||||||||
| 974 | var SVGDoc; | ||||||||||||||||||||||||||||
| 975 | var groups = new Array(); | ||||||||||||||||||||||||||||
| 976 | var last_group; | ||||||||||||||||||||||||||||
| 977 | |||||||||||||||||||||||||||||
| 978 | /***** | ||||||||||||||||||||||||||||
| 979 | * | ||||||||||||||||||||||||||||
| 980 | * init | ||||||||||||||||||||||||||||
| 981 | * | ||||||||||||||||||||||||||||
| 982 | * Find this SVG's document element | ||||||||||||||||||||||||||||
| 983 | * Define members of each group by id | ||||||||||||||||||||||||||||
| 984 | * | ||||||||||||||||||||||||||||
| 985 | *****/ | ||||||||||||||||||||||||||||
| 986 | function init(e) { | ||||||||||||||||||||||||||||
| 987 | SVGDoc = e.getTarget().getOwnerDocument(); | ||||||||||||||||||||||||||||
| 988 | append_group(1, 4, 6); // group 0 | ||||||||||||||||||||||||||||
| 989 | append_group(5, 4, 3); // group 1 | ||||||||||||||||||||||||||||
| 990 | append_group(2, 3); // group 2 | ||||||||||||||||||||||||||||
| 991 | } | ||||||||||||||||||||||||||||
| 992 | ]]E<gt> | ||||||||||||||||||||||||||||
| 993 | |||||||||||||||||||||||||||||
| 994 | SEE ALSO: L<"cdata">, L<"script">. | ||||||||||||||||||||||||||||
| 995 | |||||||||||||||||||||||||||||
| 996 | =head2 xmlescp and xmlescape | ||||||||||||||||||||||||||||
| 997 | |||||||||||||||||||||||||||||
| 998 | $string = $svg->xmlescp($string) | ||||||||||||||||||||||||||||
| 999 | $string = $svg->xmlesc($string) | ||||||||||||||||||||||||||||
| 1000 | $string = $svg->xmlescape($string) | ||||||||||||||||||||||||||||
| 1001 | |||||||||||||||||||||||||||||
| 1002 | SVG module does not xml-escape characters that are incompatible with the XML specification. B<xmlescp> and B<xmlescape> provides this functionality. It is a helper function which generates an XML-escaped string for reserved characters such as ampersand, open and close brackets, etcetera. | ||||||||||||||||||||||||||||
| 1003 | |||||||||||||||||||||||||||||
| 1004 | The behaviour of xmlesc is to apply the following transformation to the input string $s: | ||||||||||||||||||||||||||||
| 1005 | |||||||||||||||||||||||||||||
| 1006 | $s=~s/&(?!#(x\w\w|\d+?);)/&/g; | ||||||||||||||||||||||||||||
| 1007 | $s=~s/>/>/g; | ||||||||||||||||||||||||||||
| 1008 | $s=~s/</</g; | ||||||||||||||||||||||||||||
| 1009 | $s=~s/\"/"/g; | ||||||||||||||||||||||||||||
| 1010 | $s=~s/\'/'/g; | ||||||||||||||||||||||||||||
| 1011 | $s=~s/([\x00-\x08\x0b\x1f])/''/eg; | ||||||||||||||||||||||||||||
| 1012 | $s=~s/([\200-\377])/'&#'.ord($1).';'/ge; | ||||||||||||||||||||||||||||
| 1013 | |||||||||||||||||||||||||||||
| 1014 | |||||||||||||||||||||||||||||
| 1015 | =head2 filter | ||||||||||||||||||||||||||||
| 1016 | |||||||||||||||||||||||||||||
| 1017 | $tag = $svg->filter(%attributes) | ||||||||||||||||||||||||||||
| 1018 | |||||||||||||||||||||||||||||
| 1019 | Generate a filter. Filter elements contain L<"fe"> filter sub-elements. | ||||||||||||||||||||||||||||
| 1020 | |||||||||||||||||||||||||||||
| 1021 | my $filter = $svg->filter( | ||||||||||||||||||||||||||||
| 1022 | filterUnits=>"objectBoundingBox", | ||||||||||||||||||||||||||||
| 1023 | x=>"-10%", | ||||||||||||||||||||||||||||
| 1024 | y=>"-10%", | ||||||||||||||||||||||||||||
| 1025 | width=>"150%", | ||||||||||||||||||||||||||||
| 1026 | height=>"150%", | ||||||||||||||||||||||||||||
| 1027 | filterUnits=>'objectBoundingBox' | ||||||||||||||||||||||||||||
| 1028 | ); | ||||||||||||||||||||||||||||
| 1029 | |||||||||||||||||||||||||||||
| 1030 | $filter->fe(); | ||||||||||||||||||||||||||||
| 1031 | |||||||||||||||||||||||||||||
| 1032 | SEE ALSO: L<"fe">. | ||||||||||||||||||||||||||||
| 1033 | |||||||||||||||||||||||||||||
| 1034 | =head2 fe | ||||||||||||||||||||||||||||
| 1035 | |||||||||||||||||||||||||||||
| 1036 | $tag = $svg->fe(-type=>'type', %attributes) | ||||||||||||||||||||||||||||
| 1037 | |||||||||||||||||||||||||||||
| 1038 | Generate a filter sub-element. Must be a child of a L<"filter"> element. | ||||||||||||||||||||||||||||
| 1039 | |||||||||||||||||||||||||||||
| 1040 | my $fe = $svg->fe( | ||||||||||||||||||||||||||||
| 1041 | -type => 'DiffuseLighting' # required - element name omitting 'fe' | ||||||||||||||||||||||||||||
| 1042 | id => 'filter_1', | ||||||||||||||||||||||||||||
| 1043 | style => { | ||||||||||||||||||||||||||||
| 1044 | 'font' => [ qw(Arial Helvetica sans) ], | ||||||||||||||||||||||||||||
| 1045 | 'font-size' => 10, | ||||||||||||||||||||||||||||
| 1046 | 'fill' => 'red', | ||||||||||||||||||||||||||||
| 1047 | }, | ||||||||||||||||||||||||||||
| 1048 | transform => 'rotate(-45)' | ||||||||||||||||||||||||||||
| 1049 | ); | ||||||||||||||||||||||||||||
| 1050 | |||||||||||||||||||||||||||||
| 1051 | Note that the following filter elements are currently supported: | ||||||||||||||||||||||||||||
| 1052 | Also note that the elelemts are defined in lower case in the module, but as of version 2.441, any case combination is allowed. | ||||||||||||||||||||||||||||
| 1053 | |||||||||||||||||||||||||||||
| 1054 | |||||||||||||||||||||||||||||
| 1055 | =head2 * feBlend | ||||||||||||||||||||||||||||
| 1056 | |||||||||||||||||||||||||||||
| 1057 | =head2 * feColorMatrix | ||||||||||||||||||||||||||||
| 1058 | |||||||||||||||||||||||||||||
| 1059 | =head2 * feComponentTransfer | ||||||||||||||||||||||||||||
| 1060 | |||||||||||||||||||||||||||||
| 1061 | =head2 * feComposite | ||||||||||||||||||||||||||||
| 1062 | |||||||||||||||||||||||||||||
| 1063 | =head2 * feConvolveMatrix | ||||||||||||||||||||||||||||
| 1064 | |||||||||||||||||||||||||||||
| 1065 | =head2 * feDiffuseLighting | ||||||||||||||||||||||||||||
| 1066 | |||||||||||||||||||||||||||||
| 1067 | =head2 * feDisplacementMap | ||||||||||||||||||||||||||||
| 1068 | |||||||||||||||||||||||||||||
| 1069 | =head2 * feDistantLight | ||||||||||||||||||||||||||||
| 1070 | |||||||||||||||||||||||||||||
| 1071 | =head2 * feFlood | ||||||||||||||||||||||||||||
| 1072 | |||||||||||||||||||||||||||||
| 1073 | =head2 * feFuncA | ||||||||||||||||||||||||||||
| 1074 | |||||||||||||||||||||||||||||
| 1075 | =head2 * feFuncB | ||||||||||||||||||||||||||||
| 1076 | |||||||||||||||||||||||||||||
| 1077 | =head2 * feFuncG | ||||||||||||||||||||||||||||
| 1078 | |||||||||||||||||||||||||||||
| 1079 | =head2 * feFuncR | ||||||||||||||||||||||||||||
| 1080 | |||||||||||||||||||||||||||||
| 1081 | =head2 * feGaussianBlur | ||||||||||||||||||||||||||||
| 1082 | |||||||||||||||||||||||||||||
| 1083 | =head2 * feImage | ||||||||||||||||||||||||||||
| 1084 | |||||||||||||||||||||||||||||
| 1085 | =head2 * feMerge | ||||||||||||||||||||||||||||
| 1086 | |||||||||||||||||||||||||||||
| 1087 | =head2 * feMergeNode | ||||||||||||||||||||||||||||
| 1088 | |||||||||||||||||||||||||||||
| 1089 | =head2 * feMorphology | ||||||||||||||||||||||||||||
| 1090 | |||||||||||||||||||||||||||||
| 1091 | =head2 * feOffset | ||||||||||||||||||||||||||||
| 1092 | |||||||||||||||||||||||||||||
| 1093 | =head2 * fePointLight | ||||||||||||||||||||||||||||
| 1094 | |||||||||||||||||||||||||||||
| 1095 | =head2 * feSpecularLighting | ||||||||||||||||||||||||||||
| 1096 | |||||||||||||||||||||||||||||
| 1097 | =head2 * feSpotLight | ||||||||||||||||||||||||||||
| 1098 | |||||||||||||||||||||||||||||
| 1099 | =head2 * feTile | ||||||||||||||||||||||||||||
| 1100 | |||||||||||||||||||||||||||||
| 1101 | =head2 * feTurbulence | ||||||||||||||||||||||||||||
| 1102 | |||||||||||||||||||||||||||||
| 1103 | |||||||||||||||||||||||||||||
| 1104 | SEE ALSO: L<"filter">. | ||||||||||||||||||||||||||||
| 1105 | |||||||||||||||||||||||||||||
| 1106 | =head2 pattern | ||||||||||||||||||||||||||||
| 1107 | |||||||||||||||||||||||||||||
| 1108 | $tag = $svg->pattern(%attributes) | ||||||||||||||||||||||||||||
| 1109 | |||||||||||||||||||||||||||||
| 1110 | Define a pattern for later reference by url. | ||||||||||||||||||||||||||||
| 1111 | |||||||||||||||||||||||||||||
| 1112 | my $pattern = $svg->pattern( | ||||||||||||||||||||||||||||
| 1113 | id => "Argyle_1", | ||||||||||||||||||||||||||||
| 1114 | width => "50", | ||||||||||||||||||||||||||||
| 1115 | height => "50", | ||||||||||||||||||||||||||||
| 1116 | patternUnits => "userSpaceOnUse", | ||||||||||||||||||||||||||||
| 1117 | patternContentUnits => "userSpaceOnUse" | ||||||||||||||||||||||||||||
| 1118 | ); | ||||||||||||||||||||||||||||
| 1119 | |||||||||||||||||||||||||||||
| 1120 | =head2 set | ||||||||||||||||||||||||||||
| 1121 | |||||||||||||||||||||||||||||
| 1122 | $tag = $svg->set(%attributes) | ||||||||||||||||||||||||||||
| 1123 | |||||||||||||||||||||||||||||
| 1124 | Set a definition for an SVG object in one section, to be referenced in other | ||||||||||||||||||||||||||||
| 1125 | sections as needed. | ||||||||||||||||||||||||||||
| 1126 | |||||||||||||||||||||||||||||
| 1127 | my $set = $svg->set( | ||||||||||||||||||||||||||||
| 1128 | id => "Argyle_1", | ||||||||||||||||||||||||||||
| 1129 | width => "50", | ||||||||||||||||||||||||||||
| 1130 | height => "50", | ||||||||||||||||||||||||||||
| 1131 | patternUnits => "userSpaceOnUse", | ||||||||||||||||||||||||||||
| 1132 | patternContentUnits => "userSpaceOnUse" | ||||||||||||||||||||||||||||
| 1133 | ); | ||||||||||||||||||||||||||||
| 1134 | |||||||||||||||||||||||||||||
| 1135 | =head2 stop | ||||||||||||||||||||||||||||
| 1136 | |||||||||||||||||||||||||||||
| 1137 | $tag = $svg->stop(%attributes) | ||||||||||||||||||||||||||||
| 1138 | |||||||||||||||||||||||||||||
| 1139 | Define a stop boundary for L<"gradient"> | ||||||||||||||||||||||||||||
| 1140 | |||||||||||||||||||||||||||||
| 1141 | my $pattern = $svg->stop( | ||||||||||||||||||||||||||||
| 1142 | id => "Argyle_1", | ||||||||||||||||||||||||||||
| 1143 | width => "50", | ||||||||||||||||||||||||||||
| 1144 | height => "50", | ||||||||||||||||||||||||||||
| 1145 | patternUnits => "userSpaceOnUse", | ||||||||||||||||||||||||||||
| 1146 | patternContentUnits => "userSpaceOnUse" | ||||||||||||||||||||||||||||
| 1147 | ); | ||||||||||||||||||||||||||||
| 1148 | |||||||||||||||||||||||||||||
| 1149 | =head2 gradient | ||||||||||||||||||||||||||||
| 1150 | |||||||||||||||||||||||||||||
| 1151 | $tag = $svg->gradient(%attributes) | ||||||||||||||||||||||||||||
| 1152 | |||||||||||||||||||||||||||||
| 1153 | Define a color gradient. Can be of type B<linear> or B<radial> | ||||||||||||||||||||||||||||
| 1154 | |||||||||||||||||||||||||||||
| 1155 | my $gradient = $svg->gradient( | ||||||||||||||||||||||||||||
| 1156 | -type => "linear", | ||||||||||||||||||||||||||||
| 1157 | id => "gradient_1" | ||||||||||||||||||||||||||||
| 1158 | ); | ||||||||||||||||||||||||||||
| 1159 | |||||||||||||||||||||||||||||
| 1160 | =head1 GENERIC ELEMENT METHODS | ||||||||||||||||||||||||||||
| 1161 | |||||||||||||||||||||||||||||
| 1162 | The following elements are generically supported by SVG: | ||||||||||||||||||||||||||||
| 1163 | |||||||||||||||||||||||||||||
| 1164 | |||||||||||||||||||||||||||||
| 1165 | =head2 * altGlyph | ||||||||||||||||||||||||||||
| 1166 | |||||||||||||||||||||||||||||
| 1167 | =head2 * altGlyphDef | ||||||||||||||||||||||||||||
| 1168 | |||||||||||||||||||||||||||||
| 1169 | =head2 * altGlyphItem | ||||||||||||||||||||||||||||
| 1170 | |||||||||||||||||||||||||||||
| 1171 | =head2 * clipPath | ||||||||||||||||||||||||||||
| 1172 | |||||||||||||||||||||||||||||
| 1173 | =head2 * color-profile | ||||||||||||||||||||||||||||
| 1174 | |||||||||||||||||||||||||||||
| 1175 | =head2 * cursor | ||||||||||||||||||||||||||||
| 1176 | |||||||||||||||||||||||||||||
| 1177 | =head2 * definition-src | ||||||||||||||||||||||||||||
| 1178 | |||||||||||||||||||||||||||||
| 1179 | =head2 * font-face-format | ||||||||||||||||||||||||||||
| 1180 | |||||||||||||||||||||||||||||
| 1181 | =head2 * font-face-name | ||||||||||||||||||||||||||||
| 1182 | |||||||||||||||||||||||||||||
| 1183 | =head2 * font-face-src | ||||||||||||||||||||||||||||
| 1184 | |||||||||||||||||||||||||||||
| 1185 | =head2 * font-face-url | ||||||||||||||||||||||||||||
| 1186 | |||||||||||||||||||||||||||||
| 1187 | =head2 * foreignObject | ||||||||||||||||||||||||||||
| 1188 | |||||||||||||||||||||||||||||
| 1189 | =head2 * glyph | ||||||||||||||||||||||||||||
| 1190 | |||||||||||||||||||||||||||||
| 1191 | =head2 * glyphRef | ||||||||||||||||||||||||||||
| 1192 | |||||||||||||||||||||||||||||
| 1193 | =head2 * hkern | ||||||||||||||||||||||||||||
| 1194 | |||||||||||||||||||||||||||||
| 1195 | =head2 * marker | ||||||||||||||||||||||||||||
| 1196 | |||||||||||||||||||||||||||||
| 1197 | =head2 * mask | ||||||||||||||||||||||||||||
| 1198 | |||||||||||||||||||||||||||||
| 1199 | =head2 * metadata | ||||||||||||||||||||||||||||
| 1200 | |||||||||||||||||||||||||||||
| 1201 | =head2 * missing-glyph | ||||||||||||||||||||||||||||
| 1202 | |||||||||||||||||||||||||||||
| 1203 | =head2 * mpath | ||||||||||||||||||||||||||||
| 1204 | |||||||||||||||||||||||||||||
| 1205 | =head2 * switch | ||||||||||||||||||||||||||||
| 1206 | |||||||||||||||||||||||||||||
| 1207 | =head2 * symbol | ||||||||||||||||||||||||||||
| 1208 | |||||||||||||||||||||||||||||
| 1209 | =head2 * tref | ||||||||||||||||||||||||||||
| 1210 | |||||||||||||||||||||||||||||
| 1211 | =head2 * view | ||||||||||||||||||||||||||||
| 1212 | |||||||||||||||||||||||||||||
| 1213 | =head2 * vkern | ||||||||||||||||||||||||||||
| 1214 | |||||||||||||||||||||||||||||
| 1215 | See e.g. L</pattern> for an example of the use of these methods. | ||||||||||||||||||||||||||||
| 1216 | |||||||||||||||||||||||||||||
| 1217 | =head1 METHODS IMPORTED BY SVG::DOM | ||||||||||||||||||||||||||||
| 1218 | |||||||||||||||||||||||||||||
| 1219 | The following L<SVG::DOM> elements are accessible through SVG: | ||||||||||||||||||||||||||||
| 1220 | |||||||||||||||||||||||||||||
| 1221 | =head2 * getChildren | ||||||||||||||||||||||||||||
| 1222 | |||||||||||||||||||||||||||||
| 1223 | =head2 * getFirstChild | ||||||||||||||||||||||||||||
| 1224 | |||||||||||||||||||||||||||||
| 1225 | =head2 * getNextChild | ||||||||||||||||||||||||||||
| 1226 | |||||||||||||||||||||||||||||
| 1227 | =head2 * getLastChild | ||||||||||||||||||||||||||||
| 1228 | |||||||||||||||||||||||||||||
| 1229 | =head2 * getParent | ||||||||||||||||||||||||||||
| 1230 | |||||||||||||||||||||||||||||
| 1231 | =head2 * getParentElement | ||||||||||||||||||||||||||||
| 1232 | |||||||||||||||||||||||||||||
| 1233 | =head2 * getSiblings | ||||||||||||||||||||||||||||
| 1234 | |||||||||||||||||||||||||||||
| 1235 | =head2 * getElementByID | ||||||||||||||||||||||||||||
| 1236 | |||||||||||||||||||||||||||||
| 1237 | =head2 * getElementID | ||||||||||||||||||||||||||||
| 1238 | |||||||||||||||||||||||||||||
| 1239 | =head2 * getElements | ||||||||||||||||||||||||||||
| 1240 | |||||||||||||||||||||||||||||
| 1241 | =head2 * getElementName | ||||||||||||||||||||||||||||
| 1242 | |||||||||||||||||||||||||||||
| 1243 | =head2 * getType | ||||||||||||||||||||||||||||
| 1244 | |||||||||||||||||||||||||||||
| 1245 | =head2 * getAttributes | ||||||||||||||||||||||||||||
| 1246 | |||||||||||||||||||||||||||||
| 1247 | =head2 * getAttribute | ||||||||||||||||||||||||||||
| 1248 | |||||||||||||||||||||||||||||
| 1249 | =head2 * setAttributes | ||||||||||||||||||||||||||||
| 1250 | |||||||||||||||||||||||||||||
| 1251 | =head2 * setAttribute | ||||||||||||||||||||||||||||
| 1252 | |||||||||||||||||||||||||||||
| 1253 | =head2 * insertBefore | ||||||||||||||||||||||||||||
| 1254 | |||||||||||||||||||||||||||||
| 1255 | =head2 * insertAfter | ||||||||||||||||||||||||||||
| 1256 | |||||||||||||||||||||||||||||
| 1257 | =head2 * insertSiblingBefore | ||||||||||||||||||||||||||||
| 1258 | |||||||||||||||||||||||||||||
| 1259 | =head2 * insertSiblingAfter | ||||||||||||||||||||||||||||
| 1260 | |||||||||||||||||||||||||||||
| 1261 | =head2 * replaceChild | ||||||||||||||||||||||||||||
| 1262 | |||||||||||||||||||||||||||||
| 1263 | =head2 * removeChild | ||||||||||||||||||||||||||||
| 1264 | |||||||||||||||||||||||||||||
| 1265 | =head2 * cloneNode | ||||||||||||||||||||||||||||
| 1266 | |||||||||||||||||||||||||||||
| 1267 | =cut | ||||||||||||||||||||||||||||
| 1268 | |||||||||||||||||||||||||||||
| 1269 | #------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 1270 | |||||||||||||||||||||||||||||
| 1271 | 30 | my %default_attrs = ( | |||||||||||||||||||||||||||
| 1272 | |||||||||||||||||||||||||||||
| 1273 | # processing options | ||||||||||||||||||||||||||||
| 1274 | -auto => 0, # permit arbitrary autoloads (only at import) | ||||||||||||||||||||||||||||
| 1275 | -printerror => 1, # print error messages to STDERR | ||||||||||||||||||||||||||||
| 1276 | -raiseerror => 1, # die on errors (implies -printerror) | ||||||||||||||||||||||||||||
| 1277 | |||||||||||||||||||||||||||||
| 1278 | # rendering options | ||||||||||||||||||||||||||||
| 1279 | -indent => "\t", # what to indent with | ||||||||||||||||||||||||||||
| 1280 | -elsep => "\n", # element line (vertical) separator | ||||||||||||||||||||||||||||
| 1281 | -nocredits => 0, # enable/disable credit note comment | ||||||||||||||||||||||||||||
| 1282 | -namespace => | ||||||||||||||||||||||||||||
| 1283 | '', # The root element's (and it's children's) namespace prefix | ||||||||||||||||||||||||||||
| 1284 | |||||||||||||||||||||||||||||
| 1285 | # XML and Doctype declarations | ||||||||||||||||||||||||||||
| 1286 | -inline => 0, # inline or stand alone | ||||||||||||||||||||||||||||
| 1287 | -docroot => 'svg', # The document's root element | ||||||||||||||||||||||||||||
| 1288 | -version => '1.0', | ||||||||||||||||||||||||||||
| 1289 | -extension => '', | ||||||||||||||||||||||||||||
| 1290 | -encoding => 'UTF-8', | ||||||||||||||||||||||||||||
| 1291 | -xml_svg => 'http://www.w3.org/2000/svg', | ||||||||||||||||||||||||||||
| 1292 | -xml_xlink => 'http://www.w3.org/1999/xlink', | ||||||||||||||||||||||||||||
| 1293 | -standalone => 'yes', | ||||||||||||||||||||||||||||
| 1294 | -pubid => '-//W3C//DTD SVG 1.0//EN', # formerly -identifier | ||||||||||||||||||||||||||||
| 1295 | -sysid => 'http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd', | ||||||||||||||||||||||||||||
| 1296 | ); | ||||||||||||||||||||||||||||
| 1297 | |||||||||||||||||||||||||||||
| 1298 | 33 | ▶ | sub import { | ||||||||||||||||||||||||||
|
Subroutine
import: called CC=7 SCAR=19.5
| |||||||||||||||||||||||||||||
| 1299 | 33 | my $package = shift; | |||||||||||||||||||||||||||
| 1300 | |||||||||||||||||||||||||||||
| 1301 | 33 | my $attr = undef; | |||||||||||||||||||||||||||
| 1302 | 33 | foreach (@_) { | |||||||||||||||||||||||||||
| 1303 | 26 | ▶ | if ($attr) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 1304 | 9 | $default_attrs{$attr} = $_; | |||||||||||||||||||||||||||
| 1305 | 9 | undef $attr; | |||||||||||||||||||||||||||
| 1306 | } | ||||||||||||||||||||||||||||
| 1307 | elsif ( exists $default_attrs{$_} ) { | ||||||||||||||||||||||||||||
| 1308 | 9 | $attr = $_; | |||||||||||||||||||||||||||
| 1309 | } | ||||||||||||||||||||||||||||
| 1310 | else { | ||||||||||||||||||||||||||||
| 1311 | 8 | ▶ | /^-/ and die "Unknown attribute '$_' in import list\n"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1312 | 7 | $SVG::Element::autosubs{$_} | |||||||||||||||||||||||||||
| 1313 | = 1; # add to list of autoloadable tags | ||||||||||||||||||||||||||||
| 1314 | } | ||||||||||||||||||||||||||||
| 1315 | } | ||||||||||||||||||||||||||||
| 1316 | |||||||||||||||||||||||||||||
| 1317 | # switch on AUTOLOADer, if asked. | ||||||||||||||||||||||||||||
| 1318 | 32 | ▶ | if ( $default_attrs{'-auto'} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1319 | 1 | *SVG::Element::AUTOLOAD = \&SVG::Element::autoload; | |||||||||||||||||||||||||||
| 1320 | } | ||||||||||||||||||||||||||||
| 1321 | |||||||||||||||||||||||||||||
| 1322 | # predeclare any additional elements asked for by the user | ||||||||||||||||||||||||||||
| 1323 | 32 | foreach my $sub ( keys %SVG::Element::autosubs ) { | |||||||||||||||||||||||||||
| 1324 | 1517 | $SVG::Element::AUTOLOAD = ("SVG::Element::$sub"); | |||||||||||||||||||||||||||
| 1325 | 1517 | SVG::Element::autoload(); | |||||||||||||||||||||||||||
| 1326 | } | ||||||||||||||||||||||||||||
| 1327 | |||||||||||||||||||||||||||||
| 1328 | 32 | delete $default_attrs{-auto}; # -auto is only allowed here, not in new | |||||||||||||||||||||||||||
| 1329 | |||||||||||||||||||||||||||||
| 1330 | 32 | return (); | |||||||||||||||||||||||||||
| 1331 | } | ||||||||||||||||||||||||||||
| 1332 | |||||||||||||||||||||||||||||
| 1333 | #------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 1334 | |||||||||||||||||||||||||||||
| 1335 | =pod | ||||||||||||||||||||||||||||
| 1336 | |||||||||||||||||||||||||||||
| 1337 | =head1 Methods | ||||||||||||||||||||||||||||
| 1338 | |||||||||||||||||||||||||||||
| 1339 | SVG provides both explicit and generic element constructor methods. Explicit | ||||||||||||||||||||||||||||
| 1340 | generators are generally (with a few exceptions) named for the element they | ||||||||||||||||||||||||||||
| 1341 | generate. If a tag method is required for a tag containing hyphens, the method | ||||||||||||||||||||||||||||
| 1342 | name replaces the hyphen with an underscore. ie: to generate tag <column-heading id="new"> | ||||||||||||||||||||||||||||
| 1343 | you would use method $svg->column_heading(id=>'new'). | ||||||||||||||||||||||||||||
| 1344 | |||||||||||||||||||||||||||||
| 1345 | |||||||||||||||||||||||||||||
| 1346 | All element constructors take a hash of element attributes and options; | ||||||||||||||||||||||||||||
| 1347 | element attributes such as 'id' or 'border' are passed by name, while options for the | ||||||||||||||||||||||||||||
| 1348 | method (such as the type of an element that supports multiple alternate forms) | ||||||||||||||||||||||||||||
| 1349 | are passed preceded by a hyphen, e.g '-type'. Both types may be freely | ||||||||||||||||||||||||||||
| 1350 | intermixed; see the L<"fe"> method and code examples throughout the documentation | ||||||||||||||||||||||||||||
| 1351 | for more examples. | ||||||||||||||||||||||||||||
| 1352 | |||||||||||||||||||||||||||||
| 1353 | =head2 new (constructor) | ||||||||||||||||||||||||||||
| 1354 | |||||||||||||||||||||||||||||
| 1355 | $svg = SVG->new(%attributes) | ||||||||||||||||||||||||||||
| 1356 | |||||||||||||||||||||||||||||
| 1357 | Creates a new SVG object. Attributes of the document SVG element be passed as | ||||||||||||||||||||||||||||
| 1358 | an optional list of key value pairs. Additionally, SVG options (prefixed with | ||||||||||||||||||||||||||||
| 1359 | a hyphen) may be set on a per object basis: | ||||||||||||||||||||||||||||
| 1360 | |||||||||||||||||||||||||||||
| 1361 | my $svg1 = SVG->new; | ||||||||||||||||||||||||||||
| 1362 | |||||||||||||||||||||||||||||
| 1363 | my $svg2 = SVG->new(id => 'document_element'); | ||||||||||||||||||||||||||||
| 1364 | |||||||||||||||||||||||||||||
| 1365 | my $svg3 = SVG->new( | ||||||||||||||||||||||||||||
| 1366 | -printerror => 1, | ||||||||||||||||||||||||||||
| 1367 | -raiseerror => 0, | ||||||||||||||||||||||||||||
| 1368 | -indent => ' ', | ||||||||||||||||||||||||||||
| 1369 | -elsep => "\n", # element line (vertical) separator | ||||||||||||||||||||||||||||
| 1370 | -docroot => 'svg', # default document root element (SVG specification assumes svg). Defaults to 'svg' if undefined | ||||||||||||||||||||||||||||
| 1371 | -xml_xlink => 'http://www.w3.org/1999/xlink', # required by Mozilla's embedded SVG engine | ||||||||||||||||||||||||||||
| 1372 | -sysid => 'abc', # optional system identifier | ||||||||||||||||||||||||||||
| 1373 | -pubid => "-//W3C//DTD SVG 1.0//EN", # public identifier default value is "-//W3C//DTD SVG 1.0//EN" if undefined | ||||||||||||||||||||||||||||
| 1374 | -namespace => 'mysvg', | ||||||||||||||||||||||||||||
| 1375 | -inline => 1 | ||||||||||||||||||||||||||||
| 1376 | id => 'document_element', | ||||||||||||||||||||||||||||
| 1377 | width => 300, | ||||||||||||||||||||||||||||
| 1378 | height => 200, | ||||||||||||||||||||||||||||
| 1379 | ); | ||||||||||||||||||||||||||||
| 1380 | |||||||||||||||||||||||||||||
| 1381 | Default SVG options may also be set in the import list. See L<"EXPORTS"> above | ||||||||||||||||||||||||||||
| 1382 | for more on the available options. | ||||||||||||||||||||||||||||
| 1383 | |||||||||||||||||||||||||||||
| 1384 | Furthermore, the following options: | ||||||||||||||||||||||||||||
| 1385 | |||||||||||||||||||||||||||||
| 1386 | -version | ||||||||||||||||||||||||||||
| 1387 | -encoding | ||||||||||||||||||||||||||||
| 1388 | -standalone | ||||||||||||||||||||||||||||
| 1389 | -namespace | ||||||||||||||||||||||||||||
| 1390 | -inline | ||||||||||||||||||||||||||||
| 1391 | -pubid (formerly -identifier) | ||||||||||||||||||||||||||||
| 1392 | -sysid (standalone) | ||||||||||||||||||||||||||||
| 1393 | |||||||||||||||||||||||||||||
| 1394 | may also be set in xmlify, overriding any corresponding values set in the SVG->new declaration | ||||||||||||||||||||||||||||
| 1395 | |||||||||||||||||||||||||||||
| 1396 | =cut | ||||||||||||||||||||||||||||
| 1397 | |||||||||||||||||||||||||||||
| 1398 | #------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 1399 | # | ||||||||||||||||||||||||||||
| 1400 | # constructor for the SVG data model. | ||||||||||||||||||||||||||||
| 1401 | # | ||||||||||||||||||||||||||||
| 1402 | # the new constructor creates a new data object with a document tag at its base. | ||||||||||||||||||||||||||||
| 1403 | # this document tag then has either: | ||||||||||||||||||||||||||||
| 1404 | # a child entry parent with its child svg generated (when -inline = 1) | ||||||||||||||||||||||||||||
| 1405 | # or | ||||||||||||||||||||||||||||
| 1406 | # a child entry svg created. | ||||||||||||||||||||||||||||
| 1407 | # | ||||||||||||||||||||||||||||
| 1408 | # Because the new method returns the $self reference and not the | ||||||||||||||||||||||||||||
| 1409 | # latest child to be created, a hash key -document with the reference to the hash | ||||||||||||||||||||||||||||
| 1410 | # entry of its already-created child. hence the document object has a -document reference | ||||||||||||||||||||||||||||
| 1411 | # to parent or svg if inline is 1 or 0, and parent will have a -document entry | ||||||||||||||||||||||||||||
| 1412 | # pointing to the svg child. | ||||||||||||||||||||||||||||
| 1413 | # | ||||||||||||||||||||||||||||
| 1414 | # This way, the next tag constructor will descend the | ||||||||||||||||||||||||||||
| 1415 | # tree until it finds no more tags with -document, and will add | ||||||||||||||||||||||||||||
| 1416 | # the next tag object there. | ||||||||||||||||||||||||||||
| 1417 | # refer to the SVG::tag method | ||||||||||||||||||||||||||||
| 1418 | |||||||||||||||||||||||||||||
| 1419 | 42 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=13 SCAR=27.9
Pod
documented
| |||||||||||||||||||||||||||||
| 1420 | 42 | my ( $proto, %attrs ) = @_; | |||||||||||||||||||||||||||
| 1421 | |||||||||||||||||||||||||||||
| 1422 | 42 | ▶ | my $class = ref $proto || $proto; | ||||||||||||||||||||||||||
|
Condition66%2/3
ref $proto || $proto
MC/DC0%0/2
ref $proto || $proto
ref $proto
$proto
Truth table66%2/3
A || B
A= ref $protoB= $proto
| |||||||||||||||||||||||||||||
| 1423 | 42 | my $self; | |||||||||||||||||||||||||||
| 1424 | |||||||||||||||||||||||||||||
| 1425 | # establish defaults for unspecified attributes | ||||||||||||||||||||||||||||
| 1426 | 42 | foreach my $attr ( keys %default_attrs ) { | |||||||||||||||||||||||||||
| 1427 | 678 | ▶ | $attrs{$attr} = $default_attrs{$attr} unless exists $attrs{$attr}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1428 | } | ||||||||||||||||||||||||||||
| 1429 | 42 | $self = $class->SUPER::new('document'); | |||||||||||||||||||||||||||
| 1430 | 42 | ▶ | if ( not $self->{-docref} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1431 | 42 | $self->{-docref} = $self; | |||||||||||||||||||||||||||
| 1432 | 42 | weaken( $self->{-docref} ); | |||||||||||||||||||||||||||
| 1433 | } | ||||||||||||||||||||||||||||
| 1434 | 42 | ▶ | unless ( $attrs{-namespace} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1435 | 42 | ▶ | $attrs{'xmlns'} = $attrs{'xmlns'} || $attrs{'-xml_svg'}; | ||||||||||||||||||||||||||
|
Condition33%1/3
$attrs{'xmlns'} || $attrs{'-xml_svg'}
MC/DC0%0/2
$attrs{'xmlns'} || $attrs{'-xml_svg'}
$attrs{'xmlns'}
$attrs{'-xml_svg'}
Truth table33%1/3
A || B
A= $attrs{'xmlns'}B= $attrs{'-xml_svg'}
| |||||||||||||||||||||||||||||
| 1436 | } | ||||||||||||||||||||||||||||
| 1437 | $attrs{'xmlns:xlink'} | ||||||||||||||||||||||||||||
| 1438 | = $attrs{'xmlns:xlink'} | ||||||||||||||||||||||||||||
| 1439 | 42 | ▶ | || $attrs{'-xml_xlink'} | ||||||||||||||||||||||||||
|
Condition40%2/5
$attrs{'xmlns:xlink'} || $attrs{'-xml_xlink'} || 'http://www.w3.org/1999/xlink'
$attrs{"xmlns:xlink"} or $attrs{"-xml_xlink"}
MC/DC0%0/2
$attrs{'xmlns:xlink'} || $attrs{'-xml_xlink'} || 'http://www.w3.org/1999/xlink'
$attrs{"xmlns:xlink"}
$attrs{"-xml_xlink"}
Truth table33%1/3
A or B
A= $attrs{"xmlns:xlink"}B= $attrs{"-xml_xlink"}
| |||||||||||||||||||||||||||||
| 1440 | || 'http://www.w3.org/1999/xlink'; | ||||||||||||||||||||||||||||
| 1441 | $attrs{'xmlns:svg'} | ||||||||||||||||||||||||||||
| 1442 | = $attrs{'xmlns:svg'} | ||||||||||||||||||||||||||||
| 1443 | 42 | ▶ | || $attrs{'-xml_svg'} | ||||||||||||||||||||||||||
|
Condition40%2/5
$attrs{'xmlns:svg'} || $attrs{'-xml_svg'} || 'http://www.w3.org/2000/svg'
$attrs{"xmlns:svg"} or $attrs{"-xml_svg"}
MC/DC0%0/2
$attrs{'xmlns:svg'} || $attrs{'-xml_svg'} || 'http://www.w3.org/2000/svg'
$attrs{"xmlns:svg"}
$attrs{"-xml_svg"}
Truth table33%1/3
A or B
A= $attrs{"xmlns:svg"}B= $attrs{"-xml_svg"}
| |||||||||||||||||||||||||||||
| 1444 | || 'http://www.w3.org/2000/svg'; | ||||||||||||||||||||||||||||
| 1445 | |||||||||||||||||||||||||||||
| 1446 | 42 | $self->{-level} = 0; | |||||||||||||||||||||||||||
| 1447 | 42 | $self->{$_} = $attrs{$_} foreach keys %default_attrs; | |||||||||||||||||||||||||||
| 1448 | |||||||||||||||||||||||||||||
| 1449 | # create SVG object according to nostub attribute | ||||||||||||||||||||||||||||
| 1450 | 42 | my $svg; | |||||||||||||||||||||||||||
| 1451 | 42 | ▶ | unless ( $attrs{-nostub} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1452 | 42 | $svg = $self->svg(%attrs); | |||||||||||||||||||||||||||
| 1453 | 42 | $self->{-document} = $svg; | |||||||||||||||||||||||||||
| 1454 | 42 | weaken( $self->{-document} ); | |||||||||||||||||||||||||||
| 1455 | } | ||||||||||||||||||||||||||||
| 1456 | |||||||||||||||||||||||||||||
| 1457 | # add -attributes to SVG object | ||||||||||||||||||||||||||||
| 1458 | # $self->{-elrefs}->{$self}->{name} = 'document'; | ||||||||||||||||||||||||||||
| 1459 | # $self->{-elrefs}->{$self}->{id} = ''; | ||||||||||||||||||||||||||||
| 1460 | |||||||||||||||||||||||||||||
| 1461 | 42 | return $self; | |||||||||||||||||||||||||||
| 1462 | } | ||||||||||||||||||||||||||||
| 1463 | |||||||||||||||||||||||||||||
| 1464 | #------------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 1465 | |||||||||||||||||||||||||||||
| 1466 | =pod | ||||||||||||||||||||||||||||
| 1467 | |||||||||||||||||||||||||||||
| 1468 | =head2 xmlify (alias: to_xml render serialize serialise ) | ||||||||||||||||||||||||||||
| 1469 | |||||||||||||||||||||||||||||
| 1470 | $string = $svg->xmlify(%attributes); | ||||||||||||||||||||||||||||
| 1471 | |||||||||||||||||||||||||||||
| 1472 | Returns xml representation of svg document. | ||||||||||||||||||||||||||||
| 1473 | |||||||||||||||||||||||||||||
| 1474 | B<XML Declaration> | ||||||||||||||||||||||||||||
| 1475 | |||||||||||||||||||||||||||||
| 1476 | Name Default Value | ||||||||||||||||||||||||||||
| 1477 | -version '1.0' | ||||||||||||||||||||||||||||
| 1478 | -encoding 'UTF-8' | ||||||||||||||||||||||||||||
| 1479 | -standalone 'yes' | ||||||||||||||||||||||||||||
| 1480 | -namespace 'svg' - namespace prefix for elements. | ||||||||||||||||||||||||||||
| 1481 | Can also be used in any element method to over-ride | ||||||||||||||||||||||||||||
| 1482 | the current namespace prefix. Make sure to have | ||||||||||||||||||||||||||||
| 1483 | declared the prefix before using it. | ||||||||||||||||||||||||||||
| 1484 | -inline '0' - If '1', then this is an inline document. | ||||||||||||||||||||||||||||
| 1485 | -pubid '-//W3C//DTD SVG 1.0//EN'; | ||||||||||||||||||||||||||||
| 1486 | -sysid 'http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd' | ||||||||||||||||||||||||||||
| 1487 | |||||||||||||||||||||||||||||
| 1488 | =cut | ||||||||||||||||||||||||||||
| 1489 | |||||||||||||||||||||||||||||
| 1490 | 29 | ▶ | sub xmlify { | ||||||||||||||||||||||||||
|
Subroutine
xmlify: called CC=8 SCAR=20.8
Pod
documented
| |||||||||||||||||||||||||||||
| 1491 | 29 | my ( $self, %attrs ) = @_; | |||||||||||||||||||||||||||
| 1492 | |||||||||||||||||||||||||||||
| 1493 | 29 | my ( $decl, $ns ); | |||||||||||||||||||||||||||
| 1494 | |||||||||||||||||||||||||||||
| 1495 | 29 | my $credits = ''; | |||||||||||||||||||||||||||
| 1496 | |||||||||||||||||||||||||||||
| 1497 | # Give the module and myself credit unless explicitly turned off | ||||||||||||||||||||||||||||
| 1498 | 29 | ▶ | unless ( $self->{-docref}->{-nocredits} | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$self->{"-docref"}{"-nocredits"} or $self->{"-docref"}{"-creditsinserted"}
MC/DC100%2/2
$self->{"-docref"}{"-nocredits"} or $self->{"-docref"}{"-creditsinserted"}
$self->{"-docref"}{"-nocredits"}
$self->{"-docref"}{"-creditsinserted"}
Truth table100%3/3
A or B
A= $self->{"-docref"}{"-nocredits"}B= $self->{"-docref"}{"-creditsinserted"}
| |||||||||||||||||||||||||||||
| 1499 | or $self->{-docref}{-creditsinserted} ) | ||||||||||||||||||||||||||||
| 1500 | { | ||||||||||||||||||||||||||||
| 1501 | 21 | $self->comment( | |||||||||||||||||||||||||||
| 1502 | "\n\tGenerated using the Perl SVG Module V$VERSION\n\tby Ronan Oger\n\n\t" | ||||||||||||||||||||||||||||
| 1503 | ); | ||||||||||||||||||||||||||||
| 1504 | 21 | $self->{-docref}{-creditsinserted} = 1; | |||||||||||||||||||||||||||
| 1505 | } | ||||||||||||||||||||||||||||
| 1506 | |||||||||||||||||||||||||||||
| 1507 | 29 | foreach my $key ( keys %attrs ) { | |||||||||||||||||||||||||||
| 1508 | 2 | ▶ | next if $key !~ /^-/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1509 | 2 | $self->{$key} = $attrs{$key}; | |||||||||||||||||||||||||||
| 1510 | } | ||||||||||||||||||||||||||||
| 1511 | |||||||||||||||||||||||||||||
| 1512 | 29 | foreach my $key ( keys %$self ) { | |||||||||||||||||||||||||||
| 1513 | 693 | ▶ | next if $key !~ /^-/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 1514 | 693 | ▶ | $attrs{$key} ||= $self->{$key}; | ||||||||||||||||||||||||||
|
Condition100%3/3
$attrs{$key} ||= $self->{$key}
MC/DC100%2/2
$attrs{$key} ||= $self->{$key}
$attrs{$key}
$self->{$key}
Truth table100%3/3
A ||= B
A= $attrs{$key}B= $self->{$key}
| |||||||||||||||||||||||||||||
| 1515 | } | ||||||||||||||||||||||||||||
| 1516 | |||||||||||||||||||||||||||||
| 1517 | 29 | return $self->SUPER::xmlify( $self->{-namespace} ); | |||||||||||||||||||||||||||
| 1518 | } | ||||||||||||||||||||||||||||
| 1519 | |||||||||||||||||||||||||||||
| 1520 | 30 | *render = \&xmlify; | |||||||||||||||||||||||||||
| 1521 | 30 | *to_xml = \&xmlify; | |||||||||||||||||||||||||||
| 1522 | 30 | *serialise = \&xmlify; | |||||||||||||||||||||||||||
| 1523 | 30 | *serialize = \&xmlify; | |||||||||||||||||||||||||||
| 1524 | |||||||||||||||||||||||||||||
| 1525 | =head2 perlify () | ||||||||||||||||||||||||||||
| 1526 | |||||||||||||||||||||||||||||
| 1527 | return the perl code which generates the SVG document as it currently exists. | ||||||||||||||||||||||||||||
| 1528 | |||||||||||||||||||||||||||||
| 1529 | =cut | ||||||||||||||||||||||||||||
| 1530 | |||||||||||||||||||||||||||||
| 1531 | 0 | ▶ | sub perlify { | ||||||||||||||||||||||||||
|
Subroutine
perlify: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 1532 | 0 | return shift->SUPER::perlify(); | |||||||||||||||||||||||||||
| 1533 | } | ||||||||||||||||||||||||||||
| 1534 | |||||||||||||||||||||||||||||
| 1535 | =head2 toperl () | ||||||||||||||||||||||||||||
| 1536 | |||||||||||||||||||||||||||||
| 1537 | Alias for method perlify() | ||||||||||||||||||||||||||||
| 1538 | |||||||||||||||||||||||||||||
| 1539 | =cut | ||||||||||||||||||||||||||||
| 1540 | |||||||||||||||||||||||||||||
| 1541 | 30 | *toperl = \&perlify; | |||||||||||||||||||||||||||
| 1542 | |||||||||||||||||||||||||||||
| 1543 | 30 | 1; | |||||||||||||||||||||||||||
| 1544 | |||||||||||||||||||||||||||||
| 1545 | =pod | ||||||||||||||||||||||||||||
| 1546 | |||||||||||||||||||||||||||||
| 1547 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 1548 | |||||||||||||||||||||||||||||
| 1549 | Ronan Oger, RO IT Systemms GmbH, cpan@roitsystems.com | ||||||||||||||||||||||||||||
| 1550 | |||||||||||||||||||||||||||||
| 1551 | =head1 MAINTAINER | ||||||||||||||||||||||||||||
| 1552 | |||||||||||||||||||||||||||||
| 1553 | L<Mohammad Sajid Anwar|https://manwar.org/> | ||||||||||||||||||||||||||||
| 1554 | |||||||||||||||||||||||||||||
| 1555 | =head1 CREDITS | ||||||||||||||||||||||||||||
| 1556 | |||||||||||||||||||||||||||||
| 1557 | I would like to thank the following people for contributing to this module with | ||||||||||||||||||||||||||||
| 1558 | patches, testing, suggestions, and other nice tidbits: | ||||||||||||||||||||||||||||
| 1559 | |||||||||||||||||||||||||||||
| 1560 | Peter Wainwright, Excellent ideas, beta-testing, writing SVG::Parser and much of SVG::DOM. | ||||||||||||||||||||||||||||
| 1561 | Fredo, http://www.penguin.at0.net/~fredo/ - provided example code and initial feedback for early SVG.pm versions and the idea of a simplified svg generator. | ||||||||||||||||||||||||||||
| 1562 | Adam Schneider | ||||||||||||||||||||||||||||
| 1563 | Brial Pilpré | ||||||||||||||||||||||||||||
| 1564 | Ian Hickson | ||||||||||||||||||||||||||||
| 1565 | Steve Lihn | ||||||||||||||||||||||||||||
| 1566 | Allen Day | ||||||||||||||||||||||||||||
| 1567 | Martin Owens - SVG::DOM improvements in version 3.34 | ||||||||||||||||||||||||||||
| 1568 | |||||||||||||||||||||||||||||
| 1569 | =head1 COPYRIGHT & LICENSE | ||||||||||||||||||||||||||||
| 1570 | |||||||||||||||||||||||||||||
| 1571 | Copyright 2001- Ronan Oger | ||||||||||||||||||||||||||||
| 1572 | |||||||||||||||||||||||||||||
| 1573 | The modules in the SVG distribution are distributed under the same license | ||||||||||||||||||||||||||||
| 1574 | as Perl itself. It is provided free of warranty and may be re-used freely. | ||||||||||||||||||||||||||||
| 1575 | |||||||||||||||||||||||||||||
| 1576 | =head1 ARTICLES | ||||||||||||||||||||||||||||
| 1577 | |||||||||||||||||||||||||||||
| 1578 | L<SVG using Perl|http://szabgab.com/svg-using-perl.html> | ||||||||||||||||||||||||||||
| 1579 | |||||||||||||||||||||||||||||
| 1580 | L<SVG - Scalable Vector Graphics with Perl|http://perlmaven.com/scalable-vector-graphics-with-perl> | ||||||||||||||||||||||||||||
| 1581 | |||||||||||||||||||||||||||||
| 1582 | L<Combining SVG and PSGI|http://perlmaven.com/combining-svg-and-psgi> | ||||||||||||||||||||||||||||
| 1583 | |||||||||||||||||||||||||||||
| 1584 | =head1 SEE ALSO | ||||||||||||||||||||||||||||
| 1585 | |||||||||||||||||||||||||||||
| 1586 | L<SVG::DOM>, | ||||||||||||||||||||||||||||
| 1587 | L<SVG::XML>, | ||||||||||||||||||||||||||||
| 1588 | L<SVG::Element>, | ||||||||||||||||||||||||||||
| 1589 | L<SVG::Parser>, | ||||||||||||||||||||||||||||
| 1590 | L<SVG::Extension> | ||||||||||||||||||||||||||||
| 1591 | |||||||||||||||||||||||||||||
| 1592 | For Commercial Perl/SVG development, refer to the following sites: | ||||||||||||||||||||||||||||
| 1593 | L<SVG at the W3C|http://www.w3c.org/Graphics/SVG/>. | ||||||||||||||||||||||||||||
| 1594 | |||||||||||||||||||||||||||||
| 1595 | =cut | ||||||||||||||||||||||||||||