LineTrace.pm

filter: Statementstmt 96.3% 53 / 55 Branchbran 85.7% 12 / 14 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 7 / 7 Podpod 0.0% 0 / 1 totaltotal 93.5% 72 / 77 CC 8 SCAR 16.1
CC
8
Cov
94%
line_trace
8.0
BEGIN
1.0
BEGIN
1.0
CRAP 5.0
« LineTrace/Algorithm.pm ↑ Summary LineTrace/Figure.pm »
1 package Imager::LineTrace;
2 1 ▶use 5.008001;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 ▶use base qw(Imager);
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 1 ▶use Imager::LineTrace::Algorithm;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use Imager::LineTrace::Figure;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 1 our $VERSION = "0.06";
12  
13 7 ▶sub line_trace {
Subroutine line_trace: called CC=8 SCAR=20.8
Pod undocumented
14 7 my $self = shift;
15 7 my %args = @_;
16  
17 7 my $channels = [ 0, 1, 2 ];
18 7 ▶ if ( exists $args{channels} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $args{"channels"}) 4 3 7
19 4 $channels = $args{channels};
20 }
21  
22 7 my $number_of_channels = scalar( @{$channels} );
23 7 my $ymax = $self->getheight() - 1;
24 my @pixels = map {
25 7 my $iy = $_;
26  
27 13 my $ary_ref = $self->getsamples( y => $iy, channels => $channels );
28 13 my @wk = ();
29 13 ▶ if ( @{$channels} == 3 ) {
Branch: 2 branches
BranchTrueFalseTotal
if (@{$channels;} == 3) { } 9 4 13
elsif (@{$channels;} == 2) { } 0 4 4
30 9 my @tmp = unpack( "C*", $ary_ref );
31 9 ▶ while ( @tmp ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@tmp) 27 9 36
32 27 my $val = shift @tmp;
33 27 $val = ($val << 8) + shift @tmp;
34 27 $val = ($val << 8) + shift @tmp;
35 27 push @wk, $val;
36 }
37 }
38 4 elsif ( @{$channels} == 2 ) {
39 0 @wk = unpack( "S*", $ary_ref );
40 }
41 else {
42 4 @wk = unpack( "C*", $ary_ref );
43 }
44  
45 13 \@wk;
46 } 0..$ymax;
47  
48 7 ▶ if ( not exists $args{ignore} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $args{"ignore"}) 6 1 7
49 6 ▶ if ( @{$channels} == 3 ) {
Branch: 2 branches
BranchTrueFalseTotal
if (@{$channels;} == 3) { } 2 4 6
elsif (@{$channels;} == 2) { } 0 4 4
50 2 $args{ignore} = 0xFFFFFF;
51 }
52 4 elsif ( @{$channels} == 2 ) {
53 0 $args{ignore} = 0xFFFF;
54 }
55 else {
56 4 $args{ignore} = 0xFF;
57 }
58 }
59  
60 7 my $results = Imager::LineTrace::Algorithm::search( \@pixels, \%args );
61 my @figures = map {
62 7 Imager::LineTrace::Figure->new( $_ );
63 7 } @{$results};
64  
65 7 return \@figures;
66 }
67  
68 1 1;
69 __END__
« LineTrace/Algorithm.pm ↑ Summary LineTrace/Figure.pm »