First commit of SDL_Perl-2.1.3
[sdlgit/SDL_perl.git] / lib / SDL / Rect.pm
CommitLineData
8fde61e3 1#
2# Rect.pm
3#
4# A package for manipulating SDL_Rect *
5#
6# Copyright (C) 2003 David J. Goehrig
7
8package SDL::Rect;
9use strict;
10use SDL;
11
12sub new {
13 my $proto = shift;
14 my $class = ref($proto) || $proto;
15 my %options = @_;
16
17 verify (%options, qw/ -x -y -width -height -w -h / ) if $SDL::DEBUG;
18
19 my $x = $options{-x} || 0;
20 my $y = $options{-y} || 0;
21 my $w = $options{-width} || $options{-w} || 0;
22 my $h = $options{-height} || $options{-h} || 0;
23
24 my $self = \SDL::NewRect($x,$y,$w,$h);
25 bless $self,$class;
26 return $self;
27}
28
29sub DESTROY {
30 SDL::FreeRect(${$_[0]});
31}
32
33sub x {
34 my $self = shift;
35 SDL::RectX($$self,@_);
36}
37
38sub y {
39 my $self = shift;
40 SDL::RectY($$self,@_);
41}
42
43sub width {
44 my $self = shift;
45 SDL::RectW($$self,@_);
46}
47
48sub height {
49 my $self = shift;
50 SDL::RectH($$self,@_);
51}
52
531;
54
55__END__;
56
57=pod
58
59
60=head1 NAME
61
62SDL::Rect - a SDL perl extension
63
64=head1 SYNOPSIS
65
66 $rect = new SDL::Rect ( -height => 4, -width => 40 );
67
68=head1 DESCRIPTION
69
70C<SDL::Rect::new> creates a SDL_Rect structure which is
71used for specifying regions for filling, blitting, and updating.
72These objects make it easy to cut and backfill.
73By default, x, y, h, w are 0.
74
75=head2 METHODS
76
77The four fields of a rectangle can be set simply
78by passing a value to the applicable method. These are:
79
80=over 4
81
82=item *
83
84C<SDL::Rect::x> sets and fetches the x position.
85
86=item *
87
88C<SDL::Rect::y> sets and fetches the y position.
89
90=item *
91
92C<SDL::Rect::width> sets and fetched the width.
93
94=item *
95
96C<SDL::Rect::height> sets and fetched the height.
97
98=back
99
100=head1 AUTHOR
101
102David J. Goehrig
103
104=head1 SEE ALSO
105
106perl(1) SDL::Surface(3)
107
108
109=cut
110