line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package SWF::Builder::ExElement; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
11
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
468
|
|
4
|
2
|
|
|
2
|
|
11
|
use Carp; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
153
|
|
5
|
2
|
|
|
2
|
|
13
|
use SWF::Element; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
724
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
require Exporter; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION="0.05"; |
10
|
|
|
|
|
|
|
@SWF::Builder::ExElement::ISA = ('Exporter'); |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our @EXPORT = ('utf2bin', 'bin2utf', '_round'); |
13
|
|
|
|
|
|
|
*utf2bin = ($]>=5.008) ? \&utf8::encode : sub{}; |
14
|
|
|
|
|
|
|
*bin2utf = ($]>=5.008) ? \&utf8::decode : sub{}; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub _round { |
17
|
480
|
|
|
480
|
|
585
|
my $a=shift; |
18
|
|
|
|
|
|
|
|
19
|
480
|
|
100
|
|
|
874
|
$a||=0; |
20
|
480
|
|
|
|
|
1287
|
return int($a+0.5*($a<=>0)); |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
package SWF::Builder::ExElement::Color; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
SWF::Element::_create_class('_Color', ['RGB','RGBA'], |
26
|
|
|
|
|
|
|
Red => '$UI8', |
27
|
|
|
|
|
|
|
Green => '$UI8', |
28
|
|
|
|
|
|
|
Blue => '$UI8', |
29
|
|
|
|
|
|
|
Alpha => '$UI8', |
30
|
|
|
|
|
|
|
is_alpha => 'Scalar'); |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
@SWF::Builder::ExElement::Color::ISA = ('SWF::Element::_Color'); |
33
|
|
|
|
|
|
|
eval{SWF::Element::RGB->new->pack}; |
34
|
|
|
|
|
|
|
eval{SWF::Element::RGBA->new->pack}; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
use overload |
37
|
|
|
|
|
|
|
'""' => sub { |
38
|
2
|
|
|
2
|
|
5
|
my $self = shift; |
39
|
2
|
|
|
|
|
42
|
sprintf('%2.2X%2.2X%2.2X%2.2X', $self->Red, $self->Green, $self->Blue, $self->Alpha); |
40
|
|
|
|
|
|
|
}, |
41
|
2
|
|
|
2
|
|
15
|
fallback =>1; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
29
|
|
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub element_names { |
44
|
1
|
|
|
1
|
|
144
|
SWF::Element::_Color->element_names; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub element_type { |
48
|
1
|
|
|
1
|
|
23
|
SWF::Element::_Color->element_type($_[1]); |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub pack { |
52
|
5
|
|
|
5
|
|
1250
|
my ($self, $stream) = @_; |
53
|
|
|
|
|
|
|
|
54
|
5
|
100
|
|
|
|
16
|
if ($self->is_alpha) { |
55
|
1
|
|
|
|
|
70
|
$self->SWF::Element::RGBA::pack($stream); |
56
|
|
|
|
|
|
|
} else { |
57
|
4
|
|
|
|
|
155
|
$self->SWF::Element::RGB::pack($stream); |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
##### |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
package SWF::Builder::ExElement::Color::AddColor; |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub _add_color { |
66
|
5
|
|
|
5
|
|
15
|
my $self = shift; |
67
|
5
|
|
|
|
|
10
|
my @param = @_; |
68
|
5
|
|
|
|
|
11
|
my %param; |
69
|
5
|
|
|
|
|
18
|
my @color = qw/Red Green Blue Alpha/; |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
{ |
72
|
5
|
50
|
|
|
|
8
|
if (@param == 1) { |
|
5
|
0
|
|
|
|
18
|
|
73
|
5
|
50
|
|
|
|
38
|
if ($param[0] =~ /^\#?([0-9a-f][0-9a-f]){3,4}$/i) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
74
|
5
|
|
|
|
|
46
|
@param{qw/Red Green Blue Alpha/} = map {oct('0x'.$_)} ($param[0]=~/\#?(..)/g); |
|
16
|
|
|
|
|
63
|
|
75
|
|
|
|
|
|
|
} elsif (ref($param[0]) eq 'ARRAY') { |
76
|
0
|
|
|
|
|
0
|
@param = @{$param[0]}; |
|
0
|
|
|
|
|
0
|
|
77
|
0
|
|
|
|
|
0
|
redo; |
78
|
|
|
|
|
|
|
} elsif (UNIVERSAL::isa($param[0],'SWF::Element::RGB')) { |
79
|
0
|
|
|
|
|
0
|
%param = $param[0]->configure; |
80
|
0
|
|
|
|
|
0
|
delete $param{_is_alpha}; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
} elsif ($param[0] =~ /^\d+$/) { |
83
|
0
|
|
|
|
|
0
|
@param{qw/Red Green Blue Alpha/} = @param; |
84
|
|
|
|
|
|
|
} else { |
85
|
0
|
|
|
|
|
0
|
my %param1 = @param; |
86
|
0
|
|
|
|
|
0
|
@param{qw/Red Green Blue Alpha/} = @param1{qw/Red Green Blue Alpha/}; |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
5
|
100
|
|
|
|
24
|
unless (defined $param{Alpha}) { |
|
|
50
|
|
|
|
|
|
91
|
4
|
|
|
|
|
9
|
$param{Alpha} = 255; |
92
|
|
|
|
|
|
|
} elsif ($param{Alpha} < 255) { |
93
|
1
|
|
|
|
|
5
|
$self->{_is_alpha}->configure(1); |
94
|
|
|
|
|
|
|
} |
95
|
5
|
|
|
|
|
59
|
return SWF::Builder::ExElement::Color->new(%param, is_alpha => $self->{_is_alpha}); |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
sub _init_is_alpha { |
99
|
3
|
|
|
3
|
|
7
|
my ($self, $f) = @_; |
100
|
3
|
|
50
|
|
|
70
|
$f ||= 0; |
101
|
3
|
|
|
|
|
22
|
$self->{_is_alpha} = SWF::Element::Scalar->new($f); |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
#### |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
package SWF::Builder::ExElement::BoundaryRect; |
107
|
|
|
|
|
|
|
@SWF::Builder::ExElement::BoundaryRect::ISA = ('SWF::Element::RECT'); |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
sub new { |
110
|
8
|
|
|
8
|
|
206
|
my $class =shift; |
111
|
8
|
|
|
|
|
163
|
bless [@_], $class; |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
sub Xmin { |
115
|
245
|
|
|
245
|
|
8463
|
my ($self, $v) = @_; |
116
|
245
|
50
|
|
|
|
515
|
if (defined $v) { |
117
|
0
|
|
|
|
|
0
|
$self->[0] = $v; |
118
|
|
|
|
|
|
|
} |
119
|
245
|
|
|
|
|
588
|
$self->[0]; |
120
|
|
|
|
|
|
|
} |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
sub Ymin { |
123
|
0
|
|
|
0
|
|
0
|
my ($self, $v) = @_; |
124
|
0
|
0
|
|
|
|
0
|
if (defined $v) { |
125
|
0
|
|
|
|
|
0
|
$self->[1] = $v; |
126
|
|
|
|
|
|
|
} |
127
|
0
|
|
|
|
|
0
|
$self->[1]; |
128
|
|
|
|
|
|
|
} |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
sub Xmax { |
131
|
0
|
|
|
0
|
|
0
|
my ($self, $v) = @_; |
132
|
0
|
0
|
|
|
|
0
|
if (defined $v) { |
133
|
0
|
|
|
|
|
0
|
$self->[2] = $v; |
134
|
|
|
|
|
|
|
} |
135
|
0
|
|
|
|
|
0
|
$self->[2]; |
136
|
|
|
|
|
|
|
} |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
sub Ymax { |
139
|
0
|
|
|
0
|
|
0
|
my ($self, $v) = @_; |
140
|
0
|
0
|
|
|
|
0
|
if (defined $v) { |
141
|
0
|
|
|
|
|
0
|
$self->[3] = $v; |
142
|
|
|
|
|
|
|
} |
143
|
0
|
|
|
|
|
0
|
$self->[3]; |
144
|
|
|
|
|
|
|
} |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
sub pack { |
147
|
2
|
|
|
2
|
|
447
|
my ($self, $stream) = @_; |
148
|
2
|
|
|
|
|
3
|
my %rect; |
149
|
2
|
|
|
|
|
14
|
@rect{qw/ Xmin Ymin Xmax Ymax /} = @$self; |
150
|
2
|
|
|
|
|
17
|
SWF::Element::RECT->new |
151
|
|
|
|
|
|
|
( Xmin => $self->[0], |
152
|
|
|
|
|
|
|
Ymin => $self->[1], |
153
|
|
|
|
|
|
|
Xmax => $self->[2], |
154
|
|
|
|
|
|
|
Ymax => $self->[3], |
155
|
|
|
|
|
|
|
)->pack($stream); |
156
|
|
|
|
|
|
|
} |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
sub set_boundary { |
159
|
245
|
|
|
245
|
|
366
|
my ($self, $x1, $y1, $x2, $y2)=@_; |
160
|
|
|
|
|
|
|
|
161
|
245
|
100
|
|
|
|
469
|
($x1, $x2) = ($x2, $x1) if $x1 > $x2; |
162
|
245
|
100
|
|
|
|
422
|
($y1, $y2) = ($y2, $y1) if $y1 > $y2; |
163
|
|
|
|
|
|
|
|
164
|
245
|
100
|
|
|
|
515
|
unless (defined($self->Xmin)) { |
165
|
7
|
|
|
|
|
15
|
$self->[0] = $x1; |
166
|
7
|
|
|
|
|
10
|
$self->[2] = $x2; |
167
|
7
|
|
|
|
|
10
|
$self->[1] = $y1; |
168
|
7
|
|
|
|
|
28
|
$self->[3] = $y2; |
169
|
|
|
|
|
|
|
} else { |
170
|
238
|
100
|
|
|
|
466
|
if ($self->[0]>$x1) { |
171
|
1
|
|
|
|
|
3
|
$self->[0] = $x1; |
172
|
|
|
|
|
|
|
} |
173
|
238
|
100
|
|
|
|
2094
|
if ($self->[2]<$x2) { |
174
|
39
|
|
|
|
|
52
|
$self->[2] = $x2; |
175
|
|
|
|
|
|
|
} |
176
|
238
|
100
|
|
|
|
591
|
if ($self->[1]>$y1) { |
177
|
43
|
|
|
|
|
56
|
$self->[1] = $y1; |
178
|
|
|
|
|
|
|
} |
179
|
238
|
100
|
|
|
|
1327
|
if ($self->[3]<$y2) { |
180
|
3
|
|
|
|
|
12
|
$self->[3] = $y2; |
181
|
|
|
|
|
|
|
} |
182
|
|
|
|
|
|
|
} |
183
|
|
|
|
|
|
|
} |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
##### |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
package SWF::Builder::ExElement::MATRIX; |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
@SWF::Builder::ExElement::MATRIX::ISA = ('SWF::Element::MATRIX'); |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
sub moveto { |
192
|
1
|
|
|
1
|
|
2
|
my ($self, $x, $y) = @_; |
193
|
1
|
|
|
|
|
13
|
$self->SUPER::moveto($x*20, $y*20); |
194
|
|
|
|
|
|
|
} |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
*translate = \&moveto; |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
sub _moveto_twips { |
199
|
0
|
|
|
0
|
|
|
shift->SUPER::moveto(@_); |
200
|
|
|
|
|
|
|
} |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
sub init { |
203
|
0
|
|
|
0
|
|
|
my ($m, $p) = @_; |
204
|
|
|
|
|
|
|
|
205
|
0
|
0
|
|
|
|
|
Carp::croak "Invalid matrix option" unless ref($p) eq 'ARRAY'; |
206
|
0
|
|
|
|
|
|
while( my ($com, $param) = splice(@$p, 0, 2) ) { |
207
|
0
|
0
|
|
|
|
|
Carp::croak "Invalid matrix option '$com'" unless $m->can($com); |
208
|
0
|
0
|
|
|
|
|
$m->$com(ref($param) eq 'ARRAY' ? @$param : ($param)); |
209
|
|
|
|
|
|
|
} |
210
|
0
|
|
|
|
|
|
$m; |
211
|
|
|
|
|
|
|
} |
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
1; |
215
|
|
|
|
|
|
|
|