5 # Copyright (C) 2005 David J. Goehrig <dgoehrig@cpan.org>
7 # ------------------------------------------------------------------------------
9 # This library is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU Lesser General Public
11 # License as published by the Free Software Foundation; either
12 # version 2.1 of the License, or (at your option) any later version.
14 # This library is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 # Lesser General Public License for more details.
19 # You should have received a copy of the GNU Lesser General Public
20 # License along with this library; if not, write to the Free Software
21 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 # ------------------------------------------------------------------------------
25 # Please feel free to send questions, suggestions or improvements to:
39 my $class = ref($proto) || $proto;
42 verify (%options, qw/ -x -y -top -left -width -height -w -h / ) if $SDL::DEBUG;
44 my $x = $options{-x} || $options{-left} || 0;
45 my $y = $options{-y} || $options{-top} || 0;
46 my $w = $options{-width} || $options{-w} || 0;
47 my $h = $options{-height} || $options{-h} || 0;
49 my $self = \SDL::NewRect($x,$y,$w,$h);
52 Carp::croak SDL::GetError();
59 SDL::FreeRect(${$_[0]});
62 # TODO: mangle with the symbol table to create an alias
63 # to sub x. We could call x from inside the sub but that
64 # would be another call and rects are a time-critical object.
67 SDL::RectX($$self,@_);
72 SDL::RectX($$self,@_);
75 ### TODO: see 'left' above (this is an 'alias' to sub y)
78 SDL::RectY($$self,@_);
83 SDL::RectY($$self,@_);
86 ### TODO: see 'left' above (this is an 'alias' to sub width)
89 SDL::RectW($$self,@_);
94 SDL::RectW($$self,@_);
97 ### TODO: see 'left' above (this is an 'alias' to sub height)
100 SDL::RectH($$self,@_);
105 SDL::RectH($$self,@_);
114 SDL::Rect - raw object for storing rectangular coordinates
118 my $rect = SDL::Rect->new( -height => 4, -width => 40 );
120 $rect->x(12); # same as $rect->left(12)
121 $rect->y(9); # same as $rect->top(9)
125 C<SDL::Rect::new> creates a SDL_Rect structure which is
126 used for specifying regions of pixels for filling, blitting, and updating.
127 These objects make it easy to cut and backfill.
129 By default, x, y, height and width are all set to 0.
133 The four fields of a rectangle can be set simply
134 by passing a value to the applicable method. These are:
140 sets and fetches the x (lefmost) position of the rectangle.
146 sets and fetches the y (topmost) position.
152 sets and fetches the width of the rectangle (in pixels).
158 sets and fetches the height of the rectangle (in pixels).
166 perl(1) SDL::Surface(3)