File Coverage

blib/lib/Image/Caa/DitherOrdered4.pm
Criterion Covered Total %
statement 19 19 100.0
branch n/a
condition n/a
subroutine 6 6 100.0
pod 0 4 0.0
total 25 29 86.2


line stmt bran cond sub pod time code
1             package Image::Caa::DitherOrdered4;
2            
3 2     2   13 use strict;
  2         5  
  2         86  
4 2     2   12 use warnings;
  2         4  
  2         488  
5            
6             sub new {
7 2     2 0 5 my ($class, $args) = @_;
8            
9 2         6 my $self = bless {}, $class;
10            
11 2         16 return $self;
12             }
13            
14             sub init {
15 2     2 0 4 my ($self, $line) = @_;
16            
17 2         21 $self->{table} = [
18             0x00, 0x80, 0x20, 0xa0,
19             0xc0, 0x40, 0xe0, 0x60,
20             0x30, 0xb0, 0x10, 0x90,
21             0xf0, 0x70, 0xd0, 0x50
22             ];
23            
24 2         6 my $skip = ($line % 4) * 4;
25 2         8 shift @{$self->{table}} for 1..$skip;
  4         8  
26            
27 2         6 $self->{index} = 0;
28             }
29            
30             sub get {
31 16     16 0 18 my ($self) = @_;
32            
33 16         47 return $self->{table}->[$self->{index}];
34             }
35            
36             sub increment {
37 4     4 0 5 my ($self) = @_;
38            
39 4         20 $self->{index} = ($self->{index} + 1) % 4;
40             }
41            
42             1;