PageRenderTime 24ms CodeModel.GetById 12ms app.highlight 9ms RepoModel.GetById 1ms app.codeStats 0ms

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