| Image-ANSI documentation | Contained in the Image-ANSI distribution. |
Image::ANSI::Palette - A base class palettes
# use Image::ANSI::Palette::VGA or your own $pal = Image::ANSI::Palette:VGA->new;
Creates a new Image::ANSI::Palette object.
Get the rgb triple at index $index
Write an rgb triple at index $index
Clears any in-memory data.
General accessor to the palette of colors
Copyright 2004-2009 by Brian Cassidy
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
| Image-ANSI documentation | Contained in the Image-ANSI distribution. |
package Image::ANSI::Palette;
use strict; use warnings; our $VERSION = '0.10';
sub new { my $class = shift; my $palette = shift; my $self = {}; bless $self, $class; $self->clear; if( $palette ) { for( 0..@$palette - 1 ) { $self->set( $_, $palette->[ $_ ] ); } } return $self; }
sub get { my $self = shift; my $index = shift; return $self->{ data }->[ $index ]; }
sub set { my $self = shift; my ( $index, $rgb ) = @_; $self->{ data }->[ $index ] = $rgb; }
sub clear { my $self = shift; $self->{ data } = []; }
sub colors { my $self = shift; $self->{ data } = $_[ 0 ] if @_; return $self->{ data }; }
1;