/lib/SDLx/Surface/TiedMatrixRow.pm
http://github.com/PerlGameDev/SDL · Perl · 42 lines · 31 code · 11 blank · 0 comment · 0 complexity · cede8a0d1b7901418e421647560ff4f4 MD5 · raw file
- package SDLx::Surface::TiedMatrixRow;
- use strict;
- use warnings;
- use base 'Tie::Array';
- our $VERSION = 2.548;
- sub new {
- my $class = shift;
- my $matrix = shift;
- my $y = shift;
- my $self = {
- matrix => $matrix,
- y => $y,
- };
- return bless $self, $class;
- }
- sub TIEARRAY {
- return SDLx::Surface::TiedMatrixRow->new( $_[1], $_[2] );
- }
- sub FETCH {
- my ( $self, $x ) = @_;
- $self->{matrix}->get_pixel( $x, $self->{y} );
- }
- sub FETCHSIZE {
- my ( $self, $x ) = @_;
- return $self->{matrix}->surface->w;
- }
- sub STORE {
- my ( $self, $x, $new_value ) = @_;
- $self->{matrix}->set_pixel( $x, $self->{y}, $new_value );
- }
- 1;