| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# Copyright 2010, 2011, 2012 Kevin Ryde |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# This file is part of Image-Base-Other. |
|
4
|
|
|
|
|
|
|
# |
|
5
|
|
|
|
|
|
|
# Image-Base-Other is free software; you can redistribute it and/or modify |
|
6
|
|
|
|
|
|
|
# it under the terms of the GNU General Public License as published by the |
|
7
|
|
|
|
|
|
|
# Free Software Foundation; either version 3, or (at your option) any later |
|
8
|
|
|
|
|
|
|
# version. |
|
9
|
|
|
|
|
|
|
# |
|
10
|
|
|
|
|
|
|
# Image-Base-Other is distributed in the hope that it will be useful, but |
|
11
|
|
|
|
|
|
|
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY |
|
12
|
|
|
|
|
|
|
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
13
|
|
|
|
|
|
|
# for more details. |
|
14
|
|
|
|
|
|
|
# |
|
15
|
|
|
|
|
|
|
# You should have received a copy of the GNU General Public License along |
|
16
|
|
|
|
|
|
|
# with Image-Base-Other. If not, see . |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
package Image::Base::Multiplex; |
|
20
|
2
|
|
|
2
|
|
1469
|
use 5.004; |
|
|
2
|
|
|
|
|
6
|
|
|
|
2
|
|
|
|
|
75
|
|
|
21
|
2
|
|
|
2
|
|
10
|
use strict; |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
60
|
|
|
22
|
2
|
|
|
2
|
|
12
|
use Carp; |
|
|
2
|
|
|
|
|
7
|
|
|
|
2
|
|
|
|
|
170
|
|
|
23
|
2
|
|
|
2
|
|
10
|
use vars '$VERSION', '@ISA'; |
|
|
2
|
|
|
|
|
2
|
|
|
|
2
|
|
|
|
|
138
|
|
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
$VERSION = 9; |
|
26
|
|
|
|
|
|
|
|
|
27
|
2
|
|
|
2
|
|
2067
|
use Image::Base; |
|
|
2
|
|
|
|
|
4176
|
|
|
|
2
|
|
|
|
|
1796
|
|
|
28
|
|
|
|
|
|
|
@ISA = ('Image::Base'); |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
# uncomment this to run the ### lines |
|
31
|
|
|
|
|
|
|
#use Smart::Comments; |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub new { |
|
35
|
6
|
|
|
6
|
1
|
1901
|
my $class = shift; |
|
36
|
|
|
|
|
|
|
|
|
37
|
6
|
50
|
|
|
|
21
|
if (ref $class) { |
|
38
|
|
|
|
|
|
|
# clone by copying fields, don't think need to copy images array |
|
39
|
0
|
|
|
|
|
0
|
return bless { %$class }, $class; |
|
40
|
|
|
|
|
|
|
} |
|
41
|
|
|
|
|
|
|
|
|
42
|
6
|
|
|
|
|
38
|
return bless { -images => [], |
|
43
|
|
|
|
|
|
|
@_ }, $class; |
|
44
|
|
|
|
|
|
|
} |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub _get { |
|
47
|
1153
|
|
|
1153
|
|
57373
|
my ($self, $key) = @_; |
|
48
|
|
|
|
|
|
|
# ### Image-Base-Multiplex _get(): $key |
|
49
|
1153
|
100
|
|
|
|
2082
|
if ($key eq '-images') { |
|
50
|
3
|
|
|
|
|
17
|
return $self->SUPER::_get($key); |
|
51
|
|
|
|
|
|
|
} else { |
|
52
|
1150
|
|
50
|
|
|
2783
|
my $image = $self->{'-images'}->[0] || return undef; |
|
53
|
1150
|
|
|
|
|
2700
|
return $image->get($key); |
|
54
|
|
|
|
|
|
|
} |
|
55
|
|
|
|
|
|
|
} |
|
56
|
|
|
|
|
|
|
sub set { |
|
57
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
|
58
|
|
|
|
|
|
|
# ### Image-Base-Multiplex set() |
|
59
|
|
|
|
|
|
|
|
|
60
|
0
|
|
|
|
|
0
|
my $set_file; |
|
61
|
0
|
|
|
|
|
0
|
for (my $i = 0; $i < @_; ) { |
|
62
|
0
|
|
|
|
|
0
|
my $key = $_[$i]; |
|
63
|
0
|
|
|
|
|
0
|
$set_file = ($key eq '-file'); |
|
64
|
0
|
0
|
|
|
|
0
|
if ($key eq '-images') { |
|
65
|
0
|
|
|
|
|
0
|
$self->{$key} = $_[$i+1]; |
|
66
|
0
|
|
|
|
|
0
|
splice @_, $i, 2; |
|
67
|
|
|
|
|
|
|
} else { |
|
68
|
0
|
|
|
|
|
0
|
$i += 2 |
|
69
|
|
|
|
|
|
|
} |
|
70
|
|
|
|
|
|
|
} |
|
71
|
|
|
|
|
|
|
|
|
72
|
0
|
|
|
|
|
0
|
my $images = $self->{'-images'}; |
|
73
|
0
|
0
|
0
|
|
|
0
|
if ($set_file && @$images > 1) { |
|
74
|
0
|
|
|
|
|
0
|
croak 'Refusing to set multiple images to same -file'; |
|
75
|
|
|
|
|
|
|
} |
|
76
|
|
|
|
|
|
|
|
|
77
|
0
|
|
|
|
|
0
|
foreach my $image (@$images) { |
|
78
|
0
|
|
|
|
|
0
|
$image->set(@_); |
|
79
|
|
|
|
|
|
|
} |
|
80
|
|
|
|
|
|
|
} |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub load { |
|
83
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
|
84
|
0
|
|
|
|
|
0
|
my $images = $self->{'-images'}; |
|
85
|
0
|
0
|
0
|
|
|
0
|
if (@_ && @$images > 1) { |
|
86
|
0
|
|
|
|
|
0
|
croak 'Refusing to load multiple images from one file'; |
|
87
|
|
|
|
|
|
|
} |
|
88
|
0
|
|
|
|
|
0
|
foreach my $image (@$images) { $image->load; } |
|
|
0
|
|
|
|
|
0
|
|
|
89
|
|
|
|
|
|
|
} |
|
90
|
|
|
|
|
|
|
sub save { |
|
91
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
|
92
|
0
|
|
|
|
|
0
|
my $images = $self->{'-images'}; |
|
93
|
0
|
0
|
0
|
|
|
0
|
if (@_ && @$images > 1) { |
|
94
|
0
|
|
|
|
|
0
|
croak 'Refusing to save multiple images to one file'; |
|
95
|
|
|
|
|
|
|
} |
|
96
|
0
|
|
|
|
|
0
|
foreach my $image (@$images) { $image->save; } |
|
|
0
|
|
|
|
|
0
|
|
|
97
|
|
|
|
|
|
|
} |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
sub xy { |
|
100
|
2914
|
|
|
2914
|
1
|
159809
|
my $self = shift; |
|
101
|
|
|
|
|
|
|
### Image-Base-Multiplex xy(): @_[1..$#_] |
|
102
|
2914
|
|
|
|
|
4122
|
my $images = $self->{'-images'}; |
|
103
|
2914
|
100
|
|
|
|
5125
|
if (@_ > 2) { |
|
104
|
8
|
|
|
|
|
13
|
foreach my $image (@$images) { $image->xy(@_); } |
|
|
9
|
|
|
|
|
27
|
|
|
105
|
|
|
|
|
|
|
} else { |
|
106
|
2906
|
|
|
|
|
3618
|
my ($x, $y) = @_; |
|
107
|
2906
|
|
50
|
|
|
5792
|
my $image = $images->[0] || return undef; |
|
108
|
2906
|
|
|
|
|
6957
|
return $image->xy($x,$y); |
|
109
|
|
|
|
|
|
|
} |
|
110
|
|
|
|
|
|
|
} |
|
111
|
|
|
|
|
|
|
sub line { |
|
112
|
26
|
|
|
26
|
1
|
121
|
foreach my $image (@{shift->{'-images'}}) { $image->line(@_); } |
|
|
26
|
|
|
|
|
59
|
|
|
|
26
|
|
|
|
|
86
|
|
|
113
|
|
|
|
|
|
|
} |
|
114
|
|
|
|
|
|
|
sub rectangle { |
|
115
|
136
|
|
|
136
|
1
|
10885
|
foreach my $image (@{shift->{'-images'}}) { $image->rectangle(@_); } |
|
|
136
|
|
|
|
|
302
|
|
|
|
136
|
|
|
|
|
429
|
|
|
116
|
|
|
|
|
|
|
} |
|
117
|
|
|
|
|
|
|
sub ellipse { |
|
118
|
26
|
|
|
26
|
1
|
148
|
foreach my $image (@{shift->{'-images'}}) { $image->ellipse(@_); } |
|
|
26
|
|
|
|
|
53
|
|
|
|
26
|
|
|
|
|
90
|
|
|
119
|
|
|
|
|
|
|
} |
|
120
|
|
|
|
|
|
|
sub diamond { |
|
121
|
0
|
|
|
0
|
1
|
0
|
foreach my $image (@{shift->{'-images'}}) { $image->diamond(@_); } |
|
|
0
|
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
0
|
|
|
122
|
|
|
|
|
|
|
} |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
sub add_colours { |
|
125
|
3
|
|
|
3
|
1
|
209
|
foreach my $image (@{shift->{'-images'}}) { |
|
|
3
|
|
|
|
|
9
|
|
|
126
|
3
|
50
|
|
|
|
24
|
if (my $coderef = $image->can('add_colours')) { |
|
127
|
3
|
|
|
|
|
644
|
$image->$coderef(@_); |
|
128
|
|
|
|
|
|
|
} |
|
129
|
|
|
|
|
|
|
} |
|
130
|
|
|
|
|
|
|
} |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
sub Image_Base_Other_xy_points { |
|
133
|
|
|
|
|
|
|
### Multiplex xy_points |
|
134
|
0
|
|
|
0
|
0
|
0
|
foreach my $image (@{shift->{'-images'}}) { |
|
|
0
|
|
|
|
|
0
|
|
|
135
|
0
|
0
|
|
|
|
0
|
if (my $coderef = $image->can('Image_Base_Other_xy_points')) { |
|
136
|
0
|
|
|
|
|
0
|
$image->$coderef(@_); |
|
137
|
|
|
|
|
|
|
} else { |
|
138
|
0
|
|
|
|
|
0
|
for (my $i = 1; $i < @_; $i += 2) { |
|
139
|
0
|
|
|
|
|
0
|
$image->xy ($_[$i], $_[$i+1], |
|
140
|
|
|
|
|
|
|
$_[0]); # colour |
|
141
|
|
|
|
|
|
|
} |
|
142
|
|
|
|
|
|
|
} |
|
143
|
|
|
|
|
|
|
} |
|
144
|
|
|
|
|
|
|
} |
|
145
|
|
|
|
|
|
|
sub Image_Base_Other_rectangles { |
|
146
|
|
|
|
|
|
|
### Multiplex rectangles |
|
147
|
32
|
|
|
32
|
0
|
334
|
foreach my $image (@{shift->{'-images'}}) { |
|
|
32
|
|
|
|
|
61
|
|
|
148
|
32
|
50
|
|
|
|
103
|
if (my $coderef = $image->can('Image_Base_Other_rectangles')) { |
|
149
|
0
|
|
|
|
|
0
|
$image->$coderef(@_); |
|
150
|
|
|
|
|
|
|
} else { |
|
151
|
32
|
|
|
|
|
74
|
for (my $i = 2; $i < @_; $i += 4) { |
|
152
|
|
|
|
|
|
|
### rect: @_[$i .. $i+3], $_[0], $_[1] |
|
153
|
32
|
|
|
|
|
109
|
$image->rectangle (@_[$i .. $i+3], |
|
154
|
|
|
|
|
|
|
$_[0], # colour |
|
155
|
|
|
|
|
|
|
$_[1]); # fill |
|
156
|
|
|
|
|
|
|
} |
|
157
|
|
|
|
|
|
|
} |
|
158
|
|
|
|
|
|
|
} |
|
159
|
|
|
|
|
|
|
} |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
1; |
|
162
|
|
|
|
|
|
|
__END__ |