| Image-XBin documentation | Contained in the Image-XBin distribution. |
Image::XBin::Pixel - Pixel object
$pixel = Image::XBin::Pixel->new; # foreground color $pixel->fg( $fg ); # background color $pixel->bg( $bg ); # blinking $pixel->blink( $blink ); # or all 3 from an attribute byte $pixel->attr( $attr ); # the character $pixel->char( $char );
Create a new pixel and set its attributes.
Set the foreground, background and blink properties from an attribute byte.
Set the foreground color
Set the background color
Set the blink property
Set the character to be displayed
Copyright 2003-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-XBin documentation | Contained in the Image-XBin distribution. |
package Image::XBin::Pixel;
use base qw( Class::Accessor ); use strict; use warnings; # Attribute byte constants use constant ATTR_BLINK => 128; use constant ATTR_BG => 112; use constant ATTR_FG => 15; our $VERSION = '0.06'; __PACKAGE__->mk_accessors( qw( char fg bg blink ) );
sub new { my $class = shift; my %options = @_; my $self = {}; bless $self, $class; $self->$_( $options{ $_ } ) for keys %options; return $self; }
sub attr { my $self = shift; my $attr = $_[ 0 ]; if( @_ ) { $self->fg( $attr & ATTR_FG ); $self->bg( ( $attr & ATTR_BG ) >> 4 ); $self->blink( ( $attr & ATTR_BLINK ) >> 7 ); } else { $attr = 0; $attr |= $self->fg; $attr |= ( $self->bg << 4 ); $attr |= ( $self->blink << 7 ); } return $attr; }
1;