Color/YUV.pm

filter: Statementstmt 93.9% 31 / 33 Branchbran 62.5% 5 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 7 / 7 Podpod 100% 3 / 3 totaltotal 90.2% 46 / 51 CC 5 SCAR 11.3
CC
5
Cov
88%
equal_to
5.6
BEGIN
1.0
BEGIN
1.0
CRAP 3.1
« Color/YIQ.pm ↑ Summary Color.pm »
1 package Graphics::Color::YUV;
2 1 $Graphics::Color::YUV::VERSION = '0.31';
3 1 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use MooseX::Aliases;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 extends qw(Graphics::Color);
7  
8 # ABSTRACT: YUV color space
9  
10 1 ▶use Graphics::Color::Types qw(NumberOneOrLess);
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12  
13 1 has 'luma' => (
14 is => 'rw',
15 isa => NumberOneOrLess,
16 default => 0,
17 alias => 'y'
18 );
19  
20  
21 1 has 'blue_luminance' => (
22 is => 'rw',
23 isa => NumberOneOrLess,
24 default => 0,
25 alias => 'u'
26 );
27  
28  
29 1 has 'red_luminance' => (
30 is => 'rw',
31 isa => NumberOneOrLess,
32 default => 0,
33 alias => 'v'
34 );
35  
36  
37 1 has 'name' => ( is => 'rw', isa => 'Str' );
38  
39  
40 1 ▶sub as_string {
Subroutine as_string: called CC=1 SCAR=0.0
Pod documented
41 1 my ($self) = @_;
42  
43 1 return sprintf('%s,%s,%s',
44 $self->luma, $self->blue_luminance, $self->red_luminance
45 );
46 }
47  
48  
49 1 ▶sub as_array {
Subroutine as_array: called CC=1 SCAR=0.0
Pod documented
50 1 my ($self) = @_;
51  
52 1 return ($self->luma, $self->blue_luminance, $self->red_luminance);
53 }
54  
55  
56 2 ▶sub equal_to {
Subroutine equal_to: called CC=5 SCAR=17.3
Pod documented
57 2 my ($self, $other) = @_;
58  
59 2 ▶ return 0 unless defined($other);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $other 0 2 2
60  
61 2 ▶ unless($self->luma == $other->luma) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->luma == $other->luma) 1 1 2
62 1 return 0;
63 }
64 1 ▶ unless($self->blue_luminance == $other->blue_luminance) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->blue_luminance == $other->blue_luminance) 0 1 1
65 0 return 0;
66 }
67 1 ▶ unless($self->red_luminance == $other->red_luminance) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->red_luminance == $other->red_luminance) 0 1 1
68 0 return 0;
69 }
70  
71 1 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 1 __PACKAGE__->meta->make_immutable;
84  
85 1 ▶no Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
86 1 1;
87  
88 __END__
« Color/YIQ.pm ↑ Summary Color.pm »