1SVG::Manual(3)        User Contributed Perl Documentation       SVG::Manual(3)
2
3
4

NAME

6       SVG - Perl extension for generating Scalable Vector Graphics (SVG)
7       documents
8
9   VERSION
10       Covers SVG-2.47 distribution, December 2008
11

SYNOPSIS

13           #!/usr/bin/perl -w
14           use strict;
15           use SVG;
16
17           # create an SVG object
18           my $svg= SVG->new(width=>200,height=>200);
19           #or
20           my $svg= SVG->new(width=>200,height=>200);
21
22           # use explicit element constructor to generate a group element
23           my $y=$svg->group(
24               id    => 'group_y',
25               style => { stroke=>'red', fill=>'green' }
26           );
27
28           # add a circle to the group
29           $y->circle(cx=>100, cy=>100, r=>50, id=>'circle_in_group_y');
30
31           # or, use the generic 'tag' method to generate a group element by name
32           my $z=$svg->tag('g',
33                           id    => 'group_z',
34                           style => {
35                               stroke => 'rgb(100,200,50)',
36                               fill   => 'rgb(10,100,150)'
37                           }
38                       );
39
40           # create and add a circle using the generic 'tag' method
41           $z->tag('circle', cx=>50, cy=>50, r=>100, id=>'circle_in_group_z');
42
43           # create an anchor on a rectangle within a group within the group z
44           my $k = $z->anchor(
45               id      => 'anchor_k',
46               -href   => 'http://test.hackmare.com/',
47               target => 'new_window_0'
48           )->rectangle(
49               x     => 20, y      => 50,
50               width => 20, height => 30,
51               rx    => 10, ry     => 5,
52               id    => 'rect_k_in_anchor_k_in_group_z'
53           );
54
55           # now render the SVG object, implicitly use svg namespace
56           print $svg->xmlify;
57
58           # or render a child node of the SVG object without rendering the entire object
59           print $k->xmlify; #renders the anchor $k above containing a rectangle, but does not
60                             #render any of the ancestor nodes of $k
61
62
63           # or, explicitly use svg namespace and generate a document with its own DTD
64           print $svg->xmlify(-namespace=>'svg');
65
66           # or, explicitly use svg namespace and generate an in-line docunent
67           print $svg->xmlify(
68               -namespace => "svg",
69               -pubid => "-//W3C//DTD SVG 1.0//EN",
70               -inline   => 1
71           );
72

DESCRIPTION

