File: | blib/lib/Image/Caa/DitherOrdered2.pm |
Coverage: | 100.0% |
line | stmt | bran | cond | sub | time | code |
---|---|---|---|---|---|---|
1 | package Image::Caa::DitherOrdered2; | |||||
2 | ||||||
3 | 2 2 2 | 10 5 12 | use strict; | |||
4 | 2 2 2 | 11 4 13 | use warnings; | |||
5 | ||||||
6 | sub new { | |||||
7 | 2 | 8 | my ($class, $args) = @_; | |||
8 | ||||||
9 | 2 | 8 | my $self = bless {}, $class; | |||
10 | ||||||
11 | 2 | 13 | return $self; | |||
12 | } | |||||
13 | ||||||
14 | sub init { | |||||
15 | 2 | 6 | my ($self, $line) = @_; | |||
16 | ||||||
17 | 2 | 9 | $self->{table} = [0x00, 0x80, 0xc0, 0x40]; | |||
18 | ||||||
19 | 2 | 6 | my $skip = ($line % 2) * 2; | |||
20 | 2 2 2 | 3 9 9 | shift @{$self->{table}} for 1..$skip; | |||
21 | ||||||
22 | 2 | 8 | $self->{index} = 0; | |||
23 | } | |||||
24 | ||||||
25 | sub get { | |||||
26 | 16 | 36 | my ($self) = @_; | |||
27 | ||||||
28 | 16 | 97 | return $self->{table}->[$self->{index}]; | |||
29 | } | |||||
30 | ||||||
31 | sub increment { | |||||
32 | 4 | 11 | my ($self) = @_; | |||
33 | ||||||
34 | 4 | 35 | $self->{index} = ($self->{index} + 1) % 2; | |||
35 | } | |||||
36 | ||||||
37 | 1; |