2 # SDL::GraphicTool - zooming and rotating graphic tool
4 # Copyright (C) 2002 Russell E. Valentine
5 # Copyright (C) 2002 David J. Goehrig
7 package SDL::Tool::Graphic;
15 my $class = ref($proto) || $proto;
28 my ( $self, $surface, $zoomx, $zoomy, $smooth) = @_;
29 die "SDL::Tool::Graphic::zoom requires an SDL::Surface\n"
30 unless ( ref($surface) && $surface->isa('SDL::Surface'));
32 $$surface = SDL::GFXZoom($$surface, $zoomx, $zoomy, $smooth);
33 SDL::FreeSurface($tmp);
38 my ( $self, $surface, $angle, $zoom, $smooth) = @_;
39 die "SDL::Tool::Graphic::rotoZoom requires an SDL::Surface\n"
40 unless ( ref($surface) && $surface->isa('SDL::Surface'));
42 $$surface = SDL::GFXRotoZoom($$surface, $angle, $zoom, $smooth);
43 SDL::FreeSurface($tmp);
48 my ( $self, $surface ) = @_;
49 if($surface->isa('SDL::Surface')) {
50 $workingSurface = $$surface;
52 $workingSurface = $surface;
55 my $width = SDL::SurfaceW($workingSurface);
56 my $height = SDL::SurfaceH($workingSurface);
57 for(my $x = 0; $x < $width; $x++){
58 for(my $y = 0; $y < $height; $y++){
59 my $origValue = SDL::SurfacePixel($workingSurface, $x, $y);
60 my $newValue = int(0.3*SDL::ColorR($origValue) + 0.59 * SDL::ColorG($origValue) + 0.11*SDL::ColorB($origValue));
61 SDL::SurfacePixel($workingSurface, $x, $y, SDL::NewColor($newValue, $newValue, $newValue));
65 if($surface->isa('SDL::Surface')) {
66 $surface = \$workingSurface;
68 $surface = $workingSurface;
73 my ( $self, $surface ) = @_;
74 if($surface->isa('SDL::Surface')) {
75 $workingSurface = $$surface;
77 $workingSurface = $surface;
79 my $width = SDL::SurfaceW($workingSurface);
80 my $height = SDL::SurfaceH($workingSurface);
81 for(my $x = 0; $x < $width; $x++){
82 for(my $y = 0; $y < $height; $y++){
83 my $origValue = SDL::SurfacePixel($workingSurface, $x, $y);
84 my $newValue = int(0.3*SDL::ColorR($origValue) + 0.59 * SDL::ColorG($origValue) + 0.11*SDL::ColorB($origValue));
85 SDL::SurfacePixel($workingSurface, $x, $y, SDL::NewColor(255-SDL::ColorR($origValue), 255 - SDL::ColorG($origValue), 255 - SDL::ColorB($origValue)));
89 if($surface->isa('SDL::Surface')) {
90 $$surface = $workingSurface;
92 $surface = $workingSurface;
96 die "SDL::Tool::Graphic requires SDL_gfx support\n"
97 unless SDL::Config->has('SDL_gfx');
114 L<SDL::Tool::Graphic> is a module for zooming and rotating L<SDL::Surface> objects.
118 =head2 zoom ( surface, xzoom, yzoom, smooth )
120 C<SDL::Tool::Graphic::zoom> scales a L<SDL::Surface> along the two axis independently.
122 =head2 rotoZoom ( surface, angle, zoom, smooth )
124 C<SDL::Tool::Graphic::rotoZoom> rotates and fixed axis zooms a L<SDL::Surface>.
126 =head2 grayScale ( surface )
128 C<SDL::Tool::Graphic::grayScale> rotates and fixed axis zooms a L<SDL::Surface>.
130 =head2 invertColor ( surface )
132 C<SDL::Tool::Graphic::invertColor> inverts the color of a <SDL::Surface>.
141 L<perl> L<SDL::Surface>