line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package GD::Arrow; |
2
|
|
|
|
|
|
|
# $Id: Arrow.pm,v 1.7 2004/10/25 17:22:27 tcaine Exp $ |
3
|
|
|
|
|
|
|
|
4
|
1
|
|
|
1
|
|
36143
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
47
|
|
5
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
35
|
|
6
|
1
|
|
|
1
|
|
5
|
use vars qw( $VERSION @ISA ); |
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
91
|
|
7
|
1
|
|
|
1
|
|
665
|
use GD; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
$VERSION = '0.01'; |
10
|
|
|
|
|
|
|
@ISA = qw( GD::Polygon ); |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub x1 { shift->{X1} } |
13
|
|
|
|
|
|
|
sub y1 { shift->{Y1} } |
14
|
|
|
|
|
|
|
sub x2 { shift->{X2} } |
15
|
|
|
|
|
|
|
sub y2 { shift->{Y2} } |
16
|
|
|
|
|
|
|
sub width { shift->{WIDTH} } |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
package GD::Arrow::Full; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
use strict; |
21
|
|
|
|
|
|
|
use warnings; |
22
|
|
|
|
|
|
|
use vars qw( $VERSION @ISA ); |
23
|
|
|
|
|
|
|
use Carp; |
24
|
|
|
|
|
|
|
use GD; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
$VERSION = '0.01'; |
27
|
|
|
|
|
|
|
@ISA = qw( GD::Arrow ); |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub new { |
30
|
|
|
|
|
|
|
my $class = shift; |
31
|
|
|
|
|
|
|
my %arg = @_; |
32
|
|
|
|
|
|
|
my ($x1, $y1, $x2, $y2, $width); |
33
|
|
|
|
|
|
|
my $self = $class->SUPER::new(); |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
foreach ( keys %arg ) { |
36
|
|
|
|
|
|
|
if (/^-?X1$/i) { $self->{X1} = $x1 = $arg{$_} } |
37
|
|
|
|
|
|
|
elsif (/^-?Y1$/i) { $self->{Y1} = $y1 = $arg{$_} } |
38
|
|
|
|
|
|
|
elsif (/^-?X2$/i) { $self->{X2} = $x2 = $arg{$_} } |
39
|
|
|
|
|
|
|
elsif (/^-?Y2$/i) { $self->{Y2} = $y2 = $arg{$_} } |
40
|
|
|
|
|
|
|
elsif (/^-?WIDTH$/i) { $self->{WIDTH} = $width = $arg{$_} } |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
$self->{WIDTH} = $width = 6 if !defined($self->{WIDTH}); |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
croak "" . __PACKAGE__ . "->new() requires 4 named parameters" |
46
|
|
|
|
|
|
|
if !defined($self->{X1}) || |
47
|
|
|
|
|
|
|
!defined($self->{Y1}) || |
48
|
|
|
|
|
|
|
!defined($self->{X2}) || |
49
|
|
|
|
|
|
|
!defined($self->{Y2}); |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
my $double_width = $width * 2; |
52
|
|
|
|
|
|
|
my $theta = atan2($y1-$y2,$x1-$x2); |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
$self->addPt( |
55
|
|
|
|
|
|
|
sprintf('%.0f', $x2+$width*sin($theta)), |
56
|
|
|
|
|
|
|
sprintf('%.0f', $y2-$width*cos($theta)) |
57
|
|
|
|
|
|
|
); |
58
|
|
|
|
|
|
|
$self->addPt( |
59
|
|
|
|
|
|
|
sprintf('%.0f', $x2-$width*sin($theta)), |
60
|
|
|
|
|
|
|
sprintf('%.0f', $y2+$width*cos($theta)) |
61
|
|
|
|
|
|
|
); |
62
|
|
|
|
|
|
|
$self->addPt( |
63
|
|
|
|
|
|
|
sprintf('%.0f', $x1-$width*sin($theta)-$double_width*cos($theta)), |
64
|
|
|
|
|
|
|
sprintf('%.0f', $y1-$double_width*sin($theta)+$width*cos($theta)) |
65
|
|
|
|
|
|
|
); |
66
|
|
|
|
|
|
|
$self->addPt( |
67
|
|
|
|
|
|
|
sprintf('%.0f', $x1-$double_width*sin($theta)-$double_width*cos($theta)), |
68
|
|
|
|
|
|
|
sprintf('%.0f', $y1-$double_width*sin($theta)+$double_width*cos($theta)) |
69
|
|
|
|
|
|
|
); |
70
|
|
|
|
|
|
|
$self->addPt($x1,$y1); |
71
|
|
|
|
|
|
|
$self->addPt( |
72
|
|
|
|
|
|
|
sprintf('%.0f', $x1+$double_width*(sin($theta)-cos($theta))), |
73
|
|
|
|
|
|
|
sprintf('%.0f', $y1+$double_width*(-sin($theta)-cos($theta))) |
74
|
|
|
|
|
|
|
); |
75
|
|
|
|
|
|
|
$self->addPt( |
76
|
|
|
|
|
|
|
sprintf('%.0f', $x1+$width*sin($theta)-$double_width*cos($theta)), |
77
|
|
|
|
|
|
|
sprintf('%.0f', $y1-$double_width*sin($theta)-$width*cos($theta)) |
78
|
|
|
|
|
|
|
); |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
return $self; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
package GD::Arrow::LeftHalf; |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
use strict; |
86
|
|
|
|
|
|
|
use warnings; |
87
|
|
|
|
|
|
|
use vars qw( $VERSION @ISA ); |
88
|
|
|
|
|
|
|
use Carp; |
89
|
|
|
|
|
|
|
use GD; |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
$VERSION = '0.01'; |
92
|
|
|
|
|
|
|
@ISA = qw( GD::Arrow ); |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
sub new { |
95
|
|
|
|
|
|
|
my $class = shift; |
96
|
|
|
|
|
|
|
my %arg = @_; |
97
|
|
|
|
|
|
|
my ($x1, $y1, $x2, $y2, $width); |
98
|
|
|
|
|
|
|
my $self = $class->SUPER::new(); |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
foreach ( keys %arg ) { |
101
|
|
|
|
|
|
|
if (/^-?X1$/i) { $self->{X1} = $x1 = $arg{$_} } |
102
|
|
|
|
|
|
|
elsif (/^-?Y1$/i) { $self->{Y1} = $y1 = $arg{$_} } |
103
|
|
|
|
|
|
|
elsif (/^-?X2$/i) { $self->{X2} = $x2 = $arg{$_} } |
104
|
|
|
|
|
|
|
elsif (/^-?Y2$/i) { $self->{Y2} = $y2 = $arg{$_} } |
105
|
|
|
|
|
|
|
elsif (/^-?WIDTH$/i) { $self->{WIDTH} = $width = $arg{$_} } |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
$self->{WIDTH} = $width = 6 if !defined($self->{WIDTH}); |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
croak "" . __PACKAGE__ . "->new() requires 4 named parameters" |
111
|
|
|
|
|
|
|
if !defined($self->{X1}) || |
112
|
|
|
|
|
|
|
!defined($self->{Y1}) || |
113
|
|
|
|
|
|
|
!defined($self->{X2}) || |
114
|
|
|
|
|
|
|
!defined($self->{Y2}); |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
my $double_width = $width * 2; |
117
|
|
|
|
|
|
|
my $theta = atan2($y1-$y2,$x1-$x2); |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
$self->addPt($x2, $y2); |
120
|
|
|
|
|
|
|
$self->addPt( |
121
|
|
|
|
|
|
|
sprintf('%.0f', $x2+$width*sin($theta)), |
122
|
|
|
|
|
|
|
sprintf('%.0f', $y2-$width*cos($theta)) |
123
|
|
|
|
|
|
|
); |
124
|
|
|
|
|
|
|
$self->addPt( |
125
|
|
|
|
|
|
|
sprintf('%.0f', $x1+$width*sin($theta)-$double_width*cos($theta)), |
126
|
|
|
|
|
|
|
sprintf('%.0f', $y1-$double_width*sin($theta)-$width*cos($theta)) |
127
|
|
|
|
|
|
|
); |
128
|
|
|
|
|
|
|
$self->addPt( |
129
|
|
|
|
|
|
|
sprintf('%.0f', $x1+$double_width*(sin($theta)-cos($theta))), |
130
|
|
|
|
|
|
|
sprintf('%.0f', $y1+$double_width*(-sin($theta)-cos($theta))) |
131
|
|
|
|
|
|
|
); |
132
|
|
|
|
|
|
|
$self->addPt($x1,$y1); |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
return $self; |
135
|
|
|
|
|
|
|
} |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
package GD::Arrow::RightHalf; |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
use strict; |
140
|
|
|
|
|
|
|
use warnings; |
141
|
|
|
|
|
|
|
use vars qw( $VERSION @ISA ); |
142
|
|
|
|
|
|
|
use Carp; |
143
|
|
|
|
|
|
|
use GD; |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
$VERSION = '0.01'; |
146
|
|
|
|
|
|
|
@ISA = qw( GD::Arrow ); |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
sub new { |
149
|
|
|
|
|
|
|
my $class = shift; |
150
|
|
|
|
|
|
|
my %arg = @_; |
151
|
|
|
|
|
|
|
my ($x1, $y1, $x2, $y2, $width); |
152
|
|
|
|
|
|
|
my $self = $class->SUPER::new(); |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
foreach ( keys %arg ) { |
155
|
|
|
|
|
|
|
if (/^-?X1$/i) { $self->{X1} = $x1 = $arg{$_} } |
156
|
|
|
|
|
|
|
elsif (/^-?Y1$/i) { $self->{Y1} = $y1 = $arg{$_} } |
157
|
|
|
|
|
|
|
elsif (/^-?X2$/i) { $self->{X2} = $x2 = $arg{$_} } |
158
|
|
|
|
|
|
|
elsif (/^-?Y2$/i) { $self->{Y2} = $y2 = $arg{$_} } |
159
|
|
|
|
|
|
|
elsif (/^-?WIDTH$/i) { $self->{WIDTH} = $width = $arg{$_} } |
160
|
|
|
|
|
|
|
} |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
$self->{WIDTH} = $width = 6 if !defined($self->{WIDTH}); |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
croak "" . __PACKAGE__ . "->new() requires 4 named parameters" |
165
|
|
|
|
|
|
|
if !defined($self->{X1}) || |
166
|
|
|
|
|
|
|
!defined($self->{Y1}) || |
167
|
|
|
|
|
|
|
!defined($self->{X2}) || |
168
|
|
|
|
|
|
|
!defined($self->{Y2}); |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
my $double_width = $width * 2; |
171
|
|
|
|
|
|
|
my $theta = atan2($y1-$y2,$x1-$x2); |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
$self->addPt($x2, $y2); |
174
|
|
|
|
|
|
|
$self->addPt( |
175
|
|
|
|
|
|
|
sprintf('%.0f', $x2-$width*sin($theta)), |
176
|
|
|
|
|
|
|
sprintf('%.0f', $y2+$width*cos($theta)) |
177
|
|
|
|
|
|
|
); |
178
|
|
|
|
|
|
|
$self->addPt( |
179
|
|
|
|
|
|
|
sprintf('%.0f', $x1-$width*sin($theta)-$double_width*cos($theta)), |
180
|
|
|
|
|
|
|
sprintf('%.0f', $y1-$double_width*sin($theta)+$width*cos($theta)) |
181
|
|
|
|
|
|
|
); |
182
|
|
|
|
|
|
|
$self->addPt( |
183
|
|
|
|
|
|
|
sprintf('%.0f', $x1-$double_width*sin($theta)-$double_width*cos($theta)), |
184
|
|
|
|
|
|
|
sprintf('%.0f', $y1-$double_width*sin($theta)+$double_width*cos($theta)) |
185
|
|
|
|
|
|
|
); |
186
|
|
|
|
|
|
|
$self->addPt($x1,$y1); |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
return $self; |
189
|
|
|
|
|
|
|
} |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
1; |
193
|
|
|
|
|
|
|
__END__ |