line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
20
|
|
|
20
|
|
688321
|
use v5.12; |
|
20
|
|
|
|
|
173
|
|
2
|
20
|
|
|
20
|
|
168
|
use warnings; |
|
20
|
|
|
|
|
47
|
|
|
20
|
|
|
|
|
962
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
# utilities for any sub module of the distribution |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
package Graphics::Toolkit::Color::Space::Util; |
7
|
|
|
|
|
|
|
|
8
|
20
|
|
|
20
|
|
147
|
use Exporter 'import'; |
|
20
|
|
|
|
|
50
|
|
|
20
|
|
|
|
|
7123
|
|
9
|
|
|
|
|
|
|
our @EXPORT_OK = qw/round rmod close_enough min max/; |
10
|
|
|
|
|
|
|
our %EXPORT_TAGS = (all => [@EXPORT_OK]); |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
my $half = 0.50000000000008; |
13
|
|
|
|
|
|
|
my $tolerance = 0.00000000000008; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub rgb_to_hue { |
16
|
0
|
|
|
0
|
0
|
0
|
my (@rgb) = @_; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub max { |
21
|
172
|
|
|
172
|
0
|
297
|
my $v = shift; |
22
|
172
|
100
|
|
|
|
352
|
for (@_) { $v = $_ if $v < $_ } |
|
344
|
|
|
|
|
746
|
|
23
|
172
|
|
|
|
|
462
|
$v; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub min { |
27
|
166
|
|
|
166
|
0
|
220
|
my $v = shift; |
28
|
166
|
100
|
|
|
|
249
|
for (@_) { $v = $_ if $v > $_ } |
|
332
|
|
|
|
|
627
|
|
29
|
166
|
|
|
|
|
259
|
$v; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub round { |
33
|
1932
|
100
|
|
1932
|
0
|
6645
|
$_[0] >= 0 ? int ($_[0] + $half) |
34
|
|
|
|
|
|
|
: int ($_[0] - $half) |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
# real value modulo |
38
|
|
|
|
|
|
|
sub rmod { |
39
|
134
|
100
|
100
|
134
|
0
|
457
|
return 0 unless defined $_[1] and $_[1]; |
40
|
131
|
|
|
|
|
475
|
$_[0] - (int($_[0] / $_[1]) * $_[1]); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
74
|
50
|
|
74
|
0
|
17306
|
sub close_enough { abs($_[0] - $_[1]) < 0.008 if defined $_[1]} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
1; |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
# min(floor(val*256),255) |