Image::TextMode::Reader::ANSIMation - Reads ANSI Animation files


Image-TextMode documentation Contained in the Image-TextMode distribution.

Index


Code Index:

NAME

Top

Image::TextMode::Reader::ANSIMation - Reads ANSI Animation files

DESCRIPTION

Top

Provides reading capabilities for the ANSIMation format. This module extends the ANSI reader, and simply creates a new frame for every set_position(0,0) command executed.

METHODS

Top

set_position( [$x, $y] )

We use this method as a clue that we're starting a new frame if $x and $y are both 1, which is the default.

next_frame( )

Adds a new frame to the stack.

AUTHOR

Top

Brian Cassidy <bricas@cpan.org>

COPYRIGHT AND LICENSE

Top


Image-TextMode documentation Contained in the Image-TextMode distribution.

package Image::TextMode::Reader::ANSIMation;

use Moose;
use Image::TextMode::Canvas;

extends 'Image::TextMode::Reader::ANSI';

sub _read {
    my ( $self, $animation, @args ) = @_;
    $animation->add_frame( Image::TextMode::Canvas->new );
    $self->SUPER::_read( $animation, @args );
}

sub set_position {
    my ( $self, @args ) = @_;

    if ( ( $args[ 0 ] || 1 ) == 1 && ( $args[ 1 ] || 1 ) == 1 ) {
        $self->next_frame;
    }

    $self->SUPER::set_position( @args );
}

sub next_frame {
    my $self      = shift;
    my $animation = $self->image;

    return unless $animation->frames->[ -1 ]->height;

    $animation->add_frame( Image::TextMode::Canvas->new );
}

no Moose;

__PACKAGE__->meta->make_immutable;

1;