Color/CMYK.pm

filter: Statementstmt 92.6% 38 / 41 Branchbran 60.0% 6 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 9 / 9 Podpod 100% 4 / 4 totaltotal 89.0% 57 / 64 CC 6 SCAR 13.1
CC
6
Cov
86%
equal_to
7.3
BEGIN
1.0
BEGIN
1.0
CRAP 3.7
« Color/RGB.pm ↑ Summary Color/HSL.pm »
1 package Graphics::Color::CMYK;
2 1 $Graphics::Color::CMYK::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: CMYK color model
9  
10 1 ▶use Graphics::Color::Types qw(Number360OrLess NumberOneOrLess);
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use Graphics::Color::RGB;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13  
14 1 has 'cyan' => (
15 is => 'rw',
16 isa => NumberOneOrLess,
17 default => 1,
18 alias => 'c'
19 );
20  
21  
22 1 has 'magenta' => (
23 is => 'rw',
24 isa => NumberOneOrLess,
25 default => 1,
26 alias => 'm'
27 );
28  
29  
30 1 has 'yellow' => (
31 is => 'rw',
32 isa => NumberOneOrLess,
33 default => 1,
34 alias => 'y'
35 );
36  
37  
38 1 has 'key' => (
39 is => 'rw',
40 isa => NumberOneOrLess,
41 default => 1,
42 alias => 'k'
43 );
44  
45  
46 1 has 'name' => ( is => 'rw', isa => 'Str' );
47  
48  
49 1 ▶sub as_string {
Subroutine as_string: called CC=1 SCAR=0.0
Pod documented
50 1 my ($self) = @_;
51  
52 1 return sprintf('%0.2f,%0.2f,%0.2f,%0.2f',
53 $self->cyan, $self->magenta, $self->yellow, $self->key
54 );
55 }
56  
57  
58 1 ▶sub as_percent_string {
Subroutine as_percent_string: called CC=1 SCAR=0.0
Pod documented
59 1 my ($self) = @_;
60  
61 1 return sprintf("%d%%, %d%%, %d%%, %d%%",
62 $self->cyan * 100, $self->magenta * 100, $self->yellow * 100,
63 $self->key * 100
64 );
65 }
66  
67  
68 1 ▶sub as_array {
Subroutine as_array: called CC=1 SCAR=0.0
Pod documented
69 1 my ($self) = @_;
70  
71 1 return ($self->cyan, $self->magenta, $self->yellow, $self->key);
72 }
73  
74  
75 2 ▶sub equal_to {
Subroutine equal_to: called CC=6 SCAR=19.9
Pod documented
76 2 my ($self, $other) = @_;
77  
78 2 ▶ return 0 unless defined($other);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $other 0 2 2
79  
80 2 ▶ unless($self->cyan == $other->cyan) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->cyan == $other->cyan) 0 2 2
81 0 return 0;
82 }
83 2 ▶ unless($self->magenta == $other->magenta) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->magenta == $other->magenta) 0 2 2
84 0 return 0;
85 }
86 2 ▶ unless($self->yellow == $other->yellow) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->yellow == $other->yellow) 1 1 2
87 1 return 0;
88 }
89 1 ▶ unless($self->key == $other->key) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->key == $other->key) 0 1 1
90 0 return 0;
91 }
92  
93 1 return 1;
94 }
95  
96 1 __PACKAGE__->meta->make_immutable;
97  
98 1 ▶no Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
99 1 1;
100  
101 __END__
« Color/RGB.pm ↑ Summary Color/HSL.pm »