line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Image::TextMode::Writer::ADF; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
416
|
use Moo; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
6
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
extends 'Image::TextMode::Writer'; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
# generates a 64 color palette |
8
|
|
|
|
|
|
|
## no critic (BuiltinFunctions::ProhibitComplexMappings) |
9
|
|
|
|
|
|
|
my $default_pal = [ |
10
|
|
|
|
|
|
|
map { |
11
|
|
|
|
|
|
|
my @d = split( //s, sprintf( '%06b', $_ ) ); |
12
|
|
|
|
|
|
|
{ |
13
|
|
|
|
|
|
|
[ oct( "0b$d[ 3 ]$d[ 0 ]" ) * 63, |
14
|
|
|
|
|
|
|
oct( "0b$d[ 4 ]$d[ 1 ]" ) * 63, |
15
|
|
|
|
|
|
|
oct( "0b$d[ 5 ]$d[ 2 ]" ) * 63, |
16
|
|
|
|
|
|
|
] |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
} 0 .. 63 |
19
|
|
|
|
|
|
|
]; |
20
|
|
|
|
|
|
|
## use critic |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub _write { |
23
|
1
|
|
|
1
|
|
2
|
my ( $self, $image, $fh, $options ) = @_; |
24
|
|
|
|
|
|
|
|
25
|
1
|
|
|
|
|
21
|
print $fh pack( 'C', $image->header->{ version } ); |
26
|
|
|
|
|
|
|
|
27
|
1
|
|
|
|
|
36
|
print $fh _pack_pal( $image->palette ); |
28
|
1
|
|
|
|
|
30
|
print $fh _pack_font( $image->font ); |
29
|
|
|
|
|
|
|
|
30
|
1
|
|
|
|
|
62
|
for my $row ( @{ $image->pixeldata } ) { |
|
1
|
|
|
|
|
33
|
|
31
|
80
|
|
|
|
|
131
|
print $fh |
32
|
|
|
|
|
|
|
join( '', |
33
|
1
|
|
|
|
|
10
|
map { pack( 'aC', @{ $_ }{ qw( char attr ) } ) } @$row ); |
|
80
|
|
|
|
|
63
|
|
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub _pack_font { |
38
|
1
|
|
|
1
|
|
7
|
my $font = shift; |
39
|
1
|
|
|
|
|
2
|
return pack( 'C*', map { @$_ } @{ $font->chars } ); |
|
256
|
|
|
|
|
1044
|
|
|
1
|
|
|
|
|
5
|
|
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub _pack_pal { |
43
|
1
|
|
|
1
|
|
7
|
my $pal = shift; |
44
|
|
|
|
|
|
|
|
45
|
1
|
|
|
|
|
5
|
my @full_pal = @$default_pal; |
46
|
1
|
|
|
|
|
3
|
my @pal_map = qw( 0 1 2 3 4 5 20 7 56 57 58 59 60 61 62 63 ); |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
# insert our colors into the appropriate slots in the 64-color array |
49
|
1
|
|
|
|
|
2
|
for ( 0 .. 15 ) { |
50
|
16
|
|
|
|
|
14
|
my @p = map { $_ >> 2 } @{ $pal->colors->[ $_ ] }; |
|
48
|
|
|
|
|
608
|
|
|
16
|
|
|
|
|
212
|
|
51
|
16
|
|
|
|
|
29
|
$full_pal[ $pal_map[ $_ ] ] = \@p; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
1
|
|
|
|
|
1
|
return pack( 'C*', map { @$_ } @full_pal ); |
|
64
|
|
|
|
|
68
|
|
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head1 NAME |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
Image::TextMode::Writer::ADF - Writes ADF files |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head1 DESCRIPTION |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
Provides writing capabilities for the ADF format. |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head1 AUTHOR |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
Brian Cassidy Ebricas@cpan.orgE |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
Copyright 2008-2015 by Brian Cassidy |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
74
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=cut |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
1; |