74       SVG is a 100% Perl module which generates a nested data structure
75       containing the DOM representation of an SVG (Scalable Vector Graphics)
76       image. Using SVG, you can generate SVG objects, embed other SVG
77       instances into it, access the DOM object, create and access javascript,
78       and generate SMIL animation content.
79
80   General Steps to generating an SVG document
81       Generating SVG is a simple three step process:
82
83   1 The first step is to construct a new SVG object with "new".
84   2 The second step is to call element constructors to create SVG elements.
85       Examples of element constructors are "circle" and "path".
86   3 The third and last step is to render the SVG object into XML using the
87       "xmlify" method.
88       The "xmlify" method takes a number of optional arguments that control
89       how SVG renders the object into XML, and in particular determine
90       whether a stand-alone SVG document or an inline SVG document fragment
91       is generated:
92
93   -stand-alone
94       A complete SVG document with its own associated DTD. A namespace for
95       the SVG elements may be optionally specified.
96
97   -in-line
98       An in-line SVG document fragment with no DTD that be embedded within
99       other XML content. As with stand-alone documents, an alternate
100       namespace may be specified.
101
102       No XML content is generated until the third step is reached. Up until
103       this point, all constructed element definitions reside in a DOM-like
104       data structure from which they can be accessed and modified.
105
106   EXPORTS
107       None. However, SVG permits both options and additional element methods
108       to be specified in the import list. These options and elements are then
109       available for all SVG instances that are created with the "new"
110       constructor. For example, to change the indent string to two spaces per
111       level:
112
113           use SVG (-indent => "  ");
114
115       With the exception of -auto, all options may also be specified to the
116       "new" constructor. The currently supported options and their default
117       value are:
118
119           # processing options
120           -auto       => 0,       # permit arbitrary autoloading of all unrecognised elements
121           -printerror => 1,       # print error messages to STDERR
122           -raiseerror => 1,       # die on errors (implies -printerror)
123
124           # rendering options
125           -indent     => "\t",    # what to indent with
126           -elsep      => "\n",    # element line (vertical) separator
127                                   #     (note that not all agents ignor trailing blanks)
128           -nocredits  => 0,       # enable/disable credit note comment
129           -namespace  => '',      # The root element's (and it's children's) namespace prefix
130
131           # XML and Doctype declarations
132           -inline     => 0,       # inline or stand alone
133           -docroot    => 'svg',   # The document's root element
134           -version    => '1.0',
135           -extension  => '',
136           -encoding   => 'UTF-8',
137           -xml_svg    => 'http://www.w3.org/2000/svg',   # the svg xmlns attribute
138           -xml_xlink  => 'http://www.w3.org/1999/xlink', # the svg tag xmlns:xlink attribute
139           -standalone => 'yes',
140           -pubid      => "-//W3C//DTD SVG 1.0//EN",      # formerly -identifier
141           -sysid      => 'http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd', # the system id
142
143       SVG also allows additional element generation methods to be specified
144       in the import list. For example to generate 'star' and 'planet' element
145       methods:
146
147           use SVG qw(star planet);
148
149       or:
150
151           use SVG ("star","planet");
152
153       This will add 'star' to the list of elements supported by SVG.pm (but
154       not of course other SVG parsers...). Alternatively the '-auto' option
155       will allow any unknown method call to generate an element of the same
156       name:
157
158           use SVG (-auto => 1, "star", "planet");
159
160       Any elements specified explicitly (as 'star' and 'planet' are here) are
161       predeclared; other elements are defined as and when they are seen by
162       Perl. Note that enabling '-auto' effectively disables compile-time
163       syntax checking for valid method names.
164
165       Example:
166
167           use SVG (
168               -auto       => 0,
169               -indent     => "  ",
170               -raiserror  => 0,
171               -printerror => 1,
172               "star", "planet", "moon"
173           );
174
175   Default SVG tag
176       The Default SVG tag will generate the following XML:
177
178        $svg = new SVG;
179        $svg->xmlify;
180
181
182        resulting XML snippet:
183
184        <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
185        <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
186        <svg height="100%" width="100%" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
187               <defs  /><!--
188               Generated using the Perl SVG Module V2.44
189               by Ronan Oger
190               Info: http://www.roitsystems.com/
191         -->
192        </svg>
193

SEE ALSO

195       perl(1), SVG::XML, SVG::Element, SVG::DOM, SVG::Parser
196       <http://www.roitsystems.com/>ROIT Systems: Commercial SVG perl
197       solutions <http://www.w3c.org/Graphics/SVG/>SVG at the W3C
198

AUTHOR

200       Ronan Oger, RO IT Systems GmbH, cpan@roitsystems.com
201

CREDITS

203       Peter Wainwright, Excellent ideas, beta-testing, writing SVG::Parser
204       and much of SVG::DOM.  Fredo, http://www.penguin.at0.net/~fredo/ -
205       provided example code and initial feedback for early SVG.pm versions
206       and the idea of a simplified svg generator.  Adam Schneider, Brial
207       Pilpre, Ian Hickson Martin Owens - SVG::DOM improvements in version
208       3.34
209

EXAMPLES

211       http://wiki.roitsystems.com/
212
213       See also the examples directory in this distribution which contain
214       several fully documented examples.
215

METHODS

