Color/HSL.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% 5 / 5 totaltotal 89.2% 58 / 65 CC 6 SCAR 13.1
CC
6
Cov
86%
equal_to
7.3
BEGIN
1.0
BEGIN
1.0
CRAP 3.7
« Color/CMYK.pm ↑ Summary Color/YIQ.pm »
1 package Graphics::Color::HSL;
2 5 $Graphics::Color::HSL::VERSION = '0.31';
3 5 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 5 ▶use MooseX::Aliases;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 5 extends qw(Graphics::Color);
7  
8 # ABSTRACT: HSL color space
9  
10 5 with 'Graphics::Color::Equal';
11  
12 5 ▶use Graphics::Color::Types qw(Number360OrLess NumberOneOrLess);
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14  
15 5 has 'hue' => (
16 is => 'rw',
17 isa => Number360OrLess,
18 default => 1,
19 alias => 'h'
20 );
21  
22  
23 5 has 'saturation' => (
24 is => 'rw',
25 isa => NumberOneOrLess,
26 default => 1,
27 alias => 's'
28 );
29  
30  
31 5 has 'lightness' => (
32 is => 'rw',
33 isa => NumberOneOrLess,
34 default => 1,
35 alias => 'l'
36 );
37  
38  
39 5 has 'alpha' => (
40 is => 'rw',
41 isa => NumberOneOrLess,
42 default => 1,
43 alias => 'a'
44 );
45  
46  
47 5 has 'name' => ( is => 'rw', isa => 'Str' );
48  
49  
50 1 ▶sub as_string {
Subroutine as_string: called CC=1 SCAR=0.0
Pod documented
51 1 my ($self) = @_;
52  
53 1 return sprintf('%d,%0.2f,%0.2f,%0.2f',
54 $self->hue, $self->saturation, $self->lightness, $self->alpha
55 );
56 }
57  
58  
59 1 ▶sub as_percent_string {
Subroutine as_percent_string: called CC=1 SCAR=0.0
Pod documented
60 1 my ($self) = @_;
61  
62 1 return sprintf("%d, %d%%, %d%%, %0.2f",
63 $self->hue, $self->saturation * 100, $self->lightness * 100,
64 $self->alpha
65 );
66 }
67  
68  
69 1 ▶sub as_array {
Subroutine as_array: called CC=1 SCAR=0.0
Pod documented
70 1 my ($self) = @_;
71  
72 1 return ($self->hue, $self->saturation, $self->lightness);
73 }
74  
75  
76 1 ▶sub as_array_with_alpha {
Subroutine as_array_with_alpha: called CC=1 SCAR=0.0
Pod documented
77 1 my ($self) = @_;
78  
79 1 return ($self->hue, $self->saturation, $self->lightness, $self->alpha);
80 }
81  
82  
83 2 ▶sub equal_to {
Subroutine equal_to: called CC=6 SCAR=19.9
Pod documented
84 2 my ($self, $other) = @_;
85  
86 2 ▶ return 0 unless defined($other);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $other 0 2 2
87  
88 2 ▶ unless($self->hue == $other->hue) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->hue == $other->hue) 0 2 2
89 0 return 0;
90 }
91 2 ▶ unless($self->saturation == $other->saturation) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->saturation == $other->saturation) 1 1 2
92 1 return 0;
93 }
94 1 ▶ unless($self->lightness == $other->lightness) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->lightness == $other->lightness) 0 1 1
95 0 return 0;
96 }
97 1 ▶ unless($self->alpha == $other->alpha) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->alpha == $other->alpha) 0 1 1
98 0 return 0;
99 }
100  
101 1 return 1;
102 }
103  
104 5 __PACKAGE__->meta->make_immutable;
105  
106 5 ▶no Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
107 5 1;
108  
109 __END__
« Color/CMYK.pm ↑ Summary Color/YIQ.pm »