line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
18
|
|
|
18
|
|
535343
|
use v5.12; |
|
18
|
|
|
|
|
153
|
|
2
|
18
|
|
|
18
|
|
152
|
use warnings; |
|
18
|
|
|
|
|
33
|
|
|
18
|
|
|
|
|
839
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
# utilities for any sub module of the distribution |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
package Graphics::Toolkit::Color::Space::Util; |
7
|
|
|
|
|
|
|
|
8
|
18
|
|
|
18
|
|
95
|
use Exporter 'import'; |
|
18
|
|
|
|
|
43
|
|
|
18
|
|
|
|
|
6641
|
|
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
|
179
|
|
|
179
|
0
|
310
|
my $v = shift; |
22
|
179
|
100
|
|
|
|
395
|
for (@_) { $v = $_ if $v < $_ } |
|
358
|
|
|
|
|
727
|
|
23
|
179
|
|
|
|
|
463
|
$v; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub min { |
27
|
173
|
|
|
173
|
0
|
218
|
my $v = shift; |
28
|
173
|
100
|
|
|
|
281
|
for (@_) { $v = $_ if $v > $_ } |
|
346
|
|
|
|
|
644
|
|
29
|
173
|
|
|
|
|
303
|
$v; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub round { |
33
|
1911
|
100
|
|
1911
|
0
|
6371
|
$_[0] >= 0 ? int ($_[0] + $half) |
34
|
|
|
|
|
|
|
: int ($_[0] - $half) |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
# real value modulo |
38
|
|
|
|
|
|
|
sub rmod { |
39
|
122
|
100
|
100
|
122
|
0
|
451
|
return 0 unless defined $_[1] and $_[1]; |
40
|
119
|
|
|
|
|
343
|
$_[0] - (int($_[0] / $_[1]) * $_[1]); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
62
|
50
|
|
62
|
0
|
16408
|
sub close_enough { abs($_[0] - $_[1]) < 0.008 if defined $_[1]} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
1; |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
# min(floor(val*256),255) |