File: TiedMatrix.pm

package info (click to toggle)
libsdl-perl 2.548-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,972 kB
  • sloc: perl: 13,985; ansic: 583; makefile: 35
file content (38 lines) | stat: -rw-r--r-- 632 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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;