| 1 | package Image::TextMode::Animation; | ||
| 2 | |||
| 3 | 3 | ▶ | use Moo; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 3 | ▶ | use Types::Standard qw( ArrayRef ); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | 3 | ▶ | use Symbol (); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | |||
| 7 | BEGIN { | ||
| 8 | 3 | ▶ | for my $sub ( |
|
Subroutine
BEGIN: called CC=2 SCAR=6.9
| |||
| 9 | qw( getpixel getpixel_obj putpixel clear_screen clear_line ) ) | ||
| 10 | { | ||
| 11 | 15 | *{ Symbol::qualify_to_ref( __PACKAGE__ . "\::$sub" ) } = sub { | |
| 12 | 33 | ▶ | shift->frames->[ -1 ]->$sub( @_ ); |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||
| 13 | } | ||
| 14 | 15 | } | |
| 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 | 4 | ▶ | has 'frames' => ( is => 'rw', lazy => 1, isa => ArrayRef, default => sub { [] } ); |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||
| 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 | ▶ | my ( $self, $frame ) = @_; |
|
Subroutine
add_frame: called CC=1 SCAR=0.0
Pod
documented
| |||
| 52 | 8 | push @{ $self->frames }, $frame; | |
| 53 | } | ||
| 54 | |||
| 55 | =head2 width( ) | ||
| 56 | |||
| 57 | Returns the largest frame width. | ||
| 58 | |||
| 59 | =cut | ||
| 60 | |||
| 61 | sub width { | ||
| 62 | 4 | ▶ | my $self = shift; |
|
Subroutine
width: called CC=1 SCAR=0.0
Pod
documented
| |||
| 63 | 4 | my @widths = sort { $b <=> $a } map { $_->width } @{ $self->frames }; | |
| 64 | 4 | return $widths[ 0 ]; | |
| 65 | } | ||
| 66 | |||
| 67 | =head2 height( ) | ||
| 68 | |||
| 69 | Returns the largest frame height. | ||
| 70 | |||
| 71 | =cut | ||
| 72 | |||
| 73 | sub height { | ||
| 74 | 4 | ▶ | my $self = shift; |
|
Subroutine
height: called CC=1 SCAR=0.0
Pod
documented
| |||
| 75 | 4 | my @heights = sort { $b <=> $a } map { $_->height } @{ $self->frames }; | |
| 76 | 4 | return $heights[ 0 ]; | |
| 77 | } | ||
| 78 | |||
| 79 | =head2 dimensions( ) | ||
| 80 | |||
| 81 | Returns the a list containing the values of C<width> and C<height>. | ||
| 82 | |||
| 83 | =cut | ||
| 84 | |||
| 85 | sub dimensions { | ||
| 86 | 2 | ▶ | my $self = shift; |
|
Subroutine
dimensions: called CC=1 SCAR=0.0
Pod
documented
| |||
| 87 | 2 | 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 | ▶ | my $self = shift; |
|
Subroutine
as_ascii: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 98 | 0 | return join( "\n", map { $_->as_ascii } @{ $self->frames } ); | |
| 99 | } | ||
| 100 | |||
| 101 | =head1 PROXIED METHODS | ||
| 102 | |||
| 103 | The following methods are proxies to the last element in C<frames>. | ||
| 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 E<lt>bricas@cpan.orgE<gt> | ||
| 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 | 3 | 1; | |