File Coverage

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

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