Skip Menu |

This queue is for tickets about the SVG CPAN distribution.

Report information
The Basics
Id: 132058
Status: open
Priority: 0/
Queue: SVG

People
Owner: MANWAR [...] cpan.org
Requestors: ALEENA [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: (no value)
Fixed in: (no value)



Subject: SVG::Element incomplete, objects missing
I tried using circle, title, and path and got the errors: Can't locate object method "path" via package "SVG::Element" at SVG-pm-nested-groups.pl line 18. Can't locate object method "circle" via package "SVG::Element" at SVG-pm-nested-groups.pl line 20. Can't locate object method "title" via package "SVG::Element" at SVG-pm-nested-groups.pl line 19. Where are all of the other svg tags? Why is rectangle the only shape there? Also, please do NOT put line, polyline, and path together under one umbrella object method. Separate them out please? Lady Aleena
Hi, Thanks for your interest SVG distribution. The three methods you mentioned in your ticket i.e. circle, path and title are AUTOLOADED into SVG namespace through SVG::Element. If you look at the pod document for SVG, you will find plenty of examples. Please find below example from the pod showing the above methods. #!/usr/bin/perl use strict; use warnings; use SVG; # create an SVG object my $svg= SVG->new( width => 200, height => 200); # use explicit element constructor to generate a group element my $y = $svg->group( id => 'group_y', style => { stroke => 'red', fill => 'green' }, ); # add a circle to the group $y->circle( cx => 100, cy => 100, r => 50, id => 'circle_in_group_y' ); # a 10-pointsaw-tooth pattern drawn with a path definition my $xv = [0,1,2,3,4,5,6,7,8,9]; my $yv = [0,1,0,1,0,1,0,1,0,1]; $points = $svg->get_path( x => $xv, y => $yv, -type => 'path', -closed => 'true' #specify that the polyline is closed ); $tag = $svg->path( %$points, id => 'pline_1', style => { 'fill-opacity' => 0, 'fill' => 'green', 'stroke' => 'rgb(250,123,23)' } ); my $tag = $svg->title(id=>'document-title')->cdata('This is the title');
I just tried the following: #!/usr/bin/perl use strict; use warnings; use feature qw(say); use SVG (); my $svg = SVG->new( viewBox => "0 0 100 100", width => '100', height => '100'); $svg->circle( cx => '50', cy => '50', r => '20', id => 'my_circle'); my $text = $svg->xmlify; say $text; And the following was returned: Can't locate object method "circle" via package "SVG" at /home/me/scripts/svg_test.pl line 10. It appears that circle is not autoloaded Then I tried... my $svg = SVG->new( viewBox => "0 0 100 100", width => '100', height => '100'); $svg->title( id => 'my_title')->cdata('This is my title'); The following was returned: Can't locate object method "title" via package "SVG" at /home/me/scripts/svg_test.pl line 10. Also, the <path> element does not have x, y, or points. It has the d= attribute that looks like the following: <path d="m 20,20 h 60 v 20 i 10,10" class="path" id="my_path" /> So, I can see how the SVG module's get_path/path can apply to <line> and <polyline>, but not to the actual <path> element. LA On Sat Mar 07 07:09:27 2020, MANWAR wrote: Show quoted text
> Hi, > > Thanks for your interest SVG distribution. > > The three methods you mentioned in your ticket i.e. circle, path and > title are AUTOLOADED into SVG namespace through SVG::Element. > > If you look at the pod document for SVG, you will find plenty of > examples. > Please find below example from the pod showing the above methods. > > #!/usr/bin/perl > use strict; > use warnings; > use SVG; > > # create an SVG object > my $svg= SVG->new( width => 200, height => 200); > > # use explicit element constructor to generate a group element > my $y = $svg->group( > id => 'group_y', > style => { > stroke => 'red', > fill => 'green' > }, > ); > > # add a circle to the group > $y->circle( cx => 100, cy => 100, r => 50, id => 'circle_in_group_y' > ); > > > # a 10-pointsaw-tooth pattern drawn with a path definition > my $xv = [0,1,2,3,4,5,6,7,8,9]; > my $yv = [0,1,0,1,0,1,0,1,0,1]; > > $points = $svg->get_path( > x => $xv, > y => $yv, > -type => 'path', > -closed => 'true' #specify that the polyline is closed > ); > > $tag = $svg->path( > %$points, > id => 'pline_1', > style => { > 'fill-opacity' => 0, > 'fill' => 'green', > 'stroke' => 'rgb(250,123,23)' > } > ); > > my $tag = $svg->title(id=>'document-title')->cdata('This is the > title');