| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package SWF::Builder::Gradient; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
8
|
use Carp; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
89
|
|
|
4
|
1
|
|
|
1
|
|
7
|
use SWF::Builder::ExElement; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
445
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
@SWF::Builder::Gradient::ISA = ('SWF::Element::Array::GRADIENT3', 'SWF::Builder::ExElement::Color::AddColor'); |
|
7
|
|
|
|
|
|
|
our $VERSION = "0.02"; |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub new { |
|
10
|
1
|
|
|
1
|
0
|
3
|
my ($class, $is_alpha) = @_; |
|
11
|
|
|
|
|
|
|
|
|
12
|
1
|
|
50
|
|
|
16
|
bless { |
|
13
|
|
|
|
|
|
|
'_is_alpha' => SWF::Element::Scalar->new($is_alpha||0), |
|
14
|
|
|
|
|
|
|
'_gradient' => SWF::Element::Array::GRADIENT3->new, |
|
15
|
|
|
|
|
|
|
}, $class; |
|
16
|
|
|
|
|
|
|
} |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub pack { |
|
19
|
1
|
|
|
1
|
0
|
2
|
my ($self, $stream) = @_; |
|
20
|
1
|
|
|
|
|
11
|
$self->{_gradient}->pack($stream); |
|
21
|
|
|
|
|
|
|
} |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub add_color { |
|
24
|
1
|
|
|
1
|
1
|
65
|
my $self = shift; |
|
25
|
1
|
|
|
|
|
13
|
my $g = $self->{_gradient}; |
|
26
|
|
|
|
|
|
|
|
|
27
|
1
|
|
|
|
|
6
|
while ( my ($ratio, $color) = splice(@_,0, 2) ) { |
|
28
|
2
|
50
|
|
|
|
138
|
croak "Too many gradient records (must be 1 to 8)" if @$g >= 8; |
|
29
|
2
|
|
|
|
|
17
|
push @$g, $g->new_element |
|
30
|
|
|
|
|
|
|
( Color => $self->_add_color($color), |
|
31
|
|
|
|
|
|
|
Ratio => $ratio |
|
32
|
|
|
|
|
|
|
); |
|
33
|
|
|
|
|
|
|
} |
|
34
|
1
|
|
|
|
|
87
|
$self; |
|
35
|
|
|
|
|
|
|
} |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub matrix { |
|
38
|
1
|
|
|
1
|
1
|
127
|
SWF::Builder::Gradient::MATRIX->new; |
|
39
|
|
|
|
|
|
|
} |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
package SWF::Builder::Gradient::MATRIX; |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
@SWF::Builder::Gradient::MATRIX::ISA = ('SWF::Builder::ExElement::MATRIX'); |
|
44
|
|
|
|
|
|
|
|
|
45
|
1
|
|
|
1
|
|
7
|
use Carp; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
602
|
|
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub fit_to_rect { |
|
48
|
1
|
|
|
1
|
|
8
|
my $self = shift; |
|
49
|
1
|
|
|
|
|
3
|
my $mode = shift; |
|
50
|
1
|
|
50
|
|
|
3
|
$mode ||= 'longer'; |
|
51
|
1
|
|
|
|
|
3
|
my @rect = @_; |
|
52
|
1
|
|
|
|
|
2
|
my ($x1, $y1, $x2, $y2, $sx, $sy); |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
{ |
|
55
|
1
|
50
|
|
|
|
11
|
if (@rect == 1) { |
|
|
1
|
50
|
|
|
|
20
|
|
|
56
|
0
|
0
|
|
|
|
0
|
if (ref($param[0]) eq 'ARRAY') { |
|
|
|
0
|
|
|
|
|
|
|
57
|
0
|
|
|
|
|
0
|
@rect = @{$rect[0]}; |
|
|
0
|
|
|
|
|
0
|
|
|
58
|
0
|
|
|
|
|
0
|
redo; |
|
59
|
|
|
|
|
|
|
} elsif (UNIVERSAL::isa($rect[0], 'SWF::Element::RECT')) { |
|
60
|
0
|
|
|
|
|
0
|
($x1, $y1, $x2, $y2) = ($rect[0]->Xmin, $rect[0]->Ymin, $rect[0]->Xmax, $rect[0]->Ymax); |
|
61
|
|
|
|
|
|
|
} |
|
62
|
|
|
|
|
|
|
} elsif ($rect[0]=~/^[XY]m/) { |
|
63
|
0
|
|
|
|
|
0
|
my %rect = @rect; |
|
64
|
0
|
|
|
|
|
0
|
($x1, $y1, $x2, $y2) = @rect{qw/Xmin Ymin Xmax Ymax/}; |
|
65
|
|
|
|
|
|
|
} else { |
|
66
|
1
|
|
|
|
|
3
|
($x1, $y1, $x2, $y2) = @rect; |
|
67
|
|
|
|
|
|
|
} |
|
68
|
|
|
|
|
|
|
} |
|
69
|
1
|
50
|
|
|
|
4
|
croak('Invalid rectangle for fit_to_rect') unless defined $x1; |
|
70
|
|
|
|
|
|
|
|
|
71
|
1
|
|
|
|
|
4
|
$sx = ($x2 - $x1)*20/32768; |
|
72
|
1
|
|
|
|
|
10
|
$sy = ($y2 - $y1)*20/32768; |
|
73
|
1
|
|
|
|
|
4
|
for ($mode) { |
|
74
|
1
|
50
|
|
|
|
6
|
/^fit$/ and do { |
|
75
|
0
|
|
|
|
|
0
|
$self->scale($sx,$sy); |
|
76
|
0
|
|
|
|
|
0
|
last; |
|
77
|
|
|
|
|
|
|
}; |
|
78
|
1
|
50
|
|
|
|
4
|
/^width$/ and do { |
|
79
|
0
|
|
|
|
|
0
|
$self->scale($sx); |
|
80
|
0
|
|
|
|
|
0
|
last; |
|
81
|
|
|
|
|
|
|
}; |
|
82
|
1
|
50
|
|
|
|
6
|
/^height$/ and do { |
|
83
|
0
|
|
|
|
|
0
|
$self->scale($sy); |
|
84
|
0
|
|
|
|
|
0
|
last; |
|
85
|
|
|
|
|
|
|
}; |
|
86
|
1
|
50
|
|
|
|
12
|
/^longer$/ and do { |
|
87
|
1
|
50
|
|
|
|
16
|
$self->scale(($sx>=$sy)?$sx:$sy); |
|
88
|
1
|
|
|
|
|
43
|
last; |
|
89
|
|
|
|
|
|
|
}; |
|
90
|
0
|
0
|
|
|
|
0
|
/^shorter$/ and do { |
|
91
|
0
|
0
|
|
|
|
0
|
$self->scale(($sx>=$sy)?$sy:$sx); |
|
92
|
0
|
|
|
|
|
0
|
last; |
|
93
|
|
|
|
|
|
|
}; |
|
94
|
|
|
|
|
|
|
} |
|
95
|
1
|
|
|
|
|
13
|
$self->moveto(($x1+$x2)/2, ($y1+$y2)/2); # /2*20 |
|
96
|
1
|
|
|
|
|
38
|
$self; |
|
97
|
|
|
|
|
|
|
} |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
1; |
|
100
|
|
|
|
|
|
|
__END__ |