File Coverage

File:blib/lib/Image/Caa/DitherOrdered4.pm
Coverage:100.0%

linestmtbrancondsubtimecode
1package Image::Caa::DitherOrdered4;
2
3
2
2
2
8
4
13
use strict;
4
2
2
2
11
3
10
use warnings;
5
6sub new {
7
2
10
        my ($class, $args) = @_;
8
9
2
6
        my $self = bless {}, $class;
10
11
2
12
        return $self;
12}
13
14sub init {
15
2
8
        my ($self, $line) = @_;
16
17
2
15
        $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
8
        my $skip = ($line % 4) * 4;
25
2
2
4
2
11
16
        shift @{$self->{table}} for 1..$skip;
26
27
2
8
        $self->{index} = 0;
28}
29
30sub get {
31
16
39
        my ($self) = @_;
32
33
16
94
        return $self->{table}->[$self->{index}];
34}
35
36sub increment {
37
4
11
        my ($self) = @_;
38
39
4
36
        $self->{index} = ($self->{index} + 1) % 4;
40}
41
421;