File Coverage

lib/Graphics/Toolkit/Color/Space/Instance/DisplayP3Linear.pm
Criterion Covered Total %
statement 15 15 100.0
branch n/a
condition n/a
subroutine 5 5 100.0
pod 0 2 0.0
total 20 22 90.9


line stmt bran cond sub pod time code
1              
2             # Display P3, D65, linear (no transfer)
3              
4             package Graphics::Toolkit::Color::Space::Instance::DisplayP3Linear;
5 16     16   280316 use v5.12;
  16         47  
6 16     16   71 use warnings;
  16         21  
  16         757  
7 16     16   493 use Graphics::Toolkit::Color::Space qw/mult_matrix_vector_3/;
  16         18  
  16         4434  
8              
9             my @D65 = (0.9504559271, 1, 1.0890577508);
10              
11             sub from_p3l {
12 4     4 0 7 my ($lrgb) = shift;
13 4         13 my @xyz = mult_matrix_vector_3([[ 0.4865709486, 0.2656676932, 0.1982172852 ],
14             [ 0.2289745641, 0.6917385218, 0.0792869141 ],
15             [ 0.0000000000, 0.0451133819, 1.0439443689 ], ], @$lrgb);
16 4         20 $xyz[$_] /= $D65[ $_ ] for 0 .. 2;
17 4         10 return \@xyz;
18             }
19             sub to_p3l {
20 4     4 0 7 my ($xyz) = shift;
21 4         15 $xyz->[$_] *= $D65[ $_ ] for 0 .. 2;
22 4         15 return [ mult_matrix_vector_3( [[ 2.4934969119, -0.9313836179, -0.4027107845 ],
23             [ -0.8294889696, 1.7626640603, 0.0236246858 ],
24             [ 0.0358458302, -0.0761723893, 0.9568845240 ], ], @$xyz) ];
25             }
26            
27             Graphics::Toolkit::Color::Space->new(
28             name => 'display-p3-linear',
29             alias_name => 'Linear Display P3',
30             family => 'RGB',
31             axis => [qw/red green blue/],
32             precision => 6,
33             convert => {XYZ => [\&from_p3l, \&to_p3l]},
34             );