X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FSDL%2FTool%2FGraphic.pm;h=697089dfddc8e82cc0fb2fad8e26b16bbbeec312;hb=896b04ee008898e1c1edbdd432bedaa8643400dc;hp=049b31dcb8307090fafd7aad2bed94183023b442;hpb=8fde61e3e900d5000c94503679d735221acc1882;p=sdlgit%2FSDL_perl.git diff --git a/lib/SDL/Tool/Graphic.pm b/lib/SDL/Tool/Graphic.pm index 049b31d..697089d 100644 --- a/lib/SDL/Tool/Graphic.pm +++ b/lib/SDL/Tool/Graphic.pm @@ -1,11 +1,38 @@ +#!/usr/bin/env perl # -# SDL::GraphicTool - zooming and rotating graphic tool +# Graphic.pm +# +# Copyright (C) 2005 David J. Goehrig +# +# ------------------------------------------------------------------------------ +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +# +# ------------------------------------------------------------------------------ +# +# Please feel free to send questions, suggestions or improvements to: +# +# David J. Goehrig +# dgoehrig@cpan.org # -# Copyright (C) 2002 Russell E. Valentine -# Copyright (C) 2002 David J. Goehrig package SDL::Tool::Graphic; +use strict; +use warnings; +use Carp; use SDL; use SDL::Config; require SDL::Surface; @@ -13,7 +40,7 @@ require SDL::Surface; sub new { my $proto = shift; my $class = ref($proto) || $proto; - $self = {}; + my $self = {}; bless $self, $class; $self; } @@ -26,7 +53,7 @@ sub DESTROY { sub zoom { my ( $self, $surface, $zoomx, $zoomy, $smooth) = @_; - die "SDL::Tool::Graphic::zoom requires an SDL::Surface\n" + croak "SDL::Tool::Graphic::zoom requires an SDL::Surface\n" unless ( ref($surface) && $surface->isa('SDL::Surface')); my $tmp = $$surface; $$surface = SDL::GFXZoom($$surface, $zoomx, $zoomy, $smooth); @@ -36,7 +63,7 @@ sub zoom { sub rotoZoom { my ( $self, $surface, $angle, $zoom, $smooth) = @_; - die "SDL::Tool::Graphic::rotoZoom requires an SDL::Surface\n" + croak "SDL::Tool::Graphic::rotoZoom requires an SDL::Surface\n" unless ( ref($surface) && $surface->isa('SDL::Surface')); my $tmp = $$surface; $$surface = SDL::GFXRotoZoom($$surface, $angle, $zoom, $smooth); @@ -46,8 +73,9 @@ sub rotoZoom { sub grayScale { my ( $self, $surface ) = @_; + my $workingSurface; if($surface->isa('SDL::Surface')) { - $workingSurface = $$surface; + $workingSurface = $$surface; } else { $workingSurface = $surface; } @@ -71,6 +99,9 @@ sub grayScale { sub invertColor { my ( $self, $surface ) = @_; + #Added because of strict if we needed global + #do $workingSurface init outside subs. + my $workingSurface; if($surface->isa('SDL::Surface')) { $workingSurface = $$surface; } else { @@ -93,51 +124,8 @@ sub invertColor { } } -die "SDL::Tool::Graphic requires SDL_gfx support\n" +croak "SDL::Tool::Graphic requires SDL_gfx support\n" unless SDL::Config->has('SDL_gfx'); 1; - -__END__; - -=pod - - - -=head1 NAME - -SDL::Tool::Graphic - -=head1 DESCRIPTION - -L is a module for zooming and rotating L objects. - -=head1 METHODS - -=head2 zoom ( surface, xzoom, yzoom, smooth ) - -C scales a L along the two axis independently. - -=head2 rotoZoom ( surface, angle, zoom, smooth ) - -C rotates and fixed axis zooms a L. - -=head2 grayScale ( surface ) - -C rotates and fixed axis zooms a L. - -=head2 invertColor ( surface ) - -C inverts the color of a . - - -=head1 AUTHOR - -Russell E. Valentine - -=head1 SEE ALSO - -L L - -=cut