WMF/Colour.pm

filter: Statementstmt 62.3% 53 / 85 Branchbran 36.6% 11 / 30 Conditioncond 20.0% 3 / 15 MC/DCmcdc 0.0% 0 / 8 Subroutinesub 81.2% 13 / 16 Podpod 0.0% 0 / 13 totaltotal 47.9% 80 / 167 CC 21 SCAR 32.9
CC
21
Cov
52%
setColour
81.0
rgb
6.0
_initialise
5.5
CRAP 26.8
↑ Summary WMF/Image.pm »
1 package Image::WMF::Colour;
2 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 4 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod undocumented
5 4 my ($class, $r, $g, $b) = @_;
6 4 my $obj = bless {
7 _r => undef,
8 _g => undef,
9 _b => undef,
10 _a => undef,
11 _rgb => undef,
12 }, $class;
13 4 $obj->_initialise($r, $g, $b);
14 4 return $obj;
15 }
16  
17 4 ▶sub _initialise {
Subroutine _initialise: called CC=4 SCAR=17.1
18 4 my ($self, $r, $g, $b) = @_;
19 4 ▶ if (defined $r && defined $g && defined $b){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $r and defined $g and defined $b) 4 0 4
Condition33%2/6
defined $r and defined $g and defined $b
!ll&&!rl&&r
004
defined $r and defined $g
!ll&&!rl&&r
004
MC/DC0%0/3
defined $r and defined $g and defined $b
defined $r defined $g defined $b
Truth table25%1/4
A and B and C
A= defined $rB= defined $gC= defined $b
ABCresult
0XX0
10X0
1100
1111
20 4 $self->setColour($r, $g, $b);
21 }
22 }
23  
24 4 ▶sub _packColours {
Subroutine _packColours: called CC=1 SCAR=0.0
25 4 my ($self) = @_;
26 4 my $rgb = $self->writeInteger( $self->red() & 0xFF
27 | $self->green() << 8 & 0xFF00
28 | $self->blue() << 16 & 0xFF0000
29 );
30 4 $self->{'_rgb'} = $rgb;
31 4 return ($rgb);
32 }
33  
34 0 ▶sub rgb {
Subroutine rgb: not called CC=2 SCAR=17.9
Pod undocumented
35 0 my ($self, $rgb) = @_;
36 0 ▶ if (defined $rgb) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $rgb) { } 0 0 0
37 0 $self->{'_rgb'} = $rgb;
38 0 return $rgb;
39 } else {
40 0 return ( $self->{'_rgb'} )
41 }
42 }
43  
44 4 ▶sub loWord {
Subroutine loWord: called CC=1 SCAR=0.0
Pod undocumented
45 4 my ($self, $word) = @_;
46 4 return ($word & 0xFFFF)
47 }
48  
49 4 ▶sub hiWord {
Subroutine hiWord: called CC=1 SCAR=0.0
Pod undocumented
50 4 my ($self, $word) = @_;
51 4 return ($word & 0xFFFF0000) >> 16;
52 }
53  
54 8 ▶sub writeWord {
Subroutine writeWord: called CC=1 SCAR=0.0
Pod undocumented
55 8 my ($self, $int) = @_;
56 8 $self->outputWord($int);
57 }
58  
59 8 ▶sub outputWord {
Subroutine outputWord: called CC=1 SCAR=0.0
Pod undocumented
60 8 my ($self, $int) = @_;
61 8 my $out = undef;
62 8 $out .= pack ("C", ($int & 0xFF));
63 8 $out .= pack ("C", (($int & 0xFF00)>>8));
64 8 return($out);
65 }
66  
67 0 ▶sub outputInteger {
Subroutine outputInteger: not called CC=1 SCAR=6.9
Pod undocumented
68 0 my ($self, $int) = @_;
69 0 $self->outputWord($self->loWord($int));
70 0 $self->outputWord($self->hiWord($int));
71 }
72  
73 4 ▶sub writeInteger {
Subroutine writeInteger: called CC=1 SCAR=0.0
Pod undocumented
74 4 my ($self, $int) = @_;
75 4 $self->writeWord($self->loWord($int));
76 4 $self->writeWord($self->hiWord($int));
77 }
78  
79 4 ▶sub setColour {
Subroutine setColour: called CC=11 SCAR=43.9
Pod undocumented
80 4 my ($self, $colour, $col2, $col3, $col4) = @_;
81 4 ▶ if (defined $col2 && defined $col3){
Branch: 2 branches
BranchTrueFalseTotal
if (defined $col2 and defined $col3) { } 4 0 4
elsif (defined $colour) { } 0 0 0
Condition33%1/3
defined $col2 and defined $col3
!ll&&!rl&&r
004
MC/DC0%0/2
defined $col2 and defined $col3
defined $col2 defined $col3
Truth table33%1/3
A and B
A= defined $col2B= defined $col3
ABresult
0X0
100
111
82 4 $self->red($colour);
83 4 $self->green($col2);
84 4 $self->blue($col3);
85 4 return($self->_packColours());
86 }
87 elsif (defined $colour) {
88 0 ▶ if ($colour eq "red"){
Branch: 4 branches
BranchTrueFalseTotal
if ($colour eq 'red') { } 0 0 0
elsif ($colour eq 'green') { } 0 0 0
elsif ($colour eq 'blue') { } 0 0 0
elsif ($colour eq 'black') { } 0 0 0
89 0 $self->red(255);
90 0 $self->green(0);
91 0 $self->blue(0);
92 } elsif ($colour eq "green"){
93 0 $self->red(0);
94 0 $self->green(255);
95 0 $self->blue(0);
96 } elsif ($colour eq "blue"){
97 0 $self->red(0);
98 0 $self->green(0);
99 0 $self->blue(255);
100 } elsif ($colour eq "black"){
101 0 $self->red(0);
102 0 $self->green(0);
103 0 $self->blue(0);
104 } else {
105 0 $self->red(255); # default is white
106 0 $self->green(255);
107 0 $self->blue(255);
108 }
109 0 ▶ if(defined $self->red() && defined $self->green() && defined $self->blue()){
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->red and defined $self->green and defined $self->blue) { } 0 0 0
Condition0%0/6
defined $self->red and defined $self->green and defined $self->blue
!ll&&!rl&&r
000
defined $self->red and defined $self->green
!ll&&!rl&&r
000
MC/DC0%0/3
defined $self->red and defined $self->green and defined $self->blue
defined $self->red defined $self->green defined $self->blue
Truth table0%0/4
A and B and C
A= defined $self->redB= defined $self->greenC= defined $self->blue
ABCresult
0XX0
10X0
1100
1111
110 0 return ($self->_packColours());
111 } else {
112 0 return (undef);
113 }
114 }
115 }
116  
117 13 ▶sub red {
Subroutine red: called CC=3 SCAR=11.2
Pod undocumented
118 13 my ($self, $r) = @_;
119 13 ▶ if (defined $r) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $r) { } 4 9 13
120 4 ▶ if ($r =~ /^0x/){
Branch: 1 branch
BranchTrueFalseTotal
if ($r =~ /^0x/) 0 4 4
121 0 $r = $self->fromHex($r);
122 }
123 4 $self->{'_r'} = $r;
124 4 return $r;
125 } else {
126 9 return ( $self->{'_r'} )
127 }
128 }
129  
130 13 ▶sub green {
Subroutine green: called CC=3 SCAR=11.2
Pod undocumented
131 13 my ($self, $g) = @_;
132 13 ▶ if (defined $g) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $g) { } 4 9 13
133 4 ▶ if ($g =~ /^0x/){
Branch: 1 branch
BranchTrueFalseTotal
if ($g =~ /^0x/) 0 4 4
134 0 $g = $self->fromHex($g);
135 }
136 4 $self->{'_g'} = $g;
137 4 return $g;
138 } else {
139 9 return ( $self->{'_g'} )
140 }
141 }
142  
143 13 ▶sub blue {
Subroutine blue: called CC=3 SCAR=11.2
Pod undocumented
144 13 my ($self, $b) = @_;
145 13 ▶ if (defined $b) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $b) { } 4 9 13
146 4 ▶ if ($b =~ /^0x/){
Branch: 1 branch
BranchTrueFalseTotal
if ($b =~ /^0x/) 0 4 4
147 0 $b = $self->fromHex($b);
148 }
149 4 $self->{'_b'} = $b;
150 4 return $b;
151 } else {
152 9 return ( $self->{'_b'} )
153 }
154 }
155  
156 0 ▶sub fromHex {
Subroutine fromHex: not called CC=1 SCAR=6.9
Pod undocumented
157 0 my ($self, $h) = @_;
158 0 return (hex($h));
159 }
160  
161 1 1;
↑ Summary WMF/Image.pm »