Color/Space/Instance/AdobeRGB.pm

filter: Statementstmt 100% 23 / 23 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod 0.0% 0 / 2 totaltotal 93.3% 28 / 30 CC 3 SCAR 4.5
CC
3
Cov
100%
from_rgb
2.0
to_rgb
2.0
BEGIN
1.0
CRAP 1.6
« Color/Space/Instance/RGBLinear.pm ↑ Summary Color/Space/Instance/AppleRGB.pm »
1  
2 # Adobe RGB (1998) color space, D65 IEC 61966-2-5:2007, ISO 12640-4:2011
3  
4 package Graphics::Toolkit::Color::Space::Instance::AdobeRGB;
5 16 ▶use v5.12;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 16 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 16 ▶use Graphics::Toolkit::Color::Space qw/spow mult_matrix_vector_3/;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 16 my @D65 = (.95047, 1, 1.08883);
10 16 my $gamma = 563/256;
11  
12 4 ▶sub from_rgb {
Subroutine from_rgb: called CC=2 SCAR=6.9
Pod undocumented
13 4 my $rgb = shift;
14 4 $rgb = [map {spow($_, $gamma)} @$rgb];
15 4 my @xyz = mult_matrix_vector_3( [[ 0.5767309, 0.1855540, 0.1881852 ],
16 [ 0.2973769, 0.6273491, 0.0752741 ],
17 [ 0.0270343, 0.0706872, 0.9911085 ] ], @$rgb);
18 4 $xyz[$_] /= $D65[ $_ ] for 0 .. 2;
19 4 return \@xyz;
20 }
21 4 ▶sub to_rgb {
Subroutine to_rgb: called CC=2 SCAR=6.9
Pod undocumented
22 4 my ($xyz) = [ @{$_[0]} ];
23 4 $xyz->[$_] *= $D65[ $_ ] for 0 .. 2;
24 4 my @rgb = mult_matrix_vector_3( [[ 2.0413690, -0.5649464, -0.3446944 ],
25 [ -0.9692660, 1.8760108, 0.0415560 ],
26 [ 0.0134474, -0.1183897, 1.0154096 ] ], @$xyz);
27 4 return [map {spow($_, 1 / $gamma)} @rgb];
28 }
29
30 16 Graphics::Toolkit::Color::Space->new(
31 name => 'AdobeRGB',
32 alias_name => 'opRGB',
33 family => 'RGB',
34 axis => [qw/red green blue/],
35 precision => 6,
36 convert => {CIEXYZ => [\&from_rgb, \&to_rgb]},
37 );
« Color/Space/Instance/RGBLinear.pm ↑ Summary Color/Space/Instance/AppleRGB.pm »