File Coverage

blib/lib/Image/Caa/DitherOrdered8.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::DitherOrdered8;
2            
3 2     2   48 use strict;
  2         4  
  2         87  
4 2     2   11 use warnings;
  2         6  
  2         614  
5            
6             sub new {
7 2     2 0 5 my ($class, $args) = @_;
8            
9 2         7 my $self = bless {}, $class;
10            
11 2         16 return $self;
12             }
13            
14             sub init {
15 2     2 0 5 my ($self, $line) = @_;
16            
17 2         27 $self->{table} = [
18             0x00, 0x80, 0x20, 0xa0, 0x08, 0x88, 0x28, 0xa8,
19             0xc0, 0x40, 0xe0, 0x60, 0xc8, 0x48, 0xe8, 0x68,
20             0x30, 0xb0, 0x10, 0x90, 0x38, 0xb8, 0x18, 0x98,
21             0xf0, 0x70, 0xd0, 0x50, 0xf8, 0x78, 0xd8, 0x58,
22             0x0c, 0x8c, 0x2c, 0xac, 0x04, 0x84, 0x24, 0xa4,
23             0xcc, 0x4c, 0xec, 0x6c, 0xc4, 0x44, 0xe4, 0x64,
24             0x3c, 0xbc, 0x1c, 0x9c, 0x34, 0xb4, 0x14, 0x94,
25             0xfc, 0x7c, 0xdc, 0x5c, 0xf4, 0x74, 0xd4, 0x54,
26             ];
27            
28 2         8 my $skip = ($line % 8) * 8;
29 2         7 shift @{$self->{table}} for 1..$skip;
  8         15  
30            
31 2         7 $self->{index} = 0;
32             }
33            
34             sub get {
35 16     16 0 19 my ($self) = @_;
36            
37 16         52 return $self->{table}->[$self->{index}];
38             }
39            
40             sub increment {
41 4     4 0 6 my ($self) = @_;
42            
43 4         21 $self->{index} = ($self->{index} + 1) % 8;
44             }
45            
46             1;