217       SVG provides both explicit and generic element constructor methods.
218       Explicit generators are generally (with a few exceptions) named for the
219       element they generate. If a tag method is required for a tag containing
220       hyphens, the method name replaces the hyphen with an underscore. ie: to
221       generate tag <column-heading id="new"> you would use method
222       $svg->column_heading(id=>'new').
223
224       All element constructors take a hash of element attributes and options;
225       element attributes such as 'id' or 'border' are passed by name, while
226       options for the method (such as the type of an element that supports
227       multiple alternate forms) are passed preceded by a hyphen, e.g '-type'.
228       Both types may be freely intermixed; see the "fe" method and code
229       examples througout the documentation for more examples.
230
231   new (constructor)
232       $svg = SVG->new(%attributes)
233
234       Creates a new SVG object. Attributes of the document SVG element be
235       passed as an optional list of key value pairs. Additionally, SVG
236       options (prefixed with a hyphen) may be set on a per object basis:
237
238       Example:
239
240           my $svg1=new SVG;
241
242           my $svg2=new SVG(id => 'document_element');
243
244           my $svg3=new SVG(s
245               -printerror => 1,
246               -raiseerror => 0,
247               -indent     => '  ',
248               -docroot => 'svg', #default document root element (SVG specification assumes svg). Defaults to 'svg' if undefined
249               -sysid      => 'abc', #optional system identifyer
250               -pubid      => "-//W3C//DTD SVG 1.0//EN", #public identifyer default value is "-//W3C//DTD SVG 1.0//EN" if undefined
251               -namespace => 'mysvg',
252               -inline   => 1
253               id          => 'document_element',
254               width       => 300,
255               height      => 200,
256           );
257
258       Default SVG options may also be set in the import list. See "EXPORTS"
259       above for more on the available options.
260
261       Furthermore, the following options:
262
263           -version
264           -encoding
265           -standalone
266           -namespace Defines the document or element level namespace. The order of assignment priority is element,document .
267           -inline
268           -identifier
269           -nostub
270           -dtd (standalone)
271
272       may also be set in xmlify, overriding any corresponding values set in
273       the SVG->new declaration
274
275   xmlify (alias: to_xml render serialise serialize)
276       $string = $svg->xmlify(%attributes);
277
278       Returns xml representation of svg document.
279
280       XML Declaration
281
282           Name               Default Value
283           -version           '1.0'
284           -encoding          'UTF-8'
285           -standalone        'yes'
286           -namespace         'svg'                - namespace for elements
287           -inline            '0' - If '1', then this is an inline document.
288           -pubid             '-//W3C//DTD SVG 1.0//EN';
289           -dtd (standalone)  'http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd'
290
291   tag (alias: element)
292       $tag = $svg->tag($name, %attributes)
293
294       Generic element generator. Creates the element named $name with the
295       attributes specified in %attributes. This method is the basis of most
296       of the explicit element generators.
297
298       Example:
299
300           my $tag = $svg->tag('g', transform=>'rotate(-45)');
301
302   anchor
303       $tag = $svg->anchor(%attributes)
304
305       Generate an anchor element. Anchors are put around objects to make them
306       'live' (i.e. clickable). It therefore requires a drawn object or group
307       element as a child.
308
309       Example:
310
311           # generate an anchor
312           $tag = $svg->anchor(
313               -href=>'http://here.com/some/simpler/svg.svg'
314           );
315           # add a circle to the anchor. The circle can be clicked on.
316           $tag->circle(cx=>10,cy=>10,r=>1);
317
318           # more complex anchor with both URL and target
319           $tag = $svg->anchor(
320                     -href   => 'http://somewhere.org/some/other/page.html',
321                     target => 'new_window'
322           );
323
324   circle
325       $tag = $svg->circle(%attributes)
326
327       Draw a circle at (cx,cy) with radius r.
328
329       Example:
330
331           my $tag = $svg->circle(cx=>4, cy=>2, r=>1);
332
333   ellipse
334       $tag = $svg->ellipse(%attributes)
335
336       Draw an ellipse at (cx,cy) with radii rx,ry.
337
338       Example:
339
340           my $tag = $svg->ellipse(
341               cx=>10, cy=>10,
342               rx=>5, ry=>7,
343               id=>'ellipse',
344               style=>{
345                   'stroke'=>'red',
346                   'fill'=>'green',
347                   'stroke-width'=>'4',
348                   'stroke-opacity'=>'0.5',
349                   'fill-opacity'=>'0.2'
350               }
351           );
352
353   rectangle (alias: rect)
354       $tag = $svg->rectangle(%attributes)
355
356       Draw a rectangle at (x,y) with width 'width' and height 'height' and
357       side radii 'rx' and 'ry'.
358
359       Example:
360
361           $tag = $svg->rectangle(
362               x=>10, y=>20,
363               width=>4, height=>5,
364               rx=>5.2, ry=>2.4,
365               id=>'rect_1'
366           );
367
368   image
369        $tag = $svg->image(%attributes)
370
371       Draw an image at (x,y) with width 'width' and height 'height' linked to
372       image resource '-href'. See also "use".
373
374       Example:
375
376           $tag = $svg->image(
377               x=>100, y=>100,
378               width=>300, height=>200,
379               '-href'=>"image.png", #may also embed SVG, e.g. "image.svg"
380               id=>'image_1'
381           );
382
383       Output:
384
385           <image xlink:href="image.png" x="100" y="100" width="300" height="200"/>
386
387   use
388       $tag = $svg->use(%attributes)
389
390       Retrieve the content from an entity within an SVG document and apply it
391       at (x,y) with width 'width' and height 'height' linked to image
392       resource '-href'.
393
394       Example:
395
396           $tag = $svg->use(
397               x=>100, y=>100,
398               width=>300, height=>200,
399               '-href'=>"pic.svg#image_1",
400               id=>'image_1'
401           );
402
403       Output:
404
405           <use xlink:href="pic.svg#image_1" x="100" y="100" width="300" height="200"/>
406
407       According to the SVG specification, the 'use' element in SVG can point
408       to a single element within an external SVG file.
409
410   polygon
411       $tag = $svg->polygon(%attributes)
412
413       Draw an n-sided polygon with vertices at points defined by a string of
414       the form 'x1,y1,x2,y2,x3,y3,... xy,yn'. The "get_path" method is
415       provided as a convenience to generate a suitable string from coordinate
416       data.
417
418       Example:
419
420           # a five-sided polygon
421           my $xv = [0,2,4,5,1];
422           my $yv = [0,0,2,7,5];
423
424           $points = $a->get_path(
425               x=>$xv, y=>$yv,
426               -type=>'polygon'
427           );
428
429           $c = $a->polygon(
430               %$points,
431               id=>'pgon1',
432               style=>\%polygon_style
433           );
434
435       SEE ALSO:
436
437       "polyline", "path", "get_path".
438
439   polyline
440       $tag = $svg->polyline(%attributes)
441
442       Draw an n-point polyline with points defined by a string of the form
443       'x1,y1,x2,y2,x3,y3,... xy,yn'. The "get_path" method is provided as a
444       convenience to generate a suitable string from coordinate data.
445
446       Example:
447
448           # a 10-pointsaw-tooth pattern
449           my $xv = [0,1,2,3,4,5,6,7,8,9];
450           my $yv = [0,1,0,1,0,1,0,1,0,1];
451
452           $points = $a->get_path(
453               x=>$xv, y=>$yv,
454               -type=>'polyline',
455               -closed=>'true' #specify that the polyline is closed.
456           );
457
458           my $tag = $a->polyline (
459               %$points,
460               id=>'pline_1',
461               style=>{
462                   'fill-opacity'=>0,
463                   'stroke-color'=>'rgb(250,123,23)'
464               }
465           );
466
467   line
468       $tag = $svg->line(%attributes)
469
470       Draw a straight line between two points (x1,y1) and (x2,y2).
471
472       Example:
473
474           my $tag = $svg->line(
475               id=>'l1',
476               x1=>0, y1=>10,
477               x2=>10, y2=>0
478           );
479
480       To draw multiple connected lines, use "polyline".
481
482   text
483       $text = $svg->text(%attributes)->cdata();
484
485       $text_path = $svg->text(-type=>'path'); $text_span =
486       $text_path->text(-type=>'span')->cdata('A'); $text_span =
487       $text_path->text(-type=>'span')->cdata('B'); $text_span =
488       $text_path->text(-type=>'span')->cdata('C');
489
490       define the container for a text string to be drawn in the image.
491
492       Input:
493           -type     = path type (path | polyline | polygon)
494           -type     = text element type  (path | span | normal [default])
495
496       Example:
497
498           my $text1 = $svg->text(
499               id=>'l1', x=>10, y=>10
500           )->cdata('hello, world');
501
502           my $text2 = $svg->text(
503               id=>'l1', x=>10, y=>10, -cdata=>'hello, world');
504
505           my $text = $svg->text(
506               id=>'tp', x=>10, y=>10 -type=>path)
507               ->text(id=>'ts' -type=>'span')
508               ->cdata('hello, world');
509
510       SEE ALSO:
511
512           L<"desc">, L<"cdata">.
513
514   title
515       $tag = $svg->title(%attributes)
516
517       Generate the title of the image.
518
519       Example:
520
521           my $tag = $svg->title(id=>'document-title')->cdata('This is the title');
522
523   desc
524       $tag = $svg->desc(%attributes)
525
526       Generate the description of the image.
527
528       Example:
529
530           my $tag = $svg->desc(id=>'document-desc')->cdata('This is a description');
531
532   comment
533       $tag = $svg->comment(@comments)
534
535       Generate the description of the image.
536
537       Example:
538
539           my $tag = $svg->comment('comment 1','comment 2','comment 3');
540
541   pi (Processing Instruction)
542       $tag = $svg->pi(@pi)
543
544       Generate a set of processing instructions
545
546       Example:
547
548           my $tag = $svg->pi('instruction one','instruction two','instruction three');
549
550           returns:
551             <lt>?instruction one?<gt>
552             <lt>?instruction two?<gt>
553             <lt>?instruction three?<gt>
554
555   script
556       $tag = $svg->script(%attributes)
557
558       Generate a script container for dynamic (client-side) scripting using
559       ECMAscript, Javascript or other compatible scripting language.
560
561       Example:
562
563           my $tag = $svg->script(-type=>"text/ecmascript");
564           #or my $tag = $svg->script();
565           #note that type ecmascript is not Mozilla compliant
566
567           # populate the script tag with cdata
568           # be careful to manage the javascript line ends.
569           # qq|text| or qqXtextX where text is the script
570           # works well for this.
571           #make sure to use the CAPITAL CDATA to poulate the script.
572           $tag->CDATA(qq|function d(){
573               //simple display function
574               for(cnt = 0; cnt < d.length; cnt++)
575                   document.write(d[cnt]);//end for loop
576               document.write("<BR>");//write a line break
577             }|
578           );
579
580   path
581       $tag = $svg->path(%attributes)
582
583       Draw a path element. The path vertices may be imputed as a parameter or
584       calculated usingthe "get_path" method.
585
586       Example:
587
588           # a 10-pointsaw-tooth pattern drawn with a path definition
589           my $xv = [0,1,2,3,4,5,6,7,8,9];
590           my $yv = [0,1,0,1,0,1,0,1,0,1];
591
592           $points = $a->get_path(
593               x => $xv,
594               y => $yv,
595               -type   => 'path',
596               -closed => 'true'  #specify that the polyline is closed
597           );
598
599           $tag = $svg->path(
600               %$points,
601               id    => 'pline_1',
602               style => {
603                   'fill-opacity' => 0,
604                   'fill-color'   => 'green',
605                   'stroke-color' => 'rgb(250,123,23)'
606               }
607           );
608
609       SEE ALSO:
610
611       "get_path".
612
613   get_path
614       $path = $svg->get_path(%attributes)
615
616       Returns the text string of points correctly formatted to be
617       incorporated into the multi-point SVG drawing object definitions (path,
618       polyline, polygon)
619
620       Input: attributes including:
621
622           -type     = path type (path | polyline | polygon)
623           x         = reference to array of x coordinates
624           y         = reference to array of y coordinates
625
626       Output: a hash reference consisting of the following key-value pair:
627
628           points    = the appropriate points-definition string
629           -type     = path|polygon|polyline
630           -relative = 1 (define relative position rather than absolute position)
631           -closed   = 1 (close the curve - path and polygon only)
632
633       Example:
634
635           #generate an open path definition for a path.
636           my ($points,$p);
637           $points = $svg->get_path(x=&gt\@x,y=&gt\@y,-relative=&gt1,-type=&gt'path');
638
639           #add the path to the SVG document
640           my $p = $svg->path(%$path, style=>\%style_definition);
641
642           #generate an closed path definition for a a polyline.
643           $points = $svg->get_path(
644               x=>\@x,
645               y=>\@y,
646               -relative=>1,
647               -type=>'polyline',
648               -closed=>1
649           ); # generate a closed path definition for a polyline
650
651           # add the polyline to the SVG document
652           $p = $svg->polyline(%$points, id=>'pline1');
653
654       Aliases: get_path set_path
655
656   animate
657       $tag = $svg->animate(%attributes)
658
659       Generate an SMIL animation tag. This is allowed within any nonempty
660       tag. Refer\ to the W3C for detailed information on the subtleties of
661       the animate SMIL commands.
662
663       Inputs: -method = Transform | Motion | Color
664
665         my $an_ellipse = $svg->ellipse(
666             cx=>30,cy=>150,rx=>10,ry=>10,id=>'an_ellipse',
667             stroke=>'rgb(130,220,70)',fill=>'rgb(30,20,50)');
668
669         $an_ellipse-> animate(
670             attributeName=>"cx",values=>"20; 200; 20",dur=>"10s", repeatDur=>'indefinite');
671
672         $an_ellipse-> animate(
673             attributeName=>"rx",values=>"10;30;20;100;50",
674             dur=>"10s", repeatDur=>'indefinite');
675
676         $an_ellipse-> animate(
677             attributeName=>"ry",values=>"30;50;10;20;70;150",
678             dur=>"15s", repeatDur=>'indefinite');
679
680         $an_ellipse-> animate(
681             attributeName=>"rx",values=>"30;75;10;100;20;20;150",
682             dur=>"20s", repeatDur=>'indefinite');
683
684         $an_ellipse-> animate(
685             attributeName=>"fill",values=>"red;green;blue;cyan;yellow",
686             dur=>"5s", repeatDur=>'indefinite');
687
688         $an_ellipse-> animate(
689             attributeName=>"fill-opacity",values=>"0;1;0.5;0.75;1",
690             dur=>"20s",repeatDur=>'indefinite');
691
692         $an_ellipse-> animate(
693             attributeName=>"stroke-width",values=>"1;3;2;10;5",
694             dur=>"20s",repeatDur=>'indefinite');
695
696   group
697       $tag = $svg->group(%attributes)
698
699       Define a group of objects with common properties. groups can have
700       style, animation, filters, transformations, and mouse actions assigned
701       to them.
702
703       Example:
704
705           $tag = $svg->group(
706               id        => 'xvs000248',
707               style     => {
708                   'font'      => [ qw( Arial Helvetica sans ) ],
709                   'font-size' => 10,
710                   'fill'      => 'red',
711               },
712               transform => 'rotate(-45)'
713           );
714
715   defs
716       $tag = $svg->defs(%attributes)
717
718       define a definition segment. A Defs requires children when defined
719       using SVG.pm Example:
720
721           $tag = $svg->defs(id  =>  'def_con_one',);
722
723   style
724       $svg->tag('style', %styledef);
725
726       Sets/Adds style-definition for the following objects being created.
727
728       Style definitions apply to an object and all its children for all
729       properties for which the value of the property is not redefined by the
730       child.
731
732   mouseaction
733       $svg->mouseaction(%attributes)
734
735       Sets/Adds mouse action definitions for tag
736
737       $svg->attrib($name, $value)
738
739       Sets/Adds mouse action definitions.
740
741       $svg->attrib $name, $value
742
743       $svg->attrib $name, \@value
744
745       $svg->attrib $name, \%value
746
747       Sets/Replaces attributes for a tag.
748
749   cdata
750       $svg->cdata($text)
751
752       Sets cdata to $text. SVG.pm allows you to set cdata for any tag. If the
753       tag is meant to be an empty tag, SVG.pm will not complain, but the
754       rendering agent will fail. In the SVG DTD, cdata is generally only
755       meant for adding text or script content.
756
757       Example:
758
759           $svg->text(
760               style => {
761                   'font'      => 'Arial',
762                   'font-size' => 20
763               })->cdata('SVG.pm is a perl module on CPAN!');
764
765           my $text = $svg->text(style=>{'font'=>'Arial','font-size'=>20});
766           $text->cdata('SVG.pm is a perl module on CPAN!');
767
768       Result:
769
770           E<lt>text style="font: Arial; font-size: 20" E<gt>SVG.pm is a perl module on CPAN!E<lt>/text E<gt>
771
772       SEE ALSO:
773
774         L<"CDATA"> L<"desc">, L<"title">, L<"text">, L<"script">.
775
776   cdata_noxmlesc
777        $script = $svg->script();
778        $script->cdata_noxmlesc($text);
779
780       Generates cdata content for text and similar tags which do not get xml-
781       escaped.  In othe words, does not parse the content and inserts the
782       exact string into the cdata location.
783
784   CDATA
785        $script = $svg->script();
786        $script->CDATA($text);
787
788       Generates a <![CDATA[ ... ]]> tag with the contents of $text rendered
789       exactly as supplied. SVG.pm allows you to set cdata for any tag. If the
790       tag is meant to be an empty tag, SVG.pm will not complain, but the
791       rendering agent will fail. In the SVG DTD, cdata is generally only
792       meant for adding text or script content.
793
794       Example:
795
796             my $text = qqX
797               var SVGDoc;
798               var groups = new Array();
799               var last_group;
800
801               /*****
802               *
803               *   init
804               *
805               *   Find this SVG's document element
806               *   Define members of each group by id
807               *
808               *****/
809               function init(e) {
810                   SVGDoc = e.getTarget().getOwnerDocument();
811                   append_group(1, 4, 6); // group 0
812                   append_group(5, 4, 3); // group 1
813                   append_group(2, 3);    // group 2
814               }X;
815               $svg->script()->CDATA($text);
816
817       Result:
818
819           E<lt>script E<gt>
820             <gt>![CDATA[
821               var SVGDoc;
822               var groups = new Array();
823               var last_group;
824
825               /*****
826               *
827               *   init
828               *
829               *   Find this SVG's document element
830               *   Define members of each group by id
831               *
832               *****/
833               function init(e) {
834                   SVGDoc = e.getTarget().getOwnerDocument();
835                   append_group(1, 4, 6); // group 0
836                   append_group(5, 4, 3); // group 1
837                   append_group(2, 3);    // group 2
838               }
839               ]]E<gt>
840
841       SEE ALSO:
842
843         L<"cdata">, L<"script">.
844
845   xmlescp and xmlescape
846       $string = SVG::xmlescp($string) $string = SVG::xmlesc($string) $string
847       = SVG::xmlescape($string)
848
849       SVG module does not xml-escape characters that are incompatible with
850       the XML specification. xmlescp and xmlescape provides this
851       functionality. It is a helper function which Generates an XML-escaped
852       string for reserved characters such as ampersand, open and close
853       brackets, etcetera.
854
855       The behaviour of xmlesc is to apply the following transformation to the
856       input string $s:
857
858           $s = '0' unless defined $s;
859           $s=join(', ',@{$s}) if(ref($s) eq 'ARRAY');
860               $s=~s/&(?!#(x\w\w|\d+?);)/&amp;/g;
861           $s=~s/>/&gt;/g;
862           $s=~s/</&lt;/g;
863           $s=~s/\"/&quot;/g;
864           $s=~s/\'/&apos;/g;
865           $s=~s/\`/&apos;/g;
866           $s=~s/([\x00-\x1f])/sprintf('&#x%02X;',chr($1))/eg;
867               #per suggestion from Adam Schneider
868               $s=~s/([\200-\377])/'&#'.ord($1).';'/ge;
869
870   filter
871       $tag = $svg->filter(%attributes)
872
873       Generate a filter. Filter elements contain "fe" filter sub-elements.
874
875       Example:
876
877           my $filter = $svg->filter(
878               filterUnits=>"objectBoundingBox",
879               x=>"-10%",
880               y=>"-10%",
881               width=>"150%",
882               height=>"150%",
883               filterUnits=>'objectBoundingBox'
884           );
885
886           $filter->fe();
887
888       SEE ALSO:
889
890       "fe".
891
892   fe
893       $tag = $svg->fe(-type=>'type', %attributes)
894
895       Generate a filter sub-element. Must be a child of a "filter" element.
896
897       Example:
898
899           my $fe = $svg->fe(
900               -type     => 'DiffuseLighting'  # required - element name omiting 'fe'
901               id        => 'filter_1',
902               style     => {
903                   'font'      => [ qw(Arial Helvetica sans) ],
904                   'font-size' => 10,
905                   'fill'      => 'red',
906               },
907               transform => 'rotate(-45)'
908           );
909
910       Note that the following filter elements are currently supported:
911
912   * feBlend
913   * feColorMatrix
914   * feComponentTransfer
915   * feComposite
916   * feConvolveMatrix
917   * feDiffuseLighting
918   * feDisplacementMap
919   * feDistantLight
920   * feFlood
921   * feFuncA
922   * feFuncB
923   * feFuncG
924   * feFuncR
925   * feGaussianBlur
926   * feImage
927   * feMerge
928   * feMergeNode
929   * feMorphology
930   * feOffset
931   * fePointLight
932   * feSpecularLighting
933   * feSpotLight
934   * feTile
935   * feTurbulence
936       SEE ALSO:
937
938       "filter".
939
940   pattern
941       $tag = $svg->pattern(%attributes)
942
943       Define a pattern for later reference by url.
944
945       Example:
946
947           my $pattern = $svg->pattern(
948               id     => "Argyle_1",
949               width  => "50",
950               height => "50",
951               patternUnits        => "userSpaceOnUse",
952               patternContentUnits => "userSpaceOnUse"
953           );
954
955   set
956       $tag = $svg->set(%attributes)
957
958       Set a definition for an SVG object in one section, to be referenced in
959       other sections as needed.
960
961       Example:
962
963           my $set = $svg->set(
964               id     => "Argyle_1",
965               width  => "50",
966               height => "50",
967               patternUnits        => "userSpaceOnUse",
968               patternContentUnits => "userSpaceOnUse"
969           );
970
971   stop
972       $tag = $svg->stop(%attributes)
973
974       Define a stop boundary for "gradient"
975
976       Example:
977
978          my $pattern = $svg->stop(
979              id     => "Argyle_1",
980              width  => "50",
981              height => "50",
982              patternUnits        => "userSpaceOnUse",
983              patternContentUnits => "userSpaceOnUse"
984          );
985
986       $tag = $svg->gradient(%attributes)
987
988       Define a color gradient. Can be of type linear or radial
989
990       Example:
991
992           my $gradient = $svg->gradient(
993               -type => "linear",
994               id    => "gradient_1"
995           );
996

GENERIC ELEMENT METHODS

998       The following elements are generically supported by SVG:
999
1000   * altGlyph
1001   * altGlyphDef
1002   * altGlyphItem
1003   * clipPath
1004   * color-profile
1005   * cursor
1006   * definition-src
1007   * font-face-format
1008   * font-face-name
1009   * font-face-src
1010   * font-face-url
1011   * foreignObject
1012   * glyph
1013   * glyphRef
1014   * hkern
1015   * marker
1016   * mask
1017   * metadata
1018   * missing-glyph
1019   * mpath
1020   * switch
1021   * symbol
1022   * tref
1023   * view
1024   * vkern
1025       See e.g. "pattern" for an example of the use of these methods.
1026

METHODS IMPORTED BY SVG::DOM

1028       The following SVG::DOM elements are accessible through SVG:
1029
1030   * getChildren
1031   * getFirstChild
1032   * getNextChild
1033   * getLastChild
1034   * getParent
1035   * getParentElement
1036   * getSiblings
1037   * getElementByID
1038   * getElementID
1039   * getElements
1040   * getElementName
1041   * getType
1042   * getAttributes
1043   * getAttribute
1044   * setAttributes
1045   * setAttribute
1046   * insertBefore
1047   * insertAfter
1048   * insertSiblingBefore
1049   * insertSiblingAfter
1050   * replaceChild
1051   * removeChild
1052   * cloneNode

LICENSE

1054       SVG.pl is distributed under the same license as Perl itself. It is
1055       provided free of warranty and may be re-used freely.
1056

SEE ALSO

1058       perl(1), SVG, SVG::DOM, SVG::XML, SVG::Element, SVG::Parser,
1059       SVG::Manual, SVG::Extension Serverside SVG Portal - Perl focused SVG
1060       site with discussion board and examples: <http://www.roitsystems.com/>
1061       <http://www.perlsvg.com/> SVG at the W3C:
1062       <http://www.w3c.org/Graphics/SVG/> For Commercial Perl/SVG development,
1063       refer to the following sites: RO IT Systems:
1064       <http://www.roitsystems.com/>
1065
1066
1067
1068perl v5.12.0                      2009-01-09                    SVG::Manual(3)
Impressum