File Coverage

lib/Graphics/Toolkit/Color/Space/Instance/AdobeRGB.pm
Criterion Covered Total %
statement 20 20 100.0
branch n/a
condition n/a
subroutine 5 5 100.0
pod 0 2 0.0
total 25 27 92.5


line stmt bran cond sub pod time code
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 15     15   458681 use v5.12;
  15         65  
6 15     15   104 use warnings;
  15         28  
  15         921  
7 15     15   736 use Graphics::Toolkit::Color::Space qw/gamma_correct mult_matrix_vector_3/;
  15         40  
  15         6900  
8              
9             my @D65 = (.95047, 1, 1.08883);
10             my $gamma = 563/256;
11              
12             sub from_xyz {
13 4     4 0 8 my ($xyz) = [ @{$_[0]} ];
  4         11  
14 4         28 $xyz->[$_] *= $D65[ $_ ] for 0 .. 2;
15 4         20 my @rgb = mult_matrix_vector_3( [[ 2.0413690, -0.5649464, -0.3446944 ],
16             [ -0.9692660, 1.8760108, 0.0415560 ],
17             [ 0.0134474, -0.1183897, 1.0154096 ] ], @$xyz);
18 4         13 return [map {gamma_correct($_, 1 / $gamma)} @rgb];
  12         31  
19             }
20             sub to_xyz {
21 4     4 0 8 my $rgb = shift;
22 4         10 $rgb = [map {gamma_correct($_, $gamma)} @$rgb];
  12         27  
23 4         39 my @xyz = mult_matrix_vector_3( [[ 0.5767309, 0.1855540, 0.1881852 ],
24             [ 0.2973769, 0.6273491, 0.0752741 ],
25             [ 0.0270343, 0.0706872, 0.9911085 ] ], @$rgb);
26 4         30 $xyz[$_] /= $D65[ $_ ] for 0 .. 2;
27 4         17 return \@xyz;
28             }
29            
30             Graphics::Toolkit::Color::Space->new(
31             name => 'AdobeRGB',
32             alias => 'opRGB',
33             axis => [qw/red green blue/],
34             precision => 6,
35             convert => {CIEXYZ => [\&to_xyz, \&from_xyz]},
36             );