line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Graphics::Color::YUV; |
2
|
|
|
|
|
|
|
$Graphics::Color::YUV::VERSION = '0.30'; |
3
|
1
|
|
|
1
|
|
15622
|
use Moose; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
use MooseX::Aliases; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
extends qw(Graphics::Color); |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
# ABSTRACT: YUV color space |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
use Graphics::Color::Types qw(NumberOneOrLess); |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
has 'luma' => ( |
14
|
|
|
|
|
|
|
is => 'rw', |
15
|
|
|
|
|
|
|
isa => NumberOneOrLess, |
16
|
|
|
|
|
|
|
default => 0, |
17
|
|
|
|
|
|
|
alias => 'y' |
18
|
|
|
|
|
|
|
); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
has 'blue_luminance' => ( |
22
|
|
|
|
|
|
|
is => 'rw', |
23
|
|
|
|
|
|
|
isa => NumberOneOrLess, |
24
|
|
|
|
|
|
|
default => 0, |
25
|
|
|
|
|
|
|
alias => 'u' |
26
|
|
|
|
|
|
|
); |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
has 'red_luminance' => ( |
30
|
|
|
|
|
|
|
is => 'rw', |
31
|
|
|
|
|
|
|
isa => NumberOneOrLess, |
32
|
|
|
|
|
|
|
default => 0, |
33
|
|
|
|
|
|
|
alias => 'v' |
34
|
|
|
|
|
|
|
); |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
has 'name' => ( is => 'rw', isa => 'Str' ); |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub as_string { |
41
|
|
|
|
|
|
|
my ($self) = @_; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
return sprintf('%s,%s,%s', |
44
|
|
|
|
|
|
|
$self->luma, $self->blue_luminance, $self->red_luminance |
45
|
|
|
|
|
|
|
); |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub as_array { |
50
|
|
|
|
|
|
|
my ($self) = @_; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
return ($self->luma, $self->blue_luminance, $self->red_luminance); |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub equal_to { |
57
|
|
|
|
|
|
|
my ($self, $other) = @_; |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
return 0 unless defined($other); |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
unless($self->luma == $other->luma) { |
62
|
|
|
|
|
|
|
return 0; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
unless($self->blue_luminance == $other->blue_luminance) { |
65
|
|
|
|
|
|
|
return 0; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
unless($self->red_luminance == $other->red_luminance) { |
68
|
|
|
|
|
|
|
return 0; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
return 1; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
# TODO RGB Conversion |
76
|
|
|
|
|
|
|
# OLD STYLE : Y' = 0.299R + 0.587G + 0.114B |
77
|
|
|
|
|
|
|
# NEW STYLE: Y' = 0.2125R + 0.7154G + 0.0721B |
78
|
|
|
|
|
|
|
# U = B - Y' |
79
|
|
|
|
|
|
|
# V = R - Y' |
80
|
|
|
|
|
|
|
# |
81
|
|
|
|
|
|
|
# http://www.fourcc.org/fccyvrgb.php |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
no Moose; |
86
|
|
|
|
|
|
|
1; |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
__END__ |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=pod |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head1 NAME |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
Graphics::Color::YUV - YUV color space |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head1 VERSION |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
version 0.30 |
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) 2014 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 |