File Coverage

lib/Graphics/Toolkit/Color/Space/Instance/DisplayP3.pm
Criterion Covered Total %
statement 14 14 100.0
branch 4 4 100.0
condition n/a
subroutine 5 5 100.0
pod 0 2 0.0
total 23 25 92.0


line stmt bran cond sub pod time code
1              
2             # Display P3, D65 same transfer function as SRGB
3              
4             package Graphics::Toolkit::Color::Space::Instance::DisplayP3;
5 16     16   265512 use v5.12;
  16         50  
6 16     16   66 use warnings;
  16         24  
  16         706  
7 16     16   484 use Graphics::Toolkit::Color::Space qw/spow/;
  16         22  
  16         3953  
8              
9             my $gamma = 2.4;
10              
11             sub from_p3 {
12 4     4 0 4 my ($rgb) = shift;
13 4 100       7 return [ map { (abs($_) > 0.04045) ? spow((($_ + 0.055) / 1.055 ), $gamma)
  12         29  
14             : ($_ / 12.92) } @$rgb ];
15             }
16             sub to_p3 {
17 4     4 0 5 my ($lrgb) = shift;
18 4 100       6 return [ map { (abs($_) > 0.0031308) ? ( (spow($_, 1/$gamma) * 1.055) - 0.055)
  12         30  
19             : ($_ * 12.92) } @$lrgb ];
20             }
21            
22             Graphics::Toolkit::Color::Space->new(
23             name => 'display-p3',
24             alias_name => 'P3',
25             family => 'RGB',
26             axis => [qw/red green blue/],
27             precision => 6,
28             convert => {'Display-P3-Linear' => [\&from_p3, \&to_p3]},
29             );