line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
8
|
|
|
8
|
|
700
|
use v5.12; |
|
8
|
|
|
|
|
28
|
|
2
|
8
|
|
|
8
|
|
40
|
use warnings; |
|
8
|
|
|
|
|
13
|
|
|
8
|
|
|
|
|
357
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
# CMYK color space specific code |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
package Graphics::Toolkit::Color::Space::Instance::CMYK; |
7
|
8
|
|
|
8
|
|
504
|
use Graphics::Toolkit::Color::Space; |
|
8
|
|
|
|
|
15
|
|
|
8
|
|
|
|
|
304
|
|
8
|
8
|
|
|
8
|
|
50
|
use Graphics::Toolkit::Color::Space::Util ':all'; |
|
8
|
|
|
|
|
12
|
|
|
8
|
|
|
|
|
2573
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
my $cmyk_def = Graphics::Toolkit::Color::Space->new( axis => [qw/cyan magenta yellow key/] ); |
11
|
|
|
|
|
|
|
$cmyk_def->add_converter('RGB', \&to_rgb, \&from_rgb ); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub from_rgb { |
14
|
6
|
|
|
6
|
0
|
18
|
my ($r, $g, $b) = @_; |
15
|
6
|
50
|
|
|
|
49
|
return unless defined $b; |
16
|
6
|
|
|
|
|
42
|
my $km = max($r, $g, $b); |
17
|
6
|
50
|
|
|
|
17
|
return (0,0,0,1) unless $km; # prevent / 0 |
18
|
6
|
|
|
|
|
37
|
return ( ($km - $r) / $km, |
19
|
|
|
|
|
|
|
($km - $g) / $km, |
20
|
|
|
|
|
|
|
($km - $b) / $km, |
21
|
|
|
|
|
|
|
1 - $km |
22
|
|
|
|
|
|
|
); |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub to_rgb { |
26
|
3
|
|
|
3
|
0
|
13
|
my ($c, $m, $y, $k) = @_; |
27
|
3
|
|
|
|
|
23
|
return ( (1-$c) * (1-$k) , |
28
|
|
|
|
|
|
|
(1-$m) * (1-$k) , |
29
|
|
|
|
|
|
|
(1-$y) * (1-$k) , |
30
|
|
|
|
|
|
|
); |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
$cmyk_def; |