line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Graphics::Color::YUV; |
2
|
|
|
|
|
|
|
BEGIN { |
3
|
1
|
|
|
1
|
|
26310
|
$Graphics::Color::YUV::VERSION = '0.29'; |
4
|
|
|
|
|
|
|
} |
5
|
1
|
|
|
1
|
|
486
|
use Moose; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
use MooseX::Aliases; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
extends qw(Graphics::Color); |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# ABSTRACT: YUV color space |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
use Graphics::Color::Types qw(NumberOneOrLess); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
has 'luma' => ( |
16
|
|
|
|
|
|
|
is => 'rw', |
17
|
|
|
|
|
|
|
isa => NumberOneOrLess, |
18
|
|
|
|
|
|
|
default => 0, |
19
|
|
|
|
|
|
|
alias => 'y' |
20
|
|
|
|
|
|
|
); |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
has 'blue_luminance' => ( |
24
|
|
|
|
|
|
|
is => 'rw', |
25
|
|
|
|
|
|
|
isa => NumberOneOrLess, |
26
|
|
|
|
|
|
|
default => 0, |
27
|
|
|
|
|
|
|
alias => 'u' |
28
|
|
|
|
|
|
|
); |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
has 'red_luminance' => ( |
32
|
|
|
|
|
|
|
is => 'rw', |
33
|
|
|
|
|
|
|
isa => NumberOneOrLess, |
34
|
|
|
|
|
|
|
default => 0, |
35
|
|
|
|
|
|
|
alias => 'v' |
36
|
|
|
|
|
|
|
); |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
has 'name' => ( is => 'rw', isa => 'Str' ); |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub as_string { |
43
|
|
|
|
|
|
|
my ($self) = @_; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
return sprintf('%s,%s,%s', |
46
|
|
|
|
|
|
|
$self->luma, $self->blue_luminance, $self->red_luminance |
47
|
|
|
|
|
|
|
); |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub as_array { |
52
|
|
|
|
|
|
|
my ($self) = @_; |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
return ($self->luma, $self->blue_luminance, $self->red_luminance); |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub equal_to { |
59
|
|
|
|
|
|
|
my ($self, $other) = @_; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
return 0 unless defined($other); |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
unless($self->luma == $other->luma) { |
64
|
|
|
|
|
|
|
return 0; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
unless($self->blue_luminance == $other->blue_luminance) { |
67
|
|
|
|
|
|
|
return 0; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
unless($self->red_luminance == $other->red_luminance) { |
70
|
|
|
|
|
|
|
return 0; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
return 1; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
# TODO RGB Conversion |
78
|
|
|
|
|
|
|
# OLD STYLE : Y' = 0.299R + 0.587G + 0.114B |
79
|
|
|
|
|
|
|
# NEW STYLE: Y' = 0.2125R + 0.7154G + 0.0721B |
80
|
|
|
|
|
|
|
# U = B - Y' |
81
|
|
|
|
|
|
|
# V = R - Y' |
82
|
|
|
|
|
|
|
# |
83
|
|
|
|
|
|
|
# http://www.fourcc.org/fccyvrgb.php |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
no Moose; |
88
|
|
|
|
|
|
|
1; |
89
|
|
|
|
|
|
|
__END__ |
90
|
|
|
|
|
|
|
=pod |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head1 NAME |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
Graphics::Color::YUV - YUV color space |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head1 VERSION |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
version 0.29 |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head1 SYNOPSIS |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
use Graphics::Color::YUV; |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
my $color = Graphics::Color::YUV->new({ |
105
|
|
|
|
|
|
|
luma => .5, |
106
|
|
|
|
|
|
|
blue_luminance => .5, |
107
|
|
|
|
|
|
|
red_luminance => .25, |
108
|
|
|
|
|
|
|
}); |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head1 DESCRIPTION |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
Graphics::Color::YUV represents a Color in an Y'UV color space. |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head2 luma |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=head2 y |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
Set/Get the luma (Y') component of this Color. Aliased to y. |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head2 blue_luminance |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=head2 u |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
Set/Get the blue_luminance component of this Color. Aliased to u. |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=head2 red_luminance |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=head2 v |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
Set/Get the red_luminance component of this Color. Aliased to v. |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=head1 METHODS |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=head2 name |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
Get the name of this color. Only valid if the color was created by name. |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=head2 as_string |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
Get a string version of this Color in the form of: |
143
|
|
|
|
|
|
|
LUMA,BLUE_LUMINENCE,RED_LUMINANCE |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=head2 as_array |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
Get the YUV values as an array |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=head2 equal_to |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
Compares this color to the provided one. Returns 1 if true, else 0; |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=head2 not_equal_to |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
The opposite of equal_to. |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=head1 AUTHOR |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
Cory G Watson <gphat@cpan.org> |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
This software is copyright (c) 2011 by Cold Hard Code, LLC. |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
166
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=cut |
169
|
|
|
|
|
|
|
|