Mercurial > laserkard
view svgExample.pl @ 58:9d156039944e laserkard
[svn r59] final modifacatios wqith kevin
author | rlm |
---|---|
date | Sun, 14 Mar 2010 01:51:23 -0500 |
parents | 8b3b5753ad41 |
children |
line wrap: on
line source
1 #!/usr/bin/perl -w2 use strict;3 use SVG;5 # create an SVG object6 my $svg= SVG->new(width=>200,height=>200);7 #or8 my $svg= SVG->new(width=>200,height=>200);10 # use explicit element constructor to generate a group element11 my $y=$svg->group(12 id => 'group_y',13 style => { stroke=>'red', fill=>'green' }14 );16 # add a circle to the group17 $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 name20 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' method29 $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 z32 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 namespace44 print $svg->xmlify;46 # or render a child node of the SVG object without rendering the entire object47 print $k->xmlify; #renders the anchor $k above containing a rectangle, but does not48 #render any of the ancestor nodes of $k51 # or, explicitly use svg namespace and generate a document with its own DTD52 print $svg->xmlify(-namespace=>'svg');54 # or, explicitly use svg namespace and generate an in-line docunent55 print $svg->xmlify(56 -namespace => "svg",57 -pubid => "-//W3C//DTD SVG 1.0//EN",58 -inline => 159 );