/lib/SDLx/Surface/TiedMatrix.pm
http://github.com/PerlGameDev/SDL · Perl · 38 lines · 31 code · 7 blank · 0 comment · 0 complexity · c6cbe872e7966aaa96d3420d4420f13c MD5 · raw file
- package SDLx::Surface::TiedMatrix;
- use strict;
- use warnings;
- use SDLx::Surface::TiedMatrixRow;
- use base 'Tie::Array';
- our $VERSION = 2.548;
- sub new {
- my $class = shift;
- my $matrix = shift;
- my $self = {
- matrix => $matrix,
- rows => [],
- };
- return bless $self, $class;
- }
- sub TIEARRAY {
- return SDLx::Surface::TiedMatrix->new( $_[1] );
- }
- sub FETCH {
- my ( $self, $y ) = @_;
- unless ( $self->{rows}[$y] ) {
- tie my @row, 'SDLx::Surface::TiedMatrixRow', $self->{matrix}, $y;
- $self->{rows}[$y] = \@row;
- }
- return $self->{rows}[$y];
- }
- sub FETCHSIZE {
- my ( $self, $x ) = @_;
- return $self->{matrix}->surface->h;
- }
- 1;