Color/YIQ.pm

filter: Statementstmt 93.3% 28 / 30 Branchbran 62.5% 5 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod 100% 3 / 3 totaltotal 89.3% 42 / 47 SCAR 16.2
CC
5
Cov
87%
equal_to
5.6
BEGIN
1.0
BEGIN
1.0
CRAP 5.1
« Color/HSL.pm ↑ Summary Color/YUV.pm »
1 package Graphics::Color::YIQ;
2 1 $Graphics::Color::YIQ::VERSION = '0.30';
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: YIQ color space
9  
10  
11 1 has 'luminance' => (
12 is => 'rw',
13 isa => 'Num',
14 default => 1,
15 alias => 'y'
16 );
17  
18  
19 1 has 'in_phase' => (
20 is => 'rw',
21 isa => 'Num',
22 default => 1,
23 alias => 'i'
24 );
25  
26  
27 1 has 'quadrature' => (
28 is => 'rw',
29 isa => 'Num',
30 default => 1,
31 alias => 'q'
32 );
33  
34  
35 1 has 'name' => ( is => 'rw', isa => 'Str' );
36  
37  
38 sub as_string {
39 1 ▶ my ($self) = @_;
Subroutine as_string: called CC=1 SCAR=0.0
Pod documented
40  
41 1 return sprintf('%s,%s,%s',
42 $self->luminance, $self->in_phase, $self->quadrature
43 );
44 }
45  
46  
47 sub as_array {
48 1 ▶ my ($self) = @_;
Subroutine as_array: called CC=1 SCAR=0.0
Pod documented
49  
50 1 return ($self->luminance, $self->in_phase, $self->quadrature);
51 }
52  
53  
54 sub equal_to {
55 2 ▶ my ($self, $other) = @_;
Subroutine equal_to: called CC=5 SCAR=17.3
Pod documented
56  
57 2 ▶ return 0 unless defined($other);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $other 0 2 2
58  
59 2 ▶ unless($self->luminance == $other->luminance) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->luminance == $other->luminance) 0 2 2
60 0 return 0;
61 }
62 2 ▶ unless($self->in_phase == $other->in_phase) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->in_phase == $other->in_phase) 1 1 2
63 1 return 0;
64 }
65 1 ▶ unless($self->quadrature == $other->quadrature) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->quadrature == $other->quadrature) 0 1 1
66 0 return 0;
67 }
68  
69 1 return 1;
70 }
71  
72  
73 1 __PACKAGE__->meta->make_immutable;
74 1 ▶no Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
75 1 1;
76  
77 __END__
78  
79 =pod
80  
81 =head1 NAME
82  
83 Graphics::Color::YIQ - YIQ color space
84  
85 =head1 VERSION
86  
87 version 0.30
88  
89 =head1 SYNOPSIS
90  
91 use Graphics::Color::YIQ;
92  
93 my $color = Graphics::Color::YIQ->new({
94 luminance => 0.5,
95 in_phase => .5,
96 quadrature => .25,
97 });
98  
99 =head1 DESCRIPTION
100  
101 Graphics::Color::YIQ represents a Color in an YIQ color space.
102  
103 =head1 DISCLAIMER
104  
105 I couldn't find clear information on the bounds of each value, so at the
106 moment there are none.
107  
108 =head1 ATTRIBUTES
109  
110 =head2 luminance
111  
112 =head2 y
113  
114 Set/Get the luminance component of this Color.
115  
116 =head2 in_phase
117  
118 =head2 i
119  
120 Set/Get the in_phase component of this Color.
121  
122 =head2 quadrature
123  
124 =head2 q
125  
126 Set/Get the quadrature component of this Color.
127  
128 =head2 name
129  
130 Get the name of this color. Only valid if the color was created by name.
131  
132 =head2 not_equal_to
133  
134 The opposite of equal_to.
135  
136 =head1 METHODS
137  
138 =head2 as_string
139  
140 Get a string version of this Color in the form of
141 LUMINANCE,IN-PHASE,QUADRATURE
142  
143 =head2 as_array
144  
145 Get the YIQ values as an array
146  
147 =head2 equal_to
148  
149 Compares this color to the provided one. Returns 1 if true, else 0;
150  
151 =head1 AUTHOR
152  
153 Cory G Watson <gphat@cpan.org>
154  
155 =head1 COPYRIGHT AND LICENSE
156  
157 This software is copyright (c) 2014 by Cold Hard Code, LLC.
158  
159 This is free software; you can redistribute it and/or modify it under
160 the same terms as the Perl 5 programming language system itself.
161  
162 =cut
« Color/HSL.pm ↑ Summary Color/YUV.pm »