line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Image::TextMode::Writer::Tundra; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
393
|
use Moo; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
7
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
extends 'Image::TextMode::Writer'; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
sub _write { |
8
|
1
|
|
|
1
|
|
2
|
my ( $self, $image, $fh, $options ) = @_; |
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
|
|
3
|
print $fh pack( 'C', 24 ); |
11
|
1
|
|
|
|
|
2
|
print $fh pack( 'A8', 'TUNDRA24' ); |
12
|
|
|
|
|
|
|
|
13
|
1
|
|
|
|
|
28
|
my $pal = $image->palette; |
14
|
|
|
|
|
|
|
|
15
|
1
|
|
|
|
|
26
|
for my $y ( 0 .. $image->height - 1 ) { |
16
|
1
|
|
|
|
|
7
|
for my $x ( 0 .. 79 ) { |
17
|
80
|
|
|
|
|
181
|
my $pixel = $image->getpixel( $x, $y ); |
18
|
|
|
|
|
|
|
|
19
|
80
|
100
|
|
|
|
393
|
if ( !defined $pixel ) { |
20
|
76
|
|
|
|
|
131
|
$pixel = { char => ' ', fg => 0, bg => 0 }; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
80
|
|
|
|
|
1200
|
my $fg = _assemble_pal( $pal->colors->[ $pixel->{ fg } ] ); |
24
|
80
|
|
|
|
|
1201
|
my $bg = _assemble_pal( $pal->colors->[ $pixel->{ bg } ] ); |
25
|
80
|
|
|
|
|
267
|
print $fh chr( 6 ), $pixel->{ char }, pack( 'N*', $fg, $bg ); |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub _assemble_pal { |
31
|
160
|
|
|
160
|
|
615
|
my ( $color ) = shift; |
32
|
160
|
|
|
|
|
229
|
return ( $color->[ 0 ] << 16 ) | ( $color->[ 1 ] << 8 ) |
33
|
|
|
|
|
|
|
| ( $color->[ 2 ] ); |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head1 NAME |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
Image::TextMode::Writer::Tundra - Writes Tundra files |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head1 DESCRIPTION |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
Provides writing capabilities for the Tundra format. It currently does not |
43
|
|
|
|
|
|
|
support any RLE compression. |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=head1 AUTHOR |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
Brian Cassidy Ebricas@cpan.orgE |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
Copyright 2008-2014 by Brian Cassidy |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
54
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=cut |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
1; |