PageRenderTime 29ms CodeModel.GetById 18ms app.highlight 8ms RepoModel.GetById 1ms app.codeStats 0ms

/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
 1package SDLx::Surface::TiedMatrix;
 2use strict;
 3use warnings;
 4use SDLx::Surface::TiedMatrixRow;
 5use base 'Tie::Array';
 6
 7our $VERSION = 2.548;
 8
 9sub new {
10	my $class  = shift;
11	my $matrix = shift;
12	my $self   = {
13		matrix => $matrix,
14		rows   => [],
15	};
16	return bless $self, $class;
17}
18
19sub TIEARRAY {
20	return SDLx::Surface::TiedMatrix->new( $_[1] );
21}
22
23sub FETCH {
24	my ( $self, $y ) = @_;
25
26	unless ( $self->{rows}[$y] ) {
27		tie my @row, 'SDLx::Surface::TiedMatrixRow', $self->{matrix}, $y;
28		$self->{rows}[$y] = \@row;
29	}
30	return $self->{rows}[$y];
31}
32
33sub FETCHSIZE {
34	my ( $self, $x ) = @_;
35	return $self->{matrix}->surface->h;
36}
37
381;