Quiq/Svg/Tag.pm

filter: Statementstmt 100% 20 / 20 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 7 / 7 Podpod 100% 3 / 3 totaltotal 100% 30 / 30 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« Quiq/JQuery.pm ↑ Summary
1 # -----------------------------------------------------------------------------
2  
3 =encoding utf8
4  
5 =head1 NAME
6  
7 Quiq::Svg::Tag - Erzeuge SVG Markup-Code
8  
9 =head1 BASE CLASS
10  
11 L<Quiq::Tag>
12  
13 =head1 SYNOPSIS
14  
15 =head3 Modul laden und Objekt instantiieren
16  
17 use Quiq::Svg::Tag;
18
19 my $p = Quiq::Svg::Tag->new;
20  
21 =head3 Ein einfaches SVG-Dokument
22  
23 $svg = $p->cat(
24 $p->preamble,
25 $p->tag('svg',
26 width => 80,
27 height => 80,
28 $p->tag('circle',
29 cx => 40,
30 cy => 40,
31 r => 39,
32 style => 'stroke: black; fill: none',
33 ),
34 ),
35 );
36  
37 erzeugt
38  
39 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
40 <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
41
42 <svg width="80" height="80" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
43 <circle cx="40" cy="40" r="39" style="stroke: black; fill: yellow" />
44 </svg>
45  
46 was darstellt wird als
47  
48 =begin html
49  
50 <p class="sdoc-fig-p">
51 <img class="sdoc-fig-img" src="https://raw.github.com/s31tz/Quiq/master/img/quiq-svg-tag-01.png" width="80" height="80" alt="" />
52 </p>
53  
54 =end html
55  
56 Anstelle eines Kreises kann jeder andere SVG-Code
57 erzeugt werden.
58  
59 =head1 DESCRIPTION
60  
61 Ein Objekt der Klasse erzeugt SVG Markup-Code beliebiger Komplexität.
62 Dies geschieht durch systematische Anwendung der Methode $p->tag(),
63 die in der Basisklasse Quiq::Tag definiert ist und hier in
64 Quiq::Svg::Tag zur Erzeugung von SVG Markup überschrieben wurde.
65  
66 =head1 SEE ALSO
67  
68 =over 2
69  
70 =item *
71  
72 L<Mozilla SVG Element Reference|https://developer.mozilla.org/en-US/docs/Web/SVG/Element>
73  
74 =back
75  
76 =cut
77  
78 # -----------------------------------------------------------------------------
79  
80 package Quiq::Svg::Tag;
81 1 ▶use base qw/Quiq::Tag/;
Subroutine BEGIN: called CC=1 SCAR=0.0
82  
83 1 ▶use v5.10;
Subroutine BEGIN: called CC=1 SCAR=0.0
84 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
85 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
86  
87 1 our $VERSION = '1.240';
88  
89 # -----------------------------------------------------------------------------
90  
91 =head1 METHODS
92  
93 =head2 Instantiierung
94  
95 =cut
96  
97 # -----------------------------------------------------------------------------
98  
99 1 my %Elements = (
100 svg => ['m',[xmlns => 'http://www.w3.org/2000/svg',
101 'xmlns:svg' => 'http://www.w3.org/2000/svg',
102 'xmlns:xlink' => 'http://www.w3.org/1999/xlink']],
103 );
104  
105 # -----------------------------------------------------------------------------
106  
107 =head3 new() - Konstruktor
108  
109 =head4 Synopsis
110  
111 $p = $class->new;
112  
113 =head4 Returns
114  
115 Objekt
116  
117 =head4 Description
118  
119 Instantiiere ein Objekt der Klasse und liefere eine Referenz
120 auf dieses Objekt zurück.
121  
122 =cut
123  
124 # -----------------------------------------------------------------------------
125  
126 1 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod documented
127 1 my $class = shift;
128 1 return $class->SUPER::new;
129 }
130  
131 # -----------------------------------------------------------------------------
132  
133 =head2 Generierung
134  
135 =head3 preamble() - SVG-Vorspann
136  
137 =head4 Synopsis
138  
139 $svg = $p->preamble;
140  
141 =head4 Returns
142  
143 SVG-Vorspann (String)
144  
145 =head4 Description
146  
147 Liefere die SVG-Präambel bestehend aus der "XML Processing Instruction"
148 und der "DOCTYPE Declaration":
149  
150 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
151 <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
152  
153 =cut
154  
155 # -----------------------------------------------------------------------------
156  
157 2 ▶sub preamble {
Subroutine preamble: called CC=1 SCAR=0.0
Pod documented
158 2 my $self = shift;
159  
160 2 return qq|<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\n|.
161 qq|<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"|.
162 qq| "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">\n\n|;
163 }
164  
165 # -----------------------------------------------------------------------------
166  
167 =head3 tag() - SVG-Tag
168  
169 =head4 Synopsis
170  
171 $svg = $p->tag($elem,@opts,@attrs);
172 $svg = $p->tag($elem,@opts,@attrs,$content);
173 $svg = $p->tag($elem,@opts,@attrs,'-',@content);
174  
175 =head4 Arguments
176  
177 I<< Siehe Quiq::Tag->tag() >>
178  
179 =head4 Options
180  
181 I<< Siehe Quiq::Tag->tag() >>
182  
183 =head4 Returns
184  
185 SVG-Code (String)
186  
187 =head4 Description
188  
189 Erzeuge einen SVG-Tag und liefere diesen zurück. Die Methode
190 ruft die gleichnamige Basisklassenmethode auf und übergibt
191 die SVG-spezifischen Element-Definitionen per Option C<-elements>.
192 Diese definieren die Default-Formatierung und die Default-Attribute
193 einzelner SVG-Elemente. Details zur Methode siehe Quiq::Tag->tag().
194  
195 =cut
196  
197 # -----------------------------------------------------------------------------
198  
199 3 ▶sub tag {
Subroutine tag: called CC=1 SCAR=0.0
Pod documented
200 3 my ($self,$elem) = splice @_,0,2;
201 3 return $self->SUPER::tag($elem,-elements=>\%Elements,@_);
202 }
203  
204 # -----------------------------------------------------------------------------
205  
206 =head1 VERSION
207  
208 1.240
209  
210 =head1 AUTHOR
211  
212 Frank Seitz, L<http://fseitz.de/>
213  
214 =head1 COPYRIGHT
215  
216 Copyright (C) 2026 Frank Seitz
217  
218 =head1 LICENSE
219  
220 This code is free software; you can redistribute it and/or modify
221 it under the same terms as Perl itself.
222  
223 =cut
224  
225 # -----------------------------------------------------------------------------
226  
227 1 1;
228  
229 # eof
« Quiq/JQuery.pm ↑ Summary