line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Image::TextMode::Animation; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
1317
|
use Moo; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
15
|
|
4
|
3
|
|
|
3
|
|
707
|
use Types::Standard qw( ArrayRef ); |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
17
|
|
5
|
3
|
|
|
3
|
|
2622
|
use Symbol (); |
|
3
|
|
|
|
|
2003
|
|
|
3
|
|
|
|
|
225
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
BEGIN { |
8
|
3
|
|
|
3
|
|
7
|
for my $sub ( |
9
|
|
|
|
|
|
|
qw( getpixel getpixel_obj putpixel clear_screen clear_line ) ) |
10
|
|
|
|
|
|
|
{ |
11
|
15
|
|
|
|
|
32
|
*{ Symbol::qualify_to_ref( __PACKAGE__ . "\::$sub" ) } = sub { |
12
|
33
|
|
|
33
|
|
1873
|
shift->frames->[ -1 ]->$sub( @_ ); |
13
|
|
|
|
|
|
|
} |
14
|
15
|
|
|
|
|
181
|
} |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 NAME |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
Image::TextMode::Animation - A base class for text mode animation file formats |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head1 DESCRIPTION |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
This class should be used for any format that requires a sequence of frames |
24
|
|
|
|
|
|
|
for display. |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=head1 ACCESSORS |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=over 4 |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=item * frames - an arrayref of frame objects |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=back |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=cut |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
has 'frames' => ( is => 'rw', lazy => 1, isa => ArrayRef, default => sub { [] } ); |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head1 METHODS |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head2 new( %args ) |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
Creates a new instance. |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head2 add_frame( $frame ) |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
Adds a frame to the end of the array. |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=cut |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub add_frame { |
51
|
8
|
|
|
8
|
1
|
3461
|
my ( $self, $frame ) = @_; |
52
|
8
|
|
|
|
|
12
|
push @{ $self->frames }, $frame; |
|
8
|
|
|
|
|
116
|
|
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head2 width( ) |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
Returns the largest frame width. |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=cut |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub width { |
62
|
4
|
|
|
4
|
1
|
1370
|
my $self = shift; |
63
|
4
|
|
|
|
|
5
|
my @widths = sort { $b <=> $a } map { $_->width } @{ $self->frames }; |
|
4
|
|
|
|
|
38
|
|
|
8
|
|
|
|
|
192
|
|
|
4
|
|
|
|
|
97
|
|
64
|
4
|
|
|
|
|
25
|
return $widths[ 0 ]; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head2 height( ) |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
Returns the largest frame height. |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=cut |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub height { |
74
|
4
|
|
|
4
|
1
|
6
|
my $self = shift; |
75
|
4
|
|
|
|
|
7
|
my @heights = sort { $b <=> $a } map { $_->height } @{ $self->frames }; |
|
4
|
|
|
|
|
25
|
|
|
8
|
|
|
|
|
151
|
|
|
4
|
|
|
|
|
62
|
|
76
|
4
|
|
|
|
|
21
|
return $heights[ 0 ]; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head2 dimensions( ) |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
Returns the a list containing the values of C and C. |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=cut |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub dimensions { |
86
|
2
|
|
|
2
|
1
|
1693
|
my $self = shift; |
87
|
2
|
|
|
|
|
8
|
return $self->width, $self->height; |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head2 as_ascii( ) |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
Returns all of the text from all of the frames. |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=cut |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
sub as_ascii { |
97
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
98
|
0
|
|
|
|
|
|
return join( "\n", map { $_->as_ascii } @{ $self->frames } ); |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head1 PROXIED METHODS |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
The following methods are proxies to the last element in C. |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=over 4 |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=item * getpixel |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=item * getpixel_obj |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=item * putpixel |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=item * clear_screen |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=item * clear_line |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=back |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=head1 AUTHOR |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
Brian Cassidy Ebricas@cpan.orgE |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
Copyright 2008-2014 by Brian Cassidy |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
128
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=cut |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
1; |