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