line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package SVG::GD;
|
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
$VERSION = '0.20';
|
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
12509
|
no strict 'refs';
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
35
|
|
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
1348
|
use SVG;
|
|
1
|
|
|
|
|
23272
|
|
|
1
|
|
|
|
|
8
|
|
8
|
1
|
|
|
1
|
|
1126
|
use Exporter;
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
41
|
|
9
|
1
|
|
|
1
|
|
5
|
use warnings;
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
83
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=pod
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 Name: SVG::GD
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 Version 0.20
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 Author: Ronan Oger
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head1 Abstract
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
Provide (as seamless as possible) an SVG wrapper to the GD API
|
22
|
|
|
|
|
|
|
in order to provide SVG output of images generate with the Perl GD module
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head1 Synopsis
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
use GD;
|
27
|
|
|
|
|
|
|
use SVG::GD;
|
28
|
|
|
|
|
|
|
$im = new GD::Image(100,50);
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
# allocate black -- this will be our background
|
31
|
|
|
|
|
|
|
$black = $im->colorAllocate(0, 0, 0);
|
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
# allocate white
|
34
|
|
|
|
|
|
|
$white = $im->colorAllocate(255, 255, 255);
|
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
# allocate red
|
37
|
|
|
|
|
|
|
$red = $im->colorAllocate(255, 0, 0);
|
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
# allocate blue
|
40
|
|
|
|
|
|
|
$blue = $im->colorAllocate(0,0,255);
|
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
#Inscribe an ellipse in the image
|
43
|
|
|
|
|
|
|
$im->arc(50, 25, 98, 48, 0, 360, $white);
|
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
# Flood-fill the ellipse. Fill color is red, and will replace the
|
46
|
|
|
|
|
|
|
# black interior of the ellipse
|
47
|
|
|
|
|
|
|
$im->fill(50, 21, $red);
|
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
binmode STDOUT;
|
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
# print the image to stdout
|
52
|
|
|
|
|
|
|
print $im->png;
|
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=cut
|
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
BEGIN {
|
58
|
|
|
|
|
|
|
#first, let's re-map the GD::Image methods to somewhere else safe.
|
59
|
|
|
|
|
|
|
#nb we will also have to do this with the GD::Font methods
|
60
|
|
|
|
|
|
|
# *SVG::HGD::Image::new = \&GD::Image::new;
|
61
|
|
|
|
|
|
|
# *SVG::HGD::gdSmallFont =\&GD::gdSmallFont;
|
62
|
|
|
|
|
|
|
# *SVG::HGD::gdLargeFont =\&GD::gdLargeFont;
|
63
|
|
|
|
|
|
|
# *SVG::HGD::gdMediumBoldFont =\&GD::gdMediumBoldFont;
|
64
|
|
|
|
|
|
|
# *SVG::HGD::gdTinyFont =\&GD::gdTinyFont;
|
65
|
|
|
|
|
|
|
# *SVG::HGD::gdGiantFont =\&GD::gdGiantFont;
|
66
|
|
|
|
|
|
|
# *SVG::HGD::Image::_make_filehandle =\&GD::Image::_make_filehandle;
|
67
|
|
|
|
|
|
|
# *SVG::HGD::Image::new =\&GD::Image::new;
|
68
|
|
|
|
|
|
|
# *SVG::HGD::Image::newTrueColor =\&GD::Image::newTrueColor;
|
69
|
|
|
|
|
|
|
# *SVG::HGD::Image::newPalette =\&GD::Image::newPalette;
|
70
|
|
|
|
|
|
|
# *SVG::HGD::Image::newFromPng =\&GD::Image::newFromPng;
|
71
|
|
|
|
|
|
|
# *SVG::HGD::Image::newFromJpeg =\&GD::Image::newFromJpeg;
|
72
|
|
|
|
|
|
|
# *SVG::HGD::Image::newFromXbm =\&GD::Image::newFromXbm;
|
73
|
|
|
|
|
|
|
# *SVG::HGD::Image::newFromGd =\&GD::Image::newFromGd;
|
74
|
|
|
|
|
|
|
# *SVG::HGD::Image::newFromGd2 =\&GD::Image::newFromGd2;
|
75
|
|
|
|
|
|
|
# *SVG::HGD::Image::newFromGd2Part =\&GD::Image::newFromGd2Part;
|
76
|
|
|
|
|
|
|
# *SVG::HGD::Image::ellipse =\&GD::Image::ellipse;
|
77
|
|
|
|
|
|
|
# *SVG::HGD::Image::clone =\&GD::Image::clone;
|
78
|
|
|
|
|
|
|
# *SVG::HGD::Polygon::new =\&GD::Polygon::new;
|
79
|
|
|
|
|
|
|
# *SVG::HGD::Polygon::DESTROY =\&GD::Polygon::DESTROY;
|
80
|
|
|
|
|
|
|
# *SVG::HGD::Polygon::addPt =\&GD::Polygon::addPt;
|
81
|
|
|
|
|
|
|
# *SVG::HGD::Polygon::getPt =\&GD::Polygon::getPt;
|
82
|
|
|
|
|
|
|
# *SVG::HGD::Polygon::setPt =\&GD::Polygon::setPt;
|
83
|
|
|
|
|
|
|
# *SVG::HGD::Polygon::length =\&GD::Polygon::length;
|
84
|
|
|
|
|
|
|
# *SVG::HGD::Polygon::vertices =\&GD::Polygon::vertices;
|
85
|
|
|
|
|
|
|
# *SVG::HGD::Polygon::bounds =\&GD::Polygon::bounds;
|
86
|
|
|
|
|
|
|
# *SVG::HGD::Polygon::deletePt =\&GD::Polygon::deletePt;
|
87
|
|
|
|
|
|
|
# *SVG::HGD::Polygon::offset =\&GD::Polygon::offset;
|
88
|
|
|
|
|
|
|
# *SVG::HGD::Polygon::map =\&GD::Polygon::map;
|
89
|
|
|
|
|
|
|
# *SVG::HGD::Image::polygon =\&GD::Image::polygon;
|
90
|
|
|
|
|
|
|
# *SVG::HGD::Polygon::toPt =\&GD::Polygon::toPt;
|
91
|
|
|
|
|
|
|
# *SVG::HGD::Polygon::transform =\&GD::Polygon::transform;
|
92
|
|
|
|
|
|
|
# *SVG::HGD::Polygon::scale =\&GD::Polygon::scale;
|
93
|
|
|
|
|
|
|
|
94
|
1
|
|
|
1
|
|
12
|
*GD::Font:: = *SVG::GD::Font::;
|
95
|
1
|
|
|
|
|
45
|
*GD::Image:: = *SVG::GD::Image::;
|
96
|
|
|
|
|
|
|
}
|
97
|
|
|
|
|
|
|
|
98
|
1
|
|
|
1
|
|
6
|
use vars qw/$VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS/;
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
373
|
|
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
our $tinyfontsize='5';
|
101
|
|
|
|
|
|
|
our $smallfontsize='7';
|
102
|
|
|
|
|
|
|
our $mediumfontsize='10';
|
103
|
|
|
|
|
|
|
our $largefontsize='12';
|
104
|
|
|
|
|
|
|
our $giantfontsize='16';
|
105
|
|
|
|
|
|
|
our $font = {};
|
106
|
|
|
|
|
|
|
our $fontindex = 0;
|
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
@ISA = qw/Exporter/;
|
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
@EXPORT = qw/
|
111
|
|
|
|
|
|
|
gdBrushed
|
112
|
|
|
|
|
|
|
gdDashSize
|
113
|
|
|
|
|
|
|
gdMaxColors
|
114
|
|
|
|
|
|
|
gdStyled
|
115
|
|
|
|
|
|
|
gdStyledBrushed
|
116
|
|
|
|
|
|
|
gdTiled
|
117
|
|
|
|
|
|
|
gdTransparent
|
118
|
|
|
|
|
|
|
gdSmallFont
|
119
|
|
|
|
|
|
|
gdMediumBoldFont
|
120
|
|
|
|
|
|
|
gdLargeFont
|
121
|
|
|
|
|
|
|
gdGiantFont /;
|
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
@EXPORT_OK = qw/
|
124
|
|
|
|
|
|
|
GD_CMP_IMAGE
|
125
|
|
|
|
|
|
|
GD_CMP_NUM_COLORS
|
126
|
|
|
|
|
|
|
GD_CMP_COLOR
|
127
|
|
|
|
|
|
|
GD_CMP_SIZE_X
|
128
|
|
|
|
|
|
|
GD_CMP_SIZE_Y
|
129
|
|
|
|
|
|
|
GD_CMP_TRANSPARENT
|
130
|
|
|
|
|
|
|
GD_CMP_BACKGROUND
|
131
|
|
|
|
|
|
|
GD_CMP_INTERLACE
|
132
|
|
|
|
|
|
|
GD_CMP_TRUECOLOR /;
|
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
%EXPORT_TAGS = ('cmp' => [ qw/
|
135
|
|
|
|
|
|
|
GD_CMP_IMAGE
|
136
|
|
|
|
|
|
|
GD_CMP_NUM_COLORS
|
137
|
|
|
|
|
|
|
GD_CMP_COLOR
|
138
|
|
|
|
|
|
|
GD_CMP_SIZE_X
|
139
|
|
|
|
|
|
|
GD_CMP_SIZE_Y
|
140
|
|
|
|
|
|
|
GD_CMP_TRANSPARENT
|
141
|
|
|
|
|
|
|
GD_CMP_BACKGROUND
|
142
|
|
|
|
|
|
|
GD_CMP_INTERLACE
|
143
|
|
|
|
|
|
|
GD_CMP_TRUECOLOR / ]
|
144
|
|
|
|
|
|
|
);
|
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=head2 gdTinyFont
|
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
returns SVG::GD::Font::Tiny
|
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=cut
|
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
#font control
|
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
sub SVG::GD::gdTinyFont {
|
156
|
0
|
|
|
0
|
1
|
|
return SVG::GD::Font::Tiny();
|
157
|
|
|
|
|
|
|
}
|
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
#font control
|
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=head2 gdSmallFont
|
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
returns SVG::GD::Font::Small();
|
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=cut
|
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
sub SVG::GD::gdSmallFont {
|
169
|
0
|
|
|
0
|
1
|
|
return SVG::GD::Font::Small();
|
170
|
|
|
|
|
|
|
}
|
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=head2 gdMediumBoldFont
|
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
returns SVG::GD::Font::Bold();
|
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
=cut
|
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
#font control
|
179
|
|
|
|
|
|
|
sub SVG::GD::gdMediumBoldFont {
|
180
|
0
|
|
|
0
|
1
|
|
return SVG::GD::Font::MediumBold();
|
181
|
|
|
|
|
|
|
}
|
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
=head2 gdLargeFont
|
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
Returns SVG::GD::Font::Large()
|
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
=cut
|
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
#font control
|
190
|
|
|
|
|
|
|
sub SVG::GD::gdLargeFont {
|
191
|
0
|
|
|
0
|
1
|
|
return SVG::GD::Font::Large();
|
192
|
|
|
|
|
|
|
}
|
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
=head2 gdGiantFont
|
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
Returns SVG::GD::Font::Giant()
|
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
=cut
|
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
#font control
|
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
sub SVG::GD::gdGiantFont {
|
205
|
0
|
|
|
0
|
1
|
|
return SVG::GD::Font::Giant();
|
206
|
|
|
|
|
|
|
}
|
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
=head2 gdBrushed
|
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
Does nothing at this time
|
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
=cut
|
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
sub SVG::GD::gdBrushed {
|
215
|
0
|
|
|
0
|
1
|
|
return '';
|
216
|
|
|
|
|
|
|
}
|
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
#
|
219
|
|
|
|
|
|
|
#
|
220
|
|
|
|
|
|
|
# OO font support (encountered in GD::Graph::radar)
|
221
|
|
|
|
|
|
|
#
|
222
|
|
|
|
|
|
|
#
|
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
package SVG::GD::Font;
|
225
|
|
|
|
|
|
|
|
226
|
1
|
|
|
1
|
|
13
|
use strict;
|
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
32
|
|
227
|
1
|
|
|
1
|
|
1144
|
use Data::Dumper;
|
|
1
|
|
|
|
|
7598
|
|
|
1
|
|
|
|
|
80
|
|
228
|
1
|
|
|
1
|
|
10
|
use warnings;
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
454
|
|
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
sub registerFont($) {
|
231
|
0
|
|
|
0
|
|
|
my $size = shift;
|
232
|
0
|
|
|
|
|
|
$fontindex++;
|
233
|
0
|
|
|
|
|
|
$font->{$fontindex}->{fontheight} = $size;
|
234
|
0
|
|
|
|
|
|
$font->{$fontindex}->{fontstyle} = {'font-size'=>$size};
|
235
|
0
|
|
|
|
|
|
return $fontindex;
|
236
|
|
|
|
|
|
|
}
|
237
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
sub Giant {
|
239
|
0
|
|
|
0
|
|
|
my $class = shift;
|
240
|
0
|
|
|
|
|
|
my $size = $giantfontsize;
|
241
|
0
|
|
|
|
|
|
SVG::GD::Font::registerFont($size);
|
242
|
|
|
|
|
|
|
}
|
243
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
sub Large {
|
245
|
0
|
|
|
0
|
|
|
my $class = shift;
|
246
|
0
|
|
|
|
|
|
my $size = $largefontsize;
|
247
|
0
|
|
|
|
|
|
SVG::GD::Font::registerFont($size);
|
248
|
|
|
|
|
|
|
}
|
249
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
sub Medium {
|
251
|
0
|
|
|
0
|
|
|
my $class = shift;
|
252
|
0
|
|
|
|
|
|
my $size = $mediumfontsize;
|
253
|
0
|
|
|
|
|
|
SVG::GD::Font::registerFont($size);
|
254
|
|
|
|
|
|
|
}
|
255
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
sub MediumBold {
|
257
|
0
|
|
|
0
|
|
|
my $class = shift;
|
258
|
0
|
|
|
|
|
|
my $size = $mediumfontsize;
|
259
|
0
|
|
|
|
|
|
SVG::GD::Font::registerFont($size);
|
260
|
|
|
|
|
|
|
}
|
261
|
|
|
|
|
|
|
|
262
|
|
|
|
|
|
|
sub Small {
|
263
|
0
|
|
|
0
|
|
|
my $class = shift;
|
264
|
0
|
|
|
|
|
|
my $size = $smallfontsize;
|
265
|
0
|
|
|
|
|
|
SVG::GD::Font::registerFont($size);
|
266
|
|
|
|
|
|
|
}
|
267
|
|
|
|
|
|
|
|
268
|
|
|
|
|
|
|
sub Tiny {
|
269
|
0
|
|
|
0
|
|
|
my $class = shift;
|
270
|
0
|
|
|
|
|
|
my $size = $tinyfontsize;
|
271
|
0
|
|
|
|
|
|
SVG::GD::Font::registerFont($size);
|
272
|
|
|
|
|
|
|
}
|
273
|
|
|
|
|
|
|
|
274
|
|
|
|
|
|
|
sub height {
|
275
|
0
|
|
|
0
|
|
|
my $id = shift;
|
276
|
0
|
|
|
|
|
|
return 10;
|
277
|
|
|
|
|
|
|
}
|
278
|
|
|
|
|
|
|
|
279
|
|
|
|
|
|
|
sub width {
|
280
|
0
|
|
|
0
|
|
|
my $myfont = shift;
|
281
|
0
|
|
|
|
|
|
return 8;
|
282
|
|
|
|
|
|
|
}
|
283
|
|
|
|
|
|
|
|
284
|
|
|
|
|
|
|
=head2 getSVGstyle($font)
|
285
|
|
|
|
|
|
|
|
286
|
|
|
|
|
|
|
retrieve the style in SVG format for predefined fomts
|
287
|
|
|
|
|
|
|
|
288
|
|
|
|
|
|
|
=cut
|
289
|
|
|
|
|
|
|
|
290
|
|
|
|
|
|
|
sub getSVGstyle {
|
291
|
0
|
|
|
0
|
|
|
my $myfont = shift;
|
292
|
0
|
0
|
|
|
|
|
if (eval{defined $font->{$myfont}->{fontstyle} eq 'HASH'}) {
|
|
0
|
|
|
|
|
|
|
293
|
0
|
|
|
|
|
|
return %{$font->{$myfont}->{fontstyle}};
|
|
0
|
|
|
|
|
|
|
294
|
|
|
|
|
|
|
} else {
|
295
|
0
|
|
|
|
|
|
return ();
|
296
|
|
|
|
|
|
|
}
|
297
|
|
|
|
|
|
|
|
298
|
|
|
|
|
|
|
}
|
299
|
|
|
|
|
|
|
#
|
300
|
|
|
|
|
|
|
# SVG::GD::Image
|
301
|
|
|
|
|
|
|
#
|
302
|
|
|
|
|
|
|
|
303
|
|
|
|
|
|
|
package SVG::GD::Image;
|
304
|
|
|
|
|
|
|
|
305
|
1
|
|
|
1
|
|
7
|
use warnings;
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
27
|
|
306
|
1
|
|
|
1
|
|
5
|
use strict;
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
2901
|
|
307
|
|
|
|
|
|
|
|
308
|
|
|
|
|
|
|
#constructor
|
309
|
|
|
|
|
|
|
sub SVG::GD::Image::new {
|
310
|
0
|
|
|
0
|
|
|
my $class = shift;
|
311
|
0
|
|
|
|
|
|
my $self = {};
|
312
|
0
|
|
|
|
|
|
bless $self, $class;
|
313
|
|
|
|
|
|
|
#$self->{_GD_} = new SVG::HGD::Image(@_)
|
314
|
|
|
|
|
|
|
# || print STDERR "Quitting. Unable to construct new SVG::HGD::Image
|
315
|
|
|
|
|
|
|
# object using SVG::GD!: $!\n";
|
316
|
|
|
|
|
|
|
#return undef unless defined $self->{_GD_};
|
317
|
|
|
|
|
|
|
|
318
|
0
|
|
|
|
|
|
my ($val_1,$val_2,$val_3) = @_;
|
319
|
|
|
|
|
|
|
#do we have drawing sizes?
|
320
|
0
|
0
|
0
|
|
|
|
if ($val_1 =~ /^\d+$/ && $val_2 =~ /^\d+$/) {
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
321
|
0
|
|
|
|
|
|
$self->{_ATTRIBUTES_}->{width} = $val_1;
|
322
|
0
|
|
|
|
|
|
$self->{_ATTRIBUTES_}->{height} = $val_2;
|
323
|
0
|
0
|
|
|
|
|
$self->{_ATTRIBUTES_}->{-truecolor} = $val_3
|
324
|
|
|
|
|
|
|
if defined $val_3;
|
325
|
|
|
|
|
|
|
|
326
|
|
|
|
|
|
|
}
|
327
|
|
|
|
|
|
|
#do we have a valid filename?
|
328
|
|
|
|
|
|
|
elsif (-r $val_1) {
|
329
|
0
|
|
|
|
|
|
$self->{_ATTRIBUTES_}->{FILENAME} = $val_1;
|
330
|
|
|
|
|
|
|
}
|
331
|
|
|
|
|
|
|
#do we have a file reference?
|
332
|
|
|
|
|
|
|
elsif (ref $val_1) {
|
333
|
0
|
|
|
|
|
|
$self->{_ATTRIBUTES_}->{FILEHANDLE} = $val_1;
|
334
|
|
|
|
|
|
|
}
|
335
|
|
|
|
|
|
|
#then we have raw image data.
|
336
|
0
|
|
|
|
|
|
elsif (defined $val_1) {
|
337
|
0
|
|
|
|
|
|
$self->{_ATTRIBUTES_}->{IMAGEDATA} = $val_1;
|
338
|
|
|
|
|
|
|
}
|
339
|
|
|
|
|
|
|
else {return undef}
|
340
|
|
|
|
|
|
|
#build the svg drawing
|
341
|
0
|
|
|
|
|
|
$self->{_SVG_} = SVG->new(%{$self->{_ATTRIBUTES_}});
|
|
0
|
|
|
|
|
|
|
342
|
0
|
|
|
|
|
|
$self->{scratch}->{index_colours} = 0;
|
343
|
0
|
|
|
|
|
|
$self->{_COLOUR_}->{named} = {
|
344
|
|
|
|
|
|
|
white => {svg=>'white',rgb=>'white'},
|
345
|
|
|
|
|
|
|
lgray => {svg=>'gray',rgb=>'lgray'},
|
346
|
|
|
|
|
|
|
gray => {svg=>'gray',rgb=>'gray'},
|
347
|
|
|
|
|
|
|
dgray => {svg=>'gray',rgb=>'dgray'},
|
348
|
|
|
|
|
|
|
black =>{svg=>'black',rgb=>'black'},
|
349
|
|
|
|
|
|
|
lblue =>{svg=>'lightblue',rgb=>'lblue'},
|
350
|
|
|
|
|
|
|
blue => {svg=>'blue',rgb=>'blue'},
|
351
|
|
|
|
|
|
|
dblue =>, {svg=>'darkblue',rgb=>'dblue'},
|
352
|
|
|
|
|
|
|
gold => {svg=>'gold',rgb=>'gold'},
|
353
|
|
|
|
|
|
|
lyellow =>{svg=>'yellow',rgb=>'lyellow'},
|
354
|
|
|
|
|
|
|
yellow =>{svg=>'yellow',rgb=>'yellow'},
|
355
|
|
|
|
|
|
|
dyellow =>{svg=>'gold',rgb=>'gold'},
|
356
|
|
|
|
|
|
|
lgreen =>{svg=>'mintgreen',rgb=>'lgreen'},
|
357
|
|
|
|
|
|
|
green =>{svg=>'green',rgb=>'green'},
|
358
|
|
|
|
|
|
|
dgreen =>{svg=>'darkgreen',rgb=>'dgreen'},
|
359
|
|
|
|
|
|
|
lred =>{svg=>'red',rgb=>'dred'},
|
360
|
|
|
|
|
|
|
red => {svg=>'red',rgb=>'red'},
|
361
|
|
|
|
|
|
|
dred =>{svg=>'red',rgb=>'dred'},
|
362
|
|
|
|
|
|
|
lpurple =>{svg=>'gold',rgb=>'gold'},
|
363
|
|
|
|
|
|
|
purple => {svg=>'purple',rgb=>'purple'},
|
364
|
|
|
|
|
|
|
dpurple =>{svg=>'dpurple ',rgb=>'dpurple'},
|
365
|
|
|
|
|
|
|
lorange =>{svg=>'lorange ',rgb=>'lorange'},
|
366
|
|
|
|
|
|
|
orange => {svg=>'orange',rgb=>'orange'},
|
367
|
|
|
|
|
|
|
pink => {svg=>'pink',rgb=>'pink'},
|
368
|
|
|
|
|
|
|
dpink =>{svg=>'pink',rgb=>'dpink'},
|
369
|
|
|
|
|
|
|
marine =>{svg=>'navy',rgb=>'marine'},
|
370
|
|
|
|
|
|
|
cyan => {svg=>'cyan',rgb=>'cyan'},
|
371
|
|
|
|
|
|
|
lbrown =>{svg=>'brown',rgb=>'lbrown'},
|
372
|
|
|
|
|
|
|
dbrown => {svg=>'brown',rgb=>'dbrown'},
|
373
|
|
|
|
|
|
|
};
|
374
|
0
|
|
|
|
|
|
return $self;
|
375
|
|
|
|
|
|
|
}
|
376
|
|
|
|
|
|
|
|
377
|
|
|
|
|
|
|
|
378
|
|
|
|
|
|
|
#--------------------
|
379
|
|
|
|
|
|
|
#Wrapper methods
|
380
|
|
|
|
|
|
|
|
381
|
|
|
|
|
|
|
=head2 setPixel
|
382
|
|
|
|
|
|
|
|
383
|
|
|
|
|
|
|
set a pixel to a colour
|
384
|
|
|
|
|
|
|
Because SVG does not understand pixels, this method has to be faked. We know
|
385
|
|
|
|
|
|
|
from the image size what is meant by a pixel, so we create a rectangle of size
|
386
|
|
|
|
|
|
|
1x1 and give it a colour
|
387
|
|
|
|
|
|
|
|
388
|
|
|
|
|
|
|
=cut
|
389
|
|
|
|
|
|
|
|
390
|
|
|
|
|
|
|
sub SVG::GD::Image::setPixel($$$$) {
|
391
|
0
|
|
|
0
|
|
|
my $self = shift;
|
392
|
0
|
|
|
|
|
|
my ($x,$y,$colour) = @_;
|
393
|
0
|
|
|
|
|
|
$self->{_SVG_}->rect(x=>$x,y=>$y,
|
394
|
|
|
|
|
|
|
width=>1,height=>1,
|
395
|
|
|
|
|
|
|
fill=>$self->getColour($colour));
|
396
|
|
|
|
|
|
|
# $self->{_GD_}->setPixel($x,$y,$colour);
|
397
|
|
|
|
|
|
|
}
|
398
|
|
|
|
|
|
|
|
399
|
|
|
|
|
|
|
|
400
|
|
|
|
|
|
|
=head2 colorAllocate
|
401
|
|
|
|
|
|
|
|
402
|
|
|
|
|
|
|
Allocate the colour to a variable (red,green,blue)
|
403
|
|
|
|
|
|
|
|
404
|
|
|
|
|
|
|
=cut
|
405
|
|
|
|
|
|
|
|
406
|
|
|
|
|
|
|
sub SVG::GD::Image::colorAllocate($$$$) {
|
407
|
0
|
|
|
0
|
|
|
my $self = shift;
|
408
|
0
|
|
|
|
|
|
my ($red,$green,$blue) = @_;
|
409
|
|
|
|
|
|
|
# my $code = $self->{_GD_}->colorAllocate($red,$green,$blue);
|
410
|
|
|
|
|
|
|
#if we get an rgb triplet, handle as an rgb triplet
|
411
|
0
|
|
|
|
|
|
my $code = $self->{index_colour}++;
|
412
|
|
|
|
|
|
|
|
413
|
0
|
0
|
0
|
|
|
|
if (defined $green && defined $blue) {
|
414
|
|
|
|
|
|
|
#$code = "$red.$green.$blue" if (defined $green && defined $blue);
|
415
|
0
|
|
|
|
|
|
$self->{_COLOUR_}->{$code}->{svg} =
|
416
|
|
|
|
|
|
|
$self->{_SVG_}->colorAllocate($red,$green,$blue);
|
417
|
0
|
|
|
|
|
|
$self->{_COLOUR_}->{$code}->{rgb} = [$red,$green,$blue];
|
418
|
|
|
|
|
|
|
}
|
419
|
|
|
|
|
|
|
#otherwise assume this is a named colour.
|
420
|
|
|
|
|
|
|
else {
|
421
|
0
|
|
|
|
|
|
$code = $red;
|
422
|
0
|
|
|
|
|
|
$self->{_COLOUR_}->{$code}->{rgb} = [$code];
|
423
|
0
|
|
|
|
|
|
$self->{_COLOUR_}->{$code}->{svg} = [$code];
|
424
|
|
|
|
|
|
|
}
|
425
|
0
|
|
|
|
|
|
return $code;
|
426
|
|
|
|
|
|
|
}
|
427
|
|
|
|
|
|
|
|
428
|
|
|
|
|
|
|
=head2 colorResolve ($red,$green,$blue)
|
429
|
|
|
|
|
|
|
|
430
|
|
|
|
|
|
|
for an rbg tripplet, either returns the index for the colour or generates a new
|
431
|
|
|
|
|
|
|
index for that colour
|
432
|
|
|
|
|
|
|
|
433
|
|
|
|
|
|
|
=cut
|
434
|
|
|
|
|
|
|
|
435
|
|
|
|
|
|
|
*SVG::GD::Image::colorResolve = \&SVG::GD::Image::colorAllocate;
|
436
|
|
|
|
|
|
|
|
437
|
|
|
|
|
|
|
=head2 colorsTotal
|
438
|
|
|
|
|
|
|
|
439
|
|
|
|
|
|
|
return the number of allocated colors
|
440
|
|
|
|
|
|
|
|
441
|
|
|
|
|
|
|
=cut
|
442
|
|
|
|
|
|
|
|
443
|
|
|
|
|
|
|
sub SVG::GD::Image::colorsTotal ($) {
|
444
|
0
|
|
|
0
|
|
|
my $self = shift;
|
445
|
0
|
|
|
|
|
|
return scalar(keys %{$self->{_COLOUR_}});
|
|
0
|
|
|
|
|
|
|
446
|
|
|
|
|
|
|
}
|
447
|
|
|
|
|
|
|
|
448
|
|
|
|
|
|
|
=head2 colorExact
|
449
|
|
|
|
|
|
|
|
450
|
|
|
|
|
|
|
check for the existance of an exact color
|
451
|
|
|
|
|
|
|
|
452
|
|
|
|
|
|
|
=cut
|
453
|
|
|
|
|
|
|
|
454
|
|
|
|
|
|
|
sub SVG::GD::Image::colorExact ($$) {
|
455
|
0
|
|
|
0
|
|
|
my $self = shift;
|
456
|
0
|
|
|
|
|
|
my $colour = shift;
|
457
|
0
|
0
|
|
|
|
|
return 1 if $self->{_COLOUR_}->{$colour};
|
458
|
0
|
|
|
|
|
|
return -1;
|
459
|
|
|
|
|
|
|
}
|
460
|
|
|
|
|
|
|
|
461
|
|
|
|
|
|
|
=head2 colorClosest
|
462
|
|
|
|
|
|
|
|
463
|
|
|
|
|
|
|
returns the closest colour to the RGB triplet being submitted
|
464
|
|
|
|
|
|
|
|
465
|
|
|
|
|
|
|
=cut
|
466
|
|
|
|
|
|
|
|
467
|
|
|
|
|
|
|
sub SVG::GD::Image::colorClosest ($$$$) {
|
468
|
0
|
|
|
0
|
|
|
my $self = shift;
|
469
|
0
|
|
|
|
|
|
my ($red,$green,$blue) = @_;
|
470
|
0
|
|
|
|
|
|
my $value = {};
|
471
|
0
|
|
|
|
|
|
map {
|
472
|
0
|
|
|
|
|
|
my $cc = $_;
|
473
|
|
|
|
|
|
|
#calculate the least-square distance
|
474
|
0
|
|
|
|
|
|
my ($dr,$dg,$db) = (
|
475
|
|
|
|
|
|
|
$red * $red -
|
476
|
|
|
|
|
|
|
$self->{_COLOUR_}->{$cc}->[0] * $self->{_COLOUR_}->{$cc}->[0],
|
477
|
|
|
|
|
|
|
$green * $blue -
|
478
|
|
|
|
|
|
|
$self->{_COLOUR_}->{$cc}->[1] * $self->{_COLOUR_}->{$cc}->[1],
|
479
|
|
|
|
|
|
|
$blue * $blue -
|
480
|
|
|
|
|
|
|
$self->{_COLOUR_}->{$cc}->[2] * $self->{_COLOUR_}->{$cc}->[2],
|
481
|
|
|
|
|
|
|
);
|
482
|
|
|
|
|
|
|
|
483
|
0
|
|
|
|
|
|
$value->{$dr+$dg+$db} = $cc;
|
484
|
|
|
|
|
|
|
|
485
|
0
|
|
|
|
|
|
} keys %{$self->{_COLOUR_}};
|
486
|
|
|
|
|
|
|
#
|
487
|
0
|
|
|
|
|
|
my @array = sort {$a<=>$b} keys %$value;
|
|
0
|
|
|
|
|
|
|
488
|
0
|
|
|
|
|
|
my $leastval = shift @array;
|
489
|
0
|
|
|
|
|
|
my $code = $value->{$leastval};
|
490
|
|
|
|
|
|
|
|
491
|
|
|
|
|
|
|
}
|
492
|
|
|
|
|
|
|
|
493
|
|
|
|
|
|
|
=head2 line
|
494
|
|
|
|
|
|
|
|
495
|
|
|
|
|
|
|
Draw a line between 2 points
|
496
|
|
|
|
|
|
|
|
497
|
|
|
|
|
|
|
=cut
|
498
|
|
|
|
|
|
|
|
499
|
|
|
|
|
|
|
sub SVG::GD::Image::line($$$$$$) {
|
500
|
0
|
|
|
0
|
|
|
my $self = shift;
|
501
|
0
|
|
|
|
|
|
my ($x1,$y1,$x2,$y2,$colour) = @_;
|
502
|
|
|
|
|
|
|
# $self->{_GD_}->line(@_);
|
503
|
0
|
|
|
|
|
|
$self->{_SVG_}->line(x1=>$x1,x2=>$x2,y1=>$y1,y2=>$y2,
|
504
|
|
|
|
|
|
|
stroke=>$self->getColour($colour));
|
505
|
|
|
|
|
|
|
}
|
506
|
|
|
|
|
|
|
|
507
|
|
|
|
|
|
|
sub SVG::GD::Image::dashedLine($$$$$$) {
|
508
|
0
|
|
|
0
|
|
|
my $self = shift;
|
509
|
0
|
|
|
|
|
|
my ($x1,$y1,$x2,$y2,$colour) = @_;
|
510
|
|
|
|
|
|
|
# $self->{_GD_}->dashedLine(@_);
|
511
|
0
|
|
|
|
|
|
$self->{_SVG_}->line(x1=>$x1,x2=>$x2,y1=>$y1,y2=>$y2,
|
512
|
|
|
|
|
|
|
stroke=>$self->getColour($colour));
|
513
|
|
|
|
|
|
|
}
|
514
|
|
|
|
|
|
|
|
515
|
|
|
|
|
|
|
=head2 filledRectangle
|
516
|
|
|
|
|
|
|
|
517
|
|
|
|
|
|
|
Draw a filled rectangle.
|
518
|
|
|
|
|
|
|
|
519
|
|
|
|
|
|
|
=cut
|
520
|
|
|
|
|
|
|
|
521
|
|
|
|
|
|
|
sub SVG::GD::Image::filledRectangle($$$$$$$) {
|
522
|
0
|
|
|
0
|
|
|
my $self = shift;
|
523
|
0
|
|
|
|
|
|
my ($x1,$y1,$x2,$y2,$colour) = @_;
|
524
|
|
|
|
|
|
|
# $self->{_GD_}->filledRectangle(@_);
|
525
|
0
|
|
|
|
|
|
$self->{_SVG_}->rect(x=>$x1,y=>$y1,
|
526
|
|
|
|
|
|
|
width=>$x2-$x1,height=>$y2-$y1,
|
527
|
|
|
|
|
|
|
fill=>$self->getColour($colour),
|
528
|
|
|
|
|
|
|
stroke=>$self->getColour($colour));
|
529
|
|
|
|
|
|
|
}
|
530
|
|
|
|
|
|
|
|
531
|
|
|
|
|
|
|
=head2 rectangle
|
532
|
|
|
|
|
|
|
|
533
|
|
|
|
|
|
|
Draw a rectangle.
|
534
|
|
|
|
|
|
|
|
535
|
|
|
|
|
|
|
=cut
|
536
|
|
|
|
|
|
|
|
537
|
|
|
|
|
|
|
sub SVG::GD::Image::rectangle($$$$$$$) {
|
538
|
0
|
|
|
0
|
|
|
my $self = shift;
|
539
|
0
|
|
|
|
|
|
my ($x1,$y1,$x2,$y2,$colour) = @_;
|
540
|
|
|
|
|
|
|
# $self->{_GD_}->rectangle(@_);
|
541
|
0
|
|
|
|
|
|
$self->{_SVG_}->rect(x=>$x1,y=>$y1,
|
542
|
|
|
|
|
|
|
width=>$x2-$x1,height=>$y2-$y1,fill=>'none',
|
543
|
|
|
|
|
|
|
stroke=>$self->getColour($colour));
|
544
|
|
|
|
|
|
|
}
|
545
|
|
|
|
|
|
|
=head2 arc
|
546
|
|
|
|
|
|
|
|
547
|
|
|
|
|
|
|
Draw an arc. Only supports closed arcs at present.
|
548
|
|
|
|
|
|
|
Note that we will ultimately need to differenciate between
|
549
|
|
|
|
|
|
|
an arc and a circle.
|
550
|
|
|
|
|
|
|
|
551
|
|
|
|
|
|
|
=cut
|
552
|
|
|
|
|
|
|
|
553
|
|
|
|
|
|
|
sub SVG::GD::Image::arc($$$$$$$$) {
|
554
|
0
|
|
|
0
|
|
|
my $self = shift;
|
555
|
0
|
|
|
|
|
|
my ($cx,$cy,$width,$height,$start,$end,$colour) = @_;
|
556
|
0
|
|
|
|
|
|
$self->{_SVG_}->ellipse(cx=>$cx,cy=>$cy,
|
557
|
|
|
|
|
|
|
rx=>$width/2,ry=>$height/2,fill=>'none',
|
558
|
|
|
|
|
|
|
stroke=>$self->getColour($colour));
|
559
|
|
|
|
|
|
|
# return $self->{_GD_}->arc(@_);
|
560
|
|
|
|
|
|
|
}
|
561
|
|
|
|
|
|
|
|
562
|
|
|
|
|
|
|
=head2 SVG::GD::Image::filledPolygon
|
563
|
|
|
|
|
|
|
|
564
|
|
|
|
|
|
|
Draw a polygon defined by ab SVG::GD::Polygon object
|
565
|
|
|
|
|
|
|
|
566
|
|
|
|
|
|
|
=cut
|
567
|
|
|
|
|
|
|
|
568
|
|
|
|
|
|
|
sub SVG::GD::Image::filledPolygon ($$$) {
|
569
|
0
|
|
|
0
|
|
|
my $self = shift;
|
570
|
0
|
|
|
|
|
|
my $poly = shift;
|
571
|
0
|
|
|
|
|
|
my $fill = shift;
|
572
|
|
|
|
|
|
|
|
573
|
0
|
|
|
|
|
|
my ($x,$y) = ([],[]);
|
574
|
0
|
|
|
|
|
|
foreach my $set (@{$poly->{points}}) {
|
|
0
|
|
|
|
|
|
|
575
|
0
|
|
|
|
|
|
my ($myx,$myy) = ($set->[0],$set->[1]);
|
576
|
0
|
|
|
|
|
|
push @$x,$myx;
|
577
|
0
|
|
|
|
|
|
push @$y,$myy;
|
578
|
|
|
|
|
|
|
}
|
579
|
0
|
|
|
|
|
|
my $points = $self->{_SVG_}->
|
580
|
|
|
|
|
|
|
get_path(x=>$x, y=>$y,
|
581
|
|
|
|
|
|
|
-type=>'path',
|
582
|
|
|
|
|
|
|
-closed=>'true');
|
583
|
0
|
|
|
|
|
|
$self->{_SVG_}->path(%$points,fill=>$self->getColour($fill));
|
584
|
|
|
|
|
|
|
}
|
585
|
|
|
|
|
|
|
|
586
|
|
|
|
|
|
|
=head2 polygon
|
587
|
|
|
|
|
|
|
|
588
|
|
|
|
|
|
|
Draw an empty polygon
|
589
|
|
|
|
|
|
|
|
590
|
|
|
|
|
|
|
=cut
|
591
|
|
|
|
|
|
|
|
592
|
|
|
|
|
|
|
sub SVG::GD::Image::polygon ($$$) {
|
593
|
0
|
|
|
0
|
|
|
my $self = shift;
|
594
|
0
|
|
|
|
|
|
my $poly = shift;
|
595
|
0
|
|
|
|
|
|
my $stroke = shift;
|
596
|
|
|
|
|
|
|
|
597
|
0
|
|
|
|
|
|
my ($x,$y) = ([],[]);
|
598
|
0
|
|
|
|
|
|
foreach my $set (@{$poly->{points}}) {
|
|
0
|
|
|
|
|
|
|
599
|
0
|
|
|
|
|
|
my ($myx,$myy) = ($set->[0],$set->[1]);
|
600
|
0
|
|
|
|
|
|
push @$x,$myx;
|
601
|
0
|
|
|
|
|
|
push @$y,$myy;
|
602
|
|
|
|
|
|
|
}
|
603
|
0
|
|
|
|
|
|
my $points = $self->{_SVG_}->
|
604
|
|
|
|
|
|
|
get_path(x=>$x, y=>$y,
|
605
|
|
|
|
|
|
|
-type=>'path',
|
606
|
|
|
|
|
|
|
-closed=>'true');
|
607
|
0
|
|
|
|
|
|
$self->{_SVG_}->path(%$points,stroke=>$self->getColour($stroke),fill=>'none');
|
608
|
|
|
|
|
|
|
}
|
609
|
|
|
|
|
|
|
|
610
|
|
|
|
|
|
|
|
611
|
|
|
|
|
|
|
#string methods
|
612
|
|
|
|
|
|
|
|
613
|
|
|
|
|
|
|
=head1 string methods
|
614
|
|
|
|
|
|
|
|
615
|
|
|
|
|
|
|
=head2 string
|
616
|
|
|
|
|
|
|
|
617
|
|
|
|
|
|
|
write a text string
|
618
|
|
|
|
|
|
|
|
619
|
|
|
|
|
|
|
=cut
|
620
|
|
|
|
|
|
|
|
621
|
|
|
|
|
|
|
sub SVG::GD::Image::string ($$$$$$) {
|
622
|
0
|
|
|
0
|
|
|
my $self = shift;
|
623
|
0
|
|
|
|
|
|
my ($myfont,$x,$y,$text,$colour) = @_;
|
624
|
|
|
|
|
|
|
# $self->{_GD_}->string(@_);
|
625
|
0
|
|
|
|
|
|
$self->{_SVG_}->text(
|
626
|
|
|
|
|
|
|
'baseline-shift'=>'sub',
|
627
|
|
|
|
|
|
|
style=>{
|
628
|
|
|
|
|
|
|
SVG::GD::Font::getSVGstyle($myfont),
|
629
|
|
|
|
|
|
|
fill=>$self->getColour($colour),
|
630
|
|
|
|
|
|
|
},
|
631
|
|
|
|
|
|
|
x=>$x,
|
632
|
|
|
|
|
|
|
y=>$y)->tspan(dy=>'1em') ->cdata($text);
|
633
|
|
|
|
|
|
|
}
|
634
|
|
|
|
|
|
|
|
635
|
|
|
|
|
|
|
=head2 char
|
636
|
|
|
|
|
|
|
|
637
|
|
|
|
|
|
|
write a character
|
638
|
|
|
|
|
|
|
|
639
|
|
|
|
|
|
|
=cut
|
640
|
|
|
|
|
|
|
|
641
|
|
|
|
|
|
|
*SVG::GD::Image::char = \&SVG::GD::Image::string;
|
642
|
|
|
|
|
|
|
|
643
|
|
|
|
|
|
|
=head2 charUp
|
644
|
|
|
|
|
|
|
|
645
|
|
|
|
|
|
|
write a character upwards
|
646
|
|
|
|
|
|
|
|
647
|
|
|
|
|
|
|
=cut
|
648
|
|
|
|
|
|
|
|
649
|
|
|
|
|
|
|
sub SVG::GD::Image::stringUp ($$$$$$) {
|
650
|
0
|
|
|
0
|
|
|
my $self = shift;
|
651
|
0
|
|
|
|
|
|
my ($myfont,$x,$y,$text,$colour) = @_;
|
652
|
|
|
|
|
|
|
# $self->{_GD_}->string(@_);
|
653
|
0
|
|
|
|
|
|
$self->{_SVG_}->text(
|
654
|
|
|
|
|
|
|
style=>{'writing-mode'=>'tb',
|
655
|
|
|
|
|
|
|
SVG::GD::Font::getSVGstyle($myfont),
|
656
|
|
|
|
|
|
|
fill=>$self->getColour($colour),
|
657
|
|
|
|
|
|
|
},
|
658
|
|
|
|
|
|
|
x=>$x,y=>$y,
|
659
|
|
|
|
|
|
|
)->cdata($text);
|
660
|
|
|
|
|
|
|
}
|
661
|
|
|
|
|
|
|
*SVG::GD::Image::charUp = \&SVG::GD::Image::stringUp;
|
662
|
|
|
|
|
|
|
|
663
|
|
|
|
|
|
|
#---------------
|
664
|
|
|
|
|
|
|
#internal methods
|
665
|
|
|
|
|
|
|
|
666
|
|
|
|
|
|
|
|
667
|
|
|
|
|
|
|
sub SVG::GD::Image::getRGB($$) {
|
668
|
0
|
|
|
0
|
|
|
my $self = shift;
|
669
|
0
|
|
|
|
|
|
my $colour = shift;
|
670
|
0
|
|
|
|
|
|
return $self->{_COLOUR_}->{$colour}->{rgb};
|
671
|
|
|
|
|
|
|
}
|
672
|
|
|
|
|
|
|
|
673
|
|
|
|
|
|
|
sub SVG::GD::Image::getColour($$) {
|
674
|
0
|
|
|
0
|
|
|
my $self = shift;
|
675
|
0
|
|
|
|
|
|
my $colour = shift;
|
676
|
0
|
|
|
|
|
|
return $self->{_COLOUR_}->{$colour}->{svg};
|
677
|
|
|
|
|
|
|
}
|
678
|
|
|
|
|
|
|
|
679
|
|
|
|
|
|
|
=head2 rgb
|
680
|
|
|
|
|
|
|
|
681
|
|
|
|
|
|
|
Return the red,green,blue array for an allocated colour
|
682
|
|
|
|
|
|
|
|
683
|
|
|
|
|
|
|
=cut
|
684
|
|
|
|
|
|
|
|
685
|
|
|
|
|
|
|
sub SVG::GD::Image::rgb ($$) {
|
686
|
0
|
|
|
0
|
|
|
my $self = shift;
|
687
|
0
|
|
|
|
|
|
my $col = shift;
|
688
|
0
|
|
|
|
|
|
return @{$self->getRBG($col)};
|
|
0
|
|
|
|
|
|
|
689
|
|
|
|
|
|
|
}
|
690
|
|
|
|
|
|
|
|
691
|
|
|
|
|
|
|
=head2 svg
|
692
|
|
|
|
|
|
|
|
693
|
|
|
|
|
|
|
replace the gif writing request with an svg writing request
|
694
|
|
|
|
|
|
|
|
695
|
|
|
|
|
|
|
=cut
|
696
|
|
|
|
|
|
|
|
697
|
|
|
|
|
|
|
sub SVG::GD::Image::svg ($) {
|
698
|
0
|
|
|
0
|
|
|
my $self = shift;
|
699
|
0
|
|
|
|
|
|
return $self->{_SVG_}->xmlify;
|
700
|
|
|
|
|
|
|
}
|
701
|
|
|
|
|
|
|
|
702
|
|
|
|
|
|
|
=head2 png
|
703
|
|
|
|
|
|
|
|
704
|
|
|
|
|
|
|
Return the binary image in PNG format
|
705
|
|
|
|
|
|
|
|
706
|
|
|
|
|
|
|
=cut
|
707
|
|
|
|
|
|
|
|
708
|
|
|
|
|
|
|
sub SVG::GD::Image::png ($) {
|
709
|
0
|
|
|
0
|
|
|
my $self = shift;
|
710
|
0
|
|
|
|
|
|
return $self->svg;
|
711
|
|
|
|
|
|
|
# return $self->{_GD_}->png;
|
712
|
|
|
|
|
|
|
}
|
713
|
|
|
|
|
|
|
|
714
|
|
|
|
|
|
|
=head2 jpg
|
715
|
|
|
|
|
|
|
|
716
|
|
|
|
|
|
|
Return the binary image in JPEG format
|
717
|
|
|
|
|
|
|
|
718
|
|
|
|
|
|
|
=cut
|
719
|
|
|
|
|
|
|
|
720
|
|
|
|
|
|
|
sub SVG::GD::Image::wbmp ($$) {
|
721
|
0
|
|
|
0
|
|
|
my $self = shift;
|
722
|
|
|
|
|
|
|
# return $self->{_GD_}->wbmp(@_);
|
723
|
|
|
|
|
|
|
}
|
724
|
|
|
|
|
|
|
|
725
|
|
|
|
|
|
|
=head2 gif
|
726
|
|
|
|
|
|
|
|
727
|
|
|
|
|
|
|
Return the binary image in GIF format
|
728
|
|
|
|
|
|
|
Note that some versions of SVG::GD do not support this method
|
729
|
|
|
|
|
|
|
|
730
|
|
|
|
|
|
|
=cut
|
731
|
|
|
|
|
|
|
|
732
|
|
|
|
|
|
|
sub SVG::GD::Image::gif ($) {
|
733
|
0
|
|
|
0
|
|
|
my $self = shift;
|
734
|
0
|
|
|
|
|
|
return $self->svg;
|
735
|
|
|
|
|
|
|
}
|
736
|
|
|
|
|
|
|
#------------------
|
737
|
|
|
|
|
|
|
#ignored methods that are meaningless
|
738
|
|
|
|
|
|
|
#or too difficult to implement
|
739
|
|
|
|
|
|
|
|
740
|
|
|
|
|
|
|
|
741
|
|
|
|
|
|
|
sub SVG::GD::Image::interlaced ($) {
|
742
|
0
|
|
|
0
|
|
|
my $self = shift;
|
743
|
|
|
|
|
|
|
# $self->{_GD_}->interlaced(@_);
|
744
|
|
|
|
|
|
|
}
|
745
|
|
|
|
|
|
|
|
746
|
|
|
|
|
|
|
sub SVG::GD::Image::transparent ($$) {
|
747
|
0
|
|
|
0
|
|
|
my $self = shift;
|
748
|
0
|
|
|
|
|
|
my $colour = shift;
|
749
|
|
|
|
|
|
|
# $self->{_GD_}->transparent($colour)
|
750
|
|
|
|
|
|
|
}
|
751
|
|
|
|
|
|
|
|
752
|
|
|
|
|
|
|
sub SVG::GD::Image::fill ($$$$) {
|
753
|
0
|
|
|
0
|
|
|
my $self = shift;
|
754
|
0
|
|
|
|
|
|
my ($x,$y,$colour) = @_;
|
755
|
|
|
|
|
|
|
# $self->{_GD_}->fill(@_);
|
756
|
|
|
|
|
|
|
}
|
757
|
|
|
|
|
|
|
|
758
|
|
|
|
|
|
|
sub SVG::GD::Image::fillToBorder ($$$$) {
|
759
|
0
|
|
|
0
|
|
|
my $self = shift;
|
760
|
0
|
|
|
|
|
|
my ($x,$y,$colour) = @_;
|
761
|
|
|
|
|
|
|
# $self->{_GD_}->fillToBorder(@_);
|
762
|
|
|
|
|
|
|
}
|
763
|
|
|
|
|
|
|
|
764
|
|
|
|
|
|
|
############################################################################
|
765
|
|
|
|
|
|
|
#
|
766
|
|
|
|
|
|
|
# new methods on GD::Image
|
767
|
|
|
|
|
|
|
#
|
768
|
|
|
|
|
|
|
############################################################################
|
769
|
|
|
|
|
|
|
|
770
|
|
|
|
|
|
|
sub SVG::GD::Image::polyline ($$$) {
|
771
|
0
|
|
|
0
|
|
|
my $self = shift; # the GD::Image
|
772
|
0
|
|
|
|
|
|
my $p = shift; # the GD::Polyline (or GD::Polygon)
|
773
|
0
|
|
|
|
|
|
my $c = shift; # the color
|
774
|
|
|
|
|
|
|
|
775
|
0
|
|
|
|
|
|
my @points = $p->vertices();
|
776
|
0
|
|
|
|
|
|
my $p1 = shift @points;
|
777
|
0
|
|
|
|
|
|
my $p2;
|
778
|
0
|
|
|
|
|
|
while ($p2 = shift @points) {
|
779
|
0
|
|
|
|
|
|
$self->line(@$p1, @$p2, $c);
|
780
|
0
|
|
|
|
|
|
$p1 = $p2;
|
781
|
|
|
|
|
|
|
}
|
782
|
|
|
|
|
|
|
}
|
783
|
|
|
|
|
|
|
|
784
|
|
|
|
|
|
|
sub GD::Image::polydraw ($$$) {
|
785
|
0
|
|
|
0
|
|
|
my $self = shift; # the GD::Image
|
786
|
0
|
|
|
|
|
|
my $p = shift; # the GD::Polyline or GD::Polygon
|
787
|
0
|
|
|
|
|
|
my $c = shift;
|
788
|
|
|
|
|
|
|
# the color return
|
789
|
0
|
0
|
|
|
|
|
$self->polyline($p, $c) if $p->isa('GD::Polyline');
|
790
|
0
|
|
|
|
|
|
return $self->polygon($p, $c);
|
791
|
|
|
|
|
|
|
}
|
792
|
|
|
|
|
|
|
|
793
|
|
|
|
|
|
|
sub setBrush ($$) {
|
794
|
0
|
|
|
0
|
|
|
my $self = shift;
|
795
|
0
|
|
|
|
|
|
my $brush = shift;
|
796
|
0
|
|
|
|
|
|
return "Sorry..Ignoring this command. Unable to setBrush with this version
|
797
|
|
|
|
|
|
|
of SVG::GD";
|
798
|
|
|
|
|
|
|
}
|
799
|
|
|
|
|
|
|
|
800
|
|
|
|
|
|
|
|
801
|
|
|
|
|
|
|
|