comparison svgExample.pl @ 39:8b3b5753ad41 laserkard

[svn r40] created succesuful interface to corel Draw :)
author rlm
date Sun, 24 Jan 2010 15:06:22 -0500
parents
children
comparison
equal deleted inserted replaced
38:07c19a58ba5a 39:8b3b5753ad41
1 #!/usr/bin/perl -w
2 use strict;
3 use SVG;
4
5 # create an SVG object
6 my $svg= SVG->new(width=>200,height=>200);
7 #or
8 my $svg= SVG->new(width=>200,height=>200);
9
10 # use explicit element constructor to generate a group element
11 my $y=$svg->group(
12 id => 'group_y',
13 style => { stroke=>'red', fill=>'green' }
14 );
15
16 # add a circle to the group
17 $y->circle(cx=>100, cy=>100, r=>50, id=>'circle_in_group_y');
18
19 # or, use the generic 'tag' method to generate a group element by name
20 my $z=$svg->tag('g',
21 id => 'group_z',
22 style => {
23 stroke => 'rgb(100,200,50)',
24 fill => 'rgb(10,100,150)'
25 }
26 );
27
28 # create and add a circle using the generic 'tag' method
29 $z->tag('circle', cx=>50, cy=>50, r=>100, id=>'circle_in_group_z');
30
31 # create an anchor on a rectangle within a group within the group z
32 my $k = $z->anchor(
33 id => 'anchor_k',
34 -href => 'http://test.hackmare.com/',
35 target => 'new_window_0'
36 )->rectangle(
37 x => 20, y => 50,
38 width => 20, height => 30,
39 rx => 10, ry => 5,
40 id => 'rect_k_in_anchor_k_in_group_z'
41 );
42
43 # now render the SVG object, implicitly use svg namespace
44 print $svg->xmlify;
45
46 # or render a child node of the SVG object without rendering the entire object
47 print $k->xmlify; #renders the anchor $k above containing a rectangle, but does not
48 #render any of the ancestor nodes of $k
49
50
51 # or, explicitly use svg namespace and generate a document with its own DTD
52 print $svg->xmlify(-namespace=>'svg');
53
54 # or, explicitly use svg namespace and generate an in-line docunent
55 print $svg->xmlify(
56 -namespace => "svg",
57 -pubid => "-//W3C//DTD SVG 1.0//EN",
58 -inline => 1
59 );