XYZ.pm

filter: Statementstmt 100% 47 / 47 Branchbran 100% 6 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 17 / 17 Podpod 85.7% 6 / 7 totaltotal 98.7% 76 / 77 CC 4 SCAR 2.6
CC
4
Cov
100%
new
2.0
_from_linear
2.0
_to_linear
2.0
CRAP 1.3
« LUV.pm ↑ Summary HUSLp.pm »
1 package Convert::Color::XYZ;
2  
3 2 ▶use 5.008009;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use parent qw/Convert::Color/;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 2 ▶use Convert::Color::RGB;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 ▶use List::Util qw/sum/;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 2 our $VERSION = '1.000';
12  
13 2 ▶use constant +{ ## no critic (Capitalization)
Subroutine BEGIN: called CC=1 SCAR=0.0
14 2 MAT_R => [ 3.2409699419045214, -1.5373831775700935, -0.49861076029300328 ],
15 MAT_G => [ -0.96924363628087983, 1.8759675015077207, 0.041555057407175613 ],
16 MAT_B => [ 0.055630079696993609, -0.20397695888897657, 1.0569715142428786 ],
17  
18 IMAT_X => [ 0.41239079926595948, 0.35758433938387796, 0.18048078840183429 ],
19 IMAT_Y => [ 0.21263900587151036, 0.71516867876775593, 0.072192315360733715 ],
20 IMAT_Z => [ 0.019330818715591851, 0.11919477979462599, 0.95053215224966058 ],
21 2 };
22  
23 2 __PACKAGE__->register_color_space('xyz');
24  
25 4609 ▶sub new {
Subroutine new: called CC=2 SCAR=6.9
Pod documented
26 4609 my ($class, $x, $y, $z) = @_;
27 4609 ▶ ($x, $y, $z) = split /,/s, $x unless defined $y;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $y 1 4608 4609
28 4609 bless [$x, $y, $z], $class
29 }
30  
31 1 ▶sub X { shift->[0] }
Subroutine X: called CC=1 SCAR=0.0
Pod documented
32 1 ▶sub Y { shift->[1] }
Subroutine Y: called CC=1 SCAR=0.0
Pod documented
33 1 ▶sub Z { shift->[2] }
Subroutine Z: called CC=1 SCAR=0.0
Pod documented
34  
35 1 ▶sub xyz { @{$_[0]} }
Subroutine xyz: called CC=1 SCAR=0.0
Pod documented
36  
37 13824 ▶sub _dot_product {
Subroutine _dot_product: called CC=1 SCAR=0.0
38 13824 my ($x, $y) = @_;
39 13824 sum map { $x->[$_] * $y->[$_] } 0 .. $#{$x}
40 }
41  
42 3072 ▶sub _from_linear {
Subroutine _from_linear: called CC=2 SCAR=6.9
43 3072 my ($c) = @_;
44 3072 ▶ $c <= 0.0031308 ? 12.92 * $c : 1.055 * $c ** (1 / 2.4) - 0.055
Branch: 1 branch
BranchTrueFalseTotal
$c <= 0.0031308 ? : 384 2688 3072
45 }
46  
47 10752 ▶sub _to_linear {
Subroutine _to_linear: called CC=2 SCAR=6.9
48 10752 my ($c) = @_;
49 10752 ▶ $c <= 0.04045 ? $c / 12.92 : (($c + 0.055) / 1.055) ** 2.4
Branch: 1 branch
BranchTrueFalseTotal
$c <= 0.04045 ? : 1344 9408 10752
50 }
51  
52 1024 ▶sub rgb {
Subroutine rgb: called CC=1 SCAR=0.0
Pod documented
53 1024 my ($self) = @_;
54 1024 map { _from_linear _dot_product $_, $self } MAT_R, MAT_G, MAT_B;
55 }
56  
57 3584 ▶sub new_rgb {
Subroutine new_rgb: called CC=1 SCAR=0.0
Pod undocumented
58 3584 my $class = shift;
59 3584 my $vector = [map { _to_linear $_ } @_];
60 3584 $class->new(map { _dot_product $_, $vector } IMAT_X, IMAT_Y, IMAT_Z)
61 }
62  
63 2 1;
64 __END__
« LUV.pm ↑ Summary HUSLp.pm »