line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
20
|
|
|
20
|
|
673513
|
use v5.12; |
|
20
|
|
|
|
|
178
|
|
2
|
20
|
|
|
20
|
|
162
|
use warnings; |
|
20
|
|
|
|
|
40
|
|
|
20
|
|
|
|
|
957
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
# utilities for any sub module of the distribution |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
package Graphics::Toolkit::Color::Space::Util; |
7
|
|
|
|
|
|
|
|
8
|
20
|
|
|
20
|
|
118
|
use Exporter 'import'; |
|
20
|
|
|
|
|
44
|
|
|
20
|
|
|
|
|
6906
|
|
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
|
262
|
my $v = shift; |
22
|
172
|
100
|
|
|
|
365
|
for (@_) { $v = $_ if $v < $_ } |
|
344
|
|
|
|
|
663
|
|
23
|
172
|
|
|
|
|
422
|
$v; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub min { |
27
|
166
|
|
|
166
|
0
|
217
|
my $v = shift; |
28
|
166
|
100
|
|
|
|
234
|
for (@_) { $v = $_ if $v > $_ } |
|
332
|
|
|
|
|
563
|
|
29
|
166
|
|
|
|
|
267
|
$v; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub round { |
33
|
1932
|
100
|
|
1932
|
0
|
6046
|
$_[0] >= 0 ? int ($_[0] + $half) |
34
|
|
|
|
|
|
|
: int ($_[0] - $half) |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
# real value modulo |
38
|
|
|
|
|
|
|
sub rmod { |
39
|
134
|
100
|
100
|
134
|
0
|
469
|
return 0 unless defined $_[1] and $_[1]; |
40
|
131
|
|
|
|
|
413
|
$_[0] - (int($_[0] / $_[1]) * $_[1]); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
74
|
50
|
|
74
|
0
|
18095
|
sub close_enough { abs($_[0] - $_[1]) < 0.008 if defined $_[1]} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
1; |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
# min(floor(val*256),255) |