Color/Space/Instance/YIQ.pm

filter: Statementstmt 100% 20 / 20 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod 0.0% 0 / 2 totaltotal 92.5% 25 / 27 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« Color/Space/Instance/YPbPr.pm ↑ Summary Color/Space/Instance/CMY.pm »
1  
2 # YIQ color space specific code
3  
4 package Graphics::Toolkit::Color::Space::Instance::YIQ;
5 16 ▶use v5.12;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 16 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 16 ▶use Graphics::Toolkit::Color::Space qw/mult_matrix_vector_3/;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 16 my ($i_max, $q_max) = (0.5959, 0.5227);
10 16 my ($i_range_size, $q_range_size) = (2 * $i_max, 2 * $q_max);
11 # cyan-orange balance, magenta-green balance
12 5 ▶sub from_yiq {
Subroutine from_yiq: called CC=1 SCAR=0.0
Pod undocumented
13 5 my ($yiq) = shift;
14 5 $yiq->[1] = $yiq->[1] * $i_range_size - $i_max;
15 5 $yiq->[2] = $yiq->[2] * $q_range_size - $q_max;
16 5 return [ mult_matrix_vector_3([[1, 0.95605, 0.620755],
17 [1, -0.272052, -0.647206],
18 [1, -1.1067, 1.70442 ]], @$yiq) ];
19 }
20 4 ▶sub to_yiq {
Subroutine to_yiq: called CC=1 SCAR=0.0
Pod undocumented
21 4 my ($rgb) = shift;
22 4 my ($y, $i, $q) = mult_matrix_vector_3([[0.299, 0.587, 0.114 ],
23 [0.5959, -0.2746, -0.3213],
24 [0.2115, -0.5227, 0.3112]], @$rgb);
25 4 $i = ($i + $i_max) / $i_range_size;
26 4 $q = ($q + $q_max) / $q_range_size;
27 4 return [$y, $i, $q];
28 }
29  
30 16 Graphics::Toolkit::Color::Space->new(
31 family => 'LAB',
32 axis => [qw/luminance in_phase quadrature/],
33 short => [qw/Y I Q/],
34 role => [qw/l a b/],
35 range => [1, [-$i_max, $i_max], [-$q_max, $q_max]],
36 convert => {RGB => [\&from_yiq, \&to_yiq]},
37 );
« Color/Space/Instance/YPbPr.pm ↑ Summary Color/Space/Instance/CMY.pm »