line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
8
|
|
|
8
|
|
711
|
use v5.12; |
|
8
|
|
|
|
|
24
|
|
2
|
8
|
|
|
8
|
|
43
|
use warnings; |
|
8
|
|
|
|
|
12
|
|
|
8
|
|
|
|
|
401
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
# YIQ color space specific code |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
package Graphics::Toolkit::Color::Space::Instance::YIQ; |
7
|
8
|
|
|
8
|
|
468
|
use Graphics::Toolkit::Color::Space; |
|
8
|
|
|
|
|
33
|
|
|
8
|
|
|
|
|
2545
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
my ($i_max, $q_max) = (0.5959, 0.5227); |
10
|
|
|
|
|
|
|
my ($i_size, $q_size) = (2 * $i_max, 2 * $q_max); |
11
|
|
|
|
|
|
|
# cyan-orange balance, magenta-green balance |
12
|
|
|
|
|
|
|
my $yiq_def = Graphics::Toolkit::Color::Space->new( axis => [qw/luminance in-phase quadrature/], |
13
|
|
|
|
|
|
|
short => [qw/Y I Q/], |
14
|
|
|
|
|
|
|
range => [1, [-$i_max, $i_max], [-$q_max, $q_max]] ); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
$yiq_def->add_converter('RGB', \&to_rgb, \&from_rgb ); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub from_rgb { |
19
|
2
|
|
|
2
|
0
|
6
|
my ($r, $g, $b) = @_; |
20
|
2
|
|
|
|
|
7
|
my $y = (0.299 * $r) + ( 0.587 * $g) + ( 0.114 * $b); |
21
|
2
|
|
|
|
|
4
|
my $i = ($i_max + (0.5959 * $r) + (-0.2746 * $g) + (-0.3213 * $b)) / $i_size; |
22
|
2
|
|
|
|
|
4
|
my $q = ($q_max + (0.2115 * $r) + (-0.5227 * $g) + ( 0.3112 * $b)) / $q_size; |
23
|
2
|
|
|
|
|
10
|
return ($y, $i, $q); |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub to_rgb { |
28
|
2
|
|
|
2
|
0
|
4
|
my ($y, $i, $q) = @_; |
29
|
2
|
|
|
|
|
5
|
$i = ($i * $i_size) - $i_max; |
30
|
2
|
|
|
|
|
3
|
$q = ($q * $q_size) - $q_max; |
31
|
2
|
|
|
|
|
4
|
my $r = $y + ( 0.956 * $i) + ( 0.619 * $q); |
32
|
2
|
|
|
|
|
3
|
my $g = $y + (-0.272 * $i) + (-0.647 * $q); |
33
|
2
|
|
|
|
|
3
|
my $b = $y + (-1.106 * $i) + ( 1.703 * $q); |
34
|
2
|
|
|
|
|
9
|
return ($r, $g, $b); |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
$yiq_def; |