File Coverage

lib/Graphics/Toolkit/Color/Space/Instance/Rec709.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             # Rec.709 illuminant D65, 2° standard observer
3              
4             package Graphics::Toolkit::Color::Space::Instance::Rec709;
5 16     16   254650 use v5.12;
  16         54  
6 16     16   70 use warnings;
  16         17  
  16         811  
7 16     16   422 use Graphics::Toolkit::Color::Space qw/spow/;
  16         86  
  16         3629  
8              
9             sub from_lrgb {
10 4     4 0 5 my $lrgb = shift;
11 4 100       5 return [ map {(abs($_) < 0.018) ? ($_ * 4.5) : ((spow($_, 0.45) * 1.099) - 0.099)} @$lrgb];
  12         45  
12             }
13             sub to_lrgb {
14 4     4 0 5 my $rgb = shift;
15 4 100       4 return [ map {(abs($_) < 0.081) ? ($_ / 4.5) : spow(($_ + 0.099) / 1.099, 1 / 0.45)} @$rgb];
  12         29  
16              
17             }
18            
19             Graphics::Toolkit::Color::Space->new(
20             name => 'Rec.709',
21             alias_name => 'BT.709',
22             family => 'RGB',
23             axis => [qw/red green blue/],
24             precision => 6,
25             convert => {LinearRGB => [\&to_lrgb, \&from_lrgb]},
26             );