From: Breno G. de Oliveira Date: Sun, 4 Oct 2009 07:11:41 +0000 (-0300) Subject: implemented normalize X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=f1b790663e3f8ab1b4f53bfea13988c458153f42;p=sdlgit%2FSDL_perl.git implemented normalize --- diff --git a/lib/SDL/Game/Rect.pm b/lib/SDL/Game/Rect.pm index 18f4067..01368f0 100644 --- a/lib/SDL/Game/Rect.pm +++ b/lib/SDL/Game/Rect.pm @@ -557,6 +557,21 @@ sub fit_ip { return; } +sub normalize { + my $self = shift; + + if ($self->w < 0) { + $self->x($self->x + $self->w); + $self->w(-$self->w); + } + + if ($self->h < 0) { + $self->y( $self->y + $self->h); + $self->h(-$self->h); + } + return; +} + 42; __END__