view not-used/svgExample.pl @ 78:4ebd94bfecda laserkard

moved css files to own directory; deleted USELESS files
author Robert McIntyre <rlm@mit.edu>
date Thu, 22 Jul 2010 09:56:12 -0400
parents
children
line wrap: on
line source
1 #!/usr/bin/perl -w
2 use strict;
3 use SVG;
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);
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 );
16 # add a circle to the group
17 $y->circle(cx=>100, cy=>100, r=>50, id=>'circle_in_group_y');
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 );
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');
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 );
43 # now render the SVG object, implicitly use svg namespace
44 print $svg->xmlify;
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
51 # or, explicitly use svg namespace and generate a document with its own DTD
52 print $svg->xmlify(-namespace=>'svg');
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 );