/usr/lib/perl5/pods/SDLx/Rect.pod is in libsdl-perl 2.540-5.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 | =head1 NAME
SDLx::Rect - SDL extension for storing and manipulating rectangular coordinates
=head1 CATEGORY
Extension
=head1 SYNOPSIS
SDLx::Rect works as a SDL::Rect in the lower layer (SDL::*) but provides more methods to users.
use SDLx::Rect; #instead of SDL::Rect
my $rect = SDLx::Rect->new( $x, $y, $w, $h); #same as SDL::Rect
...
SDL::Video::fill_rect( .. , $rect, ...); # use like SDL::Rect
=head1 DESCRIPTION
C<< SDLx::Rect >> object are used to store and manipulate rectangular areas. Rect objects are created from a combination of left (or x), top (or y), width (or w) and height (or h) values, just like raw C<< SDL::Rect objects >>.
All C<< SDLx::Rect >> methods that change either position or size of a Rect return B<a new copy> of the Rect with the affected changes. The original Rect is B<not> modified. If you wish to modify the current Rect object, you can use the equivalent "in-place" methods that do not return but instead affects the original Rect. These "in-place" methods are denoted with the "ip" suffix. Note that changing a Rect's attribute is I<always> an in-place operation.
=head2 ATTRIBUTES
All Rect attributes are accessors, meaning you can get them by name, and set them by passing a value:
$rect->left(15);
$rect->left; # 15
The Rect object has several attributes which can be used to resize, move and align the Rect.
=over 4
=item * width, w - gets/sets object's width
=item * height, h - gets/sets object's height
=item * left, x - moves the object left position to match the given coordinate
=item * top, y - moves the object top position to match the given coordinate
=item * bottom - moves the object bottom position to match the given coordinate
=item * right - moves the object right position to match the given coordinate
=item * centerx - moves the object's horizontal center to match the given coordinate
=item * centery - moves the object's vertical center to match the given coordinate
=back
Some of the attributes above can be fetched or set in pairs:
$rect->topleft(10, 15); # top is now 10, left is now 15
my ($width, $height) = $rect->size;
=over 4
=item * size - gets/sets object's size (width, height)
=item * topleft - gets/sets object's top and left positions
=item * midleft - gets/sets object's vertical center and left positions
=item * bottomleft - gets/sets object's bottom and left positions
=item * center - gets/sets object's center (horizontal(x), vertical(y))
=item * topright - gets/sets object's top and right positions
=item * midright - gets/sets object's vertical center and right positions
=item * bottomright - gets/sets object's bottom and right positions
=item * midtop - gets/sets object's horizontal center and top positions
=item * midbottom - gets/sets object's horizontal center and bottom positions
=back
=head2 METHODS
Methods denoted as receiving Rect objects can receive either C<<SDLx::Rect>> or raw C<<SDL::Rect>> objects.
=head3 new ($left, $top, $width, $height)
Returns a new Rect object with the given coordinates. If any value is omitted (by passing undef), 0 is used instead.
=head3 copy
=head3 duplicate
Returns a new Rect object having the same position and size as the original
=head3 move(x, y)
Returns a new Rect that is moved by the given offset. The x and y arguments can be any integer value, positive or negative.
=head3 move_ip(x, y)
Same as C<<move>> above, but moves the current Rect in place and returns nothing.
=head3 inflate(x, y)
Grows or shrinks the rectangle. Returns a new Rect with the size changed by the given offset. The rectangle remains centered around its current center. Negative values will return a shrunken rectangle instead.
=head3 inflate_ip(x, y)
Same as C<<inflate>> above, but grows/shrinks the current Rect in place and returns nothing.
=head3 clamp($rect)
Returns a new Rect moved to be completely inside the Rect object passed as an argument. If the current Rect is too large to fit inside the passed Rect, it is centered inside it, but its size is not changed.
=head3 clamp_ip($rect)
Same as C<<clamp>> above, but moves the current Rect in place and returns nothing.
=head3 clip($rect)
Returns a new Rect with the intersection between the two Rect objects, that is, returns a new Rect cropped to be completely inside the Rect object passed as an argument. If the two rectangles do not overlap to begin with, a Rect with 0 size is returned, in the original Rect's (x,y) coordinates.
=head3 clip_ip($rect)
Same as C<<clip>> above, but crops the current Rect in place and returns nothing. As the original method, the Rect becomes zero-sized if the two rectangles do not overlap to begin with, retaining its (x, y) coordinates.
=head3 union($rect)
Returns a new rectangle that completely covers the area of the current Rect and the one passed as an argument. There may be area inside the new Rect that is not covered by the originals.
=head3 union_ip($rect)
Same as C<<union>> above, but resizes the current Rect in place and returns nothing.
=head3 unionall( [$rect1, $rect2, ...] )
Returns the union of one rectangle with a sequence of many rectangles, passed as an ARRAY REF.
=head3 unionall_ip( [$rect1, $rect2, ...] )
Same as C<<unionall>> above, but resizes the current Rect in place and returns nothing.
=head3 fit($rect)
Returns a new Rect moved and resized to fit the Rect object passed as an argument. The aspect ratio of the original Rect is preserved, so the new rectangle may be smaller than the target in either width or height.
=head3 fit_ip($rect)
Same as C<<fit>> above, but moves/resizes the current Rect in place and returns nothing.
=head3 normalize
Corrects negative sizes, flipping width/height of the Rect if they have a negative size. No repositioning is made so the rectangle will remain in the same place, but the negative sides will be swapped. This method returns nothing.
=head3 contains($rect)
Returns true (non-zero) when the argument is completely inside the Rect. Otherwise returns undef.
=head3 collidepoint(x, y)
Returns true (non-zero) if the given point is inside the Rect, otherwise returns undef. A point along the right or bottom edge is not considered to be inside the rectangle.
=head3 colliderect($rect)
Returns true (non-zero) if any portion of either rectangles overlap (except for the top+bottom or left+right edges).
=head3 collidelist( [$rect1, $rect2, ...] )
Test whether the rectangle collides with any in a sequence of rectangles, passed as an ARRAY REF. The index of the first collision found is returned. Returns undef if no collisions are found.
=head3 collidelistall( [$rect1, $rect2, ...] )
Returns an ARRAY REF of all the indices that contain rectangles that collide with the Rect. If no intersecting rectangles are found, an empty list ref is returned.
=head3 collidehash( {key1 => $rect1, key2 => $rect2, ...} )
Receives a HASH REF and returns the a (key, value) list with the key and value of the first hash item that collides with the Rect. If no collisions are found, returns (undef, undef).
=head3 collidehashall( {key1 => $rect1, key2 => $rect2, ...} )
Returns a HASH REF of all the key and value pairs that intersect with the Rect. If no collisions are found an empty hash ref is returned.
=head1 BUGS
Please report any bugs or feature requests to the bug tracker. I will be notified, and then you'll automatically be notified of progress on your bug as we make changes.
=head1 SUPPORT
You can find documentation for this module with the perldoc command.
perldoc SDLx::Rect
=head1 AUTHORS
See L<SDL/AUTHORS>.
=head1 ACKNOWLEDGEMENTS
Many thanks to the authors of pygame.rect, in which this particular module is heavily based.
=head1 COPYRIGHT & LICENSE
This program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
=head1 SEE ALSO
perl, L<SDL>, L<SDL::Rect>, L<SDL::Game>
|