Thread SVG: Syntaxfrage (7 answers)
Opened by Dynaaamo at 2011-01-25 11:23

GwenDragon
 2011-01-25 16:06
#145009 #145009
User since
2005-01-17
14533 Artikel
Admin1
[Homepage]
user image
Wenn ich das Beispiel http://cpansearch.perl.org/src/RONAN/SVG-2.50/exam... interpretiere, musst du sehr wohl die Elemente nacheinander in die Gruppe "einfügen":
Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
my $y=$svg->group(
id => 'group_y',
style => { stroke=>'red', fill=>'green' }
);

$y->circle(cx=>100, cy=>100, r=>50, id=>'circle_in_group_y_1');
# add a circle to the group
$y->circle(cx=>100, cy=>100, r=>50, id=>'circle_in_group_y_2');
$y->comment('This is a comment');
$y->circle(cx=>100, cy=>100, r=>50, id=>'circle_in_group_y_3');
# now render the SVG object, implicitly use svg namespace
print "\nfirst drawing\n";
print $svg->xmlify;


Folgender Test:
Code (perl): (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/usr/bin/perl

use strict;
use warnings;

use SVG;

my $svg = SVG->new(width => 600, height => 600);

my $viereck=$svg->group(id => 'gr_viereck');
$viereck-> rectangle(id=>'viereck1', 'stroke' => 'red', 'fill'=>'yellow', x=>0, y=>0, width=>50, height=>50);
$viereck-> rectangle(id=>'viereck2', 'stroke' => 'blue', 'fill'=>'white', x=>100, y=>100, width=>150, height=>150);

# das hier soll das eigentliche Ziel sein:
my $v = $svg->use(-href=>'#gr_viereck', transform=>'translate(250, 250) scale(0.9)');

print $svg->xmlify;

erzeugt:
Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
<svg height="600" width="600" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<g id="gr_viereck">
<rect fill="yellow" height="50" id="viereck1" stroke="red" width="50" x="0" y="0" />
<rect fill="white" height="150" id="viereck2" stroke="blue" width="150" x="100" y="100" />
</g>
<use transform="translate(250, 250) scale(0.9)" xlink:href="#gr_viereck" />
<!--
Generated using the Perl SVG Module V2.50
by Ronan Oger
Info: http://www.roitsystems.com/
-->
</svg>

Und was ist daran falsch?

Wenn ich die Ausgabe der SPerlprogramms in eine Datei namens test.svg umleite und die im Brwoser öffne, sehe ich die eine Gruppe Vierecke gelb- und weiß-gefüllt und verkleinert und verschoben die transformierte.
Last edited: 2011-01-25 16:26:02 +0100 (CET)
die Drachin, Gwendolyn


Unterschiedliche Perl-Versionen auf Windows (fast wie perlbrew) • Meine Perl-Artikel

View full thread SVG: Syntaxfrage