line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
10
|
|
|
10
|
|
1805
|
use v5.12; |
|
10
|
|
|
|
|
33
|
|
2
|
10
|
|
|
10
|
|
53
|
use warnings; |
|
10
|
|
|
|
|
14
|
|
|
10
|
|
|
|
|
408
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
# YIQ color space specific code |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
package Graphics::Toolkit::Color::Space::Instance::YIQ; |
7
|
10
|
|
|
10
|
|
1280
|
use Graphics::Toolkit::Color::Space; |
|
10
|
|
|
|
|
33
|
|
|
10
|
|
|
|
|
2930
|
|
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
|
6
|
|
|
6
|
0
|
16
|
my ($r, $g, $b) = @_; |
20
|
6
|
|
|
|
|
20
|
my $y = (0.299 * $r) + ( 0.587 * $g) + ( 0.114 * $b); |
21
|
6
|
|
|
|
|
14
|
my $i = ($i_max + (0.5959 * $r) + (-0.2746 * $g) + (-0.3213 * $b)) / $i_size; |
22
|
6
|
|
|
|
|
12
|
my $q = ($q_max + (0.2115 * $r) + (-0.5227 * $g) + ( 0.3112 * $b)) / $q_size; |
23
|
6
|
|
|
|
|
32
|
return ($y, $i, $q); |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub to_rgb { |
28
|
6
|
|
|
6
|
0
|
14
|
my ($y, $i, $q) = @_; |
29
|
6
|
|
|
|
|
15
|
$i = ($i * $i_size) - $i_max; |
30
|
6
|
|
|
|
|
9
|
$q = ($q * $q_size) - $q_max; |
31
|
6
|
|
|
|
|
13
|
my $r = $y + ( 0.956 * $i) + ( 0.619 * $q); |
32
|
6
|
|
|
|
|
9
|
my $g = $y + (-0.272 * $i) + (-0.647 * $q); |
33
|
6
|
|
|
|
|
13
|
my $b = $y + (-1.106 * $i) + ( 1.703 * $q); |
34
|
6
|
|
|
|
|
28
|
return ($r, $g, $b); |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
$yiq_def; |