annotate docs/ref/rect.html @ 1849:301bc61643a9 math_module

merged changes from trunk
author lorenz
date Mon, 16 Nov 2009 18:31:40 +0000
parents 02c1e8e9c102
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
1
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
2 <html>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
3 <title>rect - Pygame Documentation</title>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
4 <body bgcolor=#aaeebb text=#000000 link=#331111 vlink=#331111>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
5
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
6
651
8baaf192284f Additions for Overlay.
pygame
parents: 640
diff changeset
7 <table cellpadding=0 cellspacing=0 border=0 style='border: 3px solid black;' width='100%'>
8baaf192284f Additions for Overlay.
pygame
parents: 640
diff changeset
8 <tr>
8baaf192284f Additions for Overlay.
pygame
parents: 640
diff changeset
9 <td bgcolor='#c2fc20' style='padding: 6px;' align=center valign=center><a href='http://www.pygame.org/'><img src='../pygame_tiny.gif' border=0 width=200 height=60></a><br><b>pygame documentation</b></td>
8baaf192284f Additions for Overlay.
pygame
parents: 640
diff changeset
10 <td bgcolor='#6aee28' style='border-left: 3px solid black; padding: 6px;' align=center valign=center>
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
11 ||&nbsp;
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
12 <a href=http://www.pygame.org>Pygame Home</a> &nbsp;||&nbsp;
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
13 <a href=../index.html>Help Contents</a> &nbsp;||
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
14 <a href=index.html>Reference Index</a> &nbsp;||
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
15 <br>&nbsp;<br>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
16
1323
1ca45b50f8ea camera module with v4l2 support and colorspace conversion
Nirav Patel <nrp@eclecti.cc>
parents: 1038
diff changeset
17 <a href="camera.html">Camera</a>&nbsp;||&nbsp;
974
2ceb346f1e9c Fixed typo in docs
marcus
parents: 862
diff changeset
18 <a href="cdrom.html">Cdrom</a>&nbsp;||&nbsp;
1037
c4c38b97db3b Added Color class.
marcus
parents: 974
diff changeset
19 <a href="color.html">Color</a>&nbsp;||&nbsp;
974
2ceb346f1e9c Fixed typo in docs
marcus
parents: 862
diff changeset
20 <a href="cursors.html">Cursors</a>&nbsp;||&nbsp;
2ceb346f1e9c Fixed typo in docs
marcus
parents: 862
diff changeset
21 <a href="display.html">Display</a>&nbsp;||&nbsp;
2ceb346f1e9c Fixed typo in docs
marcus
parents: 862
diff changeset
22 <a href="draw.html">Draw</a>&nbsp;||&nbsp;
2ceb346f1e9c Fixed typo in docs
marcus
parents: 862
diff changeset
23 <a href="event.html">Event</a>&nbsp;||&nbsp;
1448
c496066bc336 add examples module document page
Lenard Lindstrom <len-l@telus.net>
parents: 1419
diff changeset
24 <a href="examples.html">Examples</a>&nbsp;||&nbsp;
974
2ceb346f1e9c Fixed typo in docs
marcus
parents: 862
diff changeset
25 <a href="font.html">Font</a>&nbsp;||&nbsp;
1849
301bc61643a9 merged changes from trunk
lorenz
parents: 1839
diff changeset
26 <a href="freetype.html">Freetype</a>&nbsp;||&nbsp;
1781
1f6df4baebd5 add gfxdraw docs
Lenard Lindstrom <len-l@telus.net>
parents: 1548
diff changeset
27 <a href="gfxdraw.html">Gfxdraw</a>&nbsp;||&nbsp;
974
2ceb346f1e9c Fixed typo in docs
marcus
parents: 862
diff changeset
28 <a href="image.html">Image</a>&nbsp;||&nbsp;
2ceb346f1e9c Fixed typo in docs
marcus
parents: 862
diff changeset
29 <a href="joystick.html">Joystick</a>&nbsp;||&nbsp;
2ceb346f1e9c Fixed typo in docs
marcus
parents: 862
diff changeset
30 <a href="key.html">Key</a>&nbsp;||&nbsp;
1373
d0e31483bd3b Added a pygame.locals module page back into the docs
Lenard Lindstrom <len-l@telus.net>
parents: 1323
diff changeset
31 <a href="locals.html">Locals</a>&nbsp;||&nbsp;
974
2ceb346f1e9c Fixed typo in docs
marcus
parents: 862
diff changeset
32 <a href="mask.html">Mask</a>&nbsp;||&nbsp;
1548
9379bdac652e add event object comparison as per mailing list request
Lenard Lindstrom <len-l@telus.net>
parents: 1506
diff changeset
33 <a href="midi.html">Midi</a>&nbsp;||&nbsp;
974
2ceb346f1e9c Fixed typo in docs
marcus
parents: 862
diff changeset
34 <a href="mixer.html">Mixer</a>&nbsp;||&nbsp;
2ceb346f1e9c Fixed typo in docs
marcus
parents: 862
diff changeset
35 <a href="mouse.html">Mouse</a>&nbsp;||&nbsp;
2ceb346f1e9c Fixed typo in docs
marcus
parents: 862
diff changeset
36 <a href="movie.html">Movie</a>&nbsp;||&nbsp;
2ceb346f1e9c Fixed typo in docs
marcus
parents: 862
diff changeset
37 <a href="music.html">Music</a>&nbsp;||&nbsp;
2ceb346f1e9c Fixed typo in docs
marcus
parents: 862
diff changeset
38 <a href="overlay.html">Overlay</a>&nbsp;||&nbsp;
2ceb346f1e9c Fixed typo in docs
marcus
parents: 862
diff changeset
39 <a href="pixelarray.html">Pixelarray</a>&nbsp;||&nbsp;
2ceb346f1e9c Fixed typo in docs
marcus
parents: 862
diff changeset
40 <a href="pygame.html">Pygame</a>&nbsp;||&nbsp;
2ceb346f1e9c Fixed typo in docs
marcus
parents: 862
diff changeset
41 <a href="rect.html">Rect</a>&nbsp;||&nbsp;
2ceb346f1e9c Fixed typo in docs
marcus
parents: 862
diff changeset
42 <a href="scrap.html">Scrap</a>&nbsp;||&nbsp;
2ceb346f1e9c Fixed typo in docs
marcus
parents: 862
diff changeset
43 <a href="sndarray.html">Sndarray</a>&nbsp;||&nbsp;
2ceb346f1e9c Fixed typo in docs
marcus
parents: 862
diff changeset
44 <a href="sprite.html">Sprite</a>&nbsp;||&nbsp;
2ceb346f1e9c Fixed typo in docs
marcus
parents: 862
diff changeset
45 <a href="surface.html">Surface</a>&nbsp;||&nbsp;
2ceb346f1e9c Fixed typo in docs
marcus
parents: 862
diff changeset
46 <a href="surfarray.html">Surfarray</a>&nbsp;||&nbsp;
1419
5f26c8759fa7 pygame.tests: added docs, go module and polished help messages
Lenard Lindstrom <len-l@telus.net>
parents: 1373
diff changeset
47 <a href="tests.html">Tests</a>&nbsp;||&nbsp;
974
2ceb346f1e9c Fixed typo in docs
marcus
parents: 862
diff changeset
48 <a href="time.html">Time</a>&nbsp;||&nbsp;
2ceb346f1e9c Fixed typo in docs
marcus
parents: 862
diff changeset
49 <a href="transform.html">Transform</a>
651
8baaf192284f Additions for Overlay.
pygame
parents: 640
diff changeset
50 </td></tr></table>
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
51 <br>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
52
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
53
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
54 <a name="pygame.Rect">
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
55 <big><b>pygame.Rect</big></b><br><ul>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
56 <i>pygame object for storing rectangular coordinates</i><br>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
57 <tt>pygame.Rect(left, top, width, height): return Rect</tt><br>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
58 <tt>pygame.Rect((left, top), (width, height)): return Rect</tt><br>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
59 <tt>pygame.Rect(object): return Rect</tt><br>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
60 <ul><small><table>
1506
a60459a910fd Bugzilla feature request 25: add Rect.copy method
Lenard Lindstrom <len-l@telus.net>
parents: 1448
diff changeset
61 <tr><td><a href="rect.html#Rect.copy">Rect.copy</a> - <font size=-1>copy the rectangle</font></td><td>copy the rectangle</td></tr>
651
8baaf192284f Additions for Overlay.
pygame
parents: 640
diff changeset
62 <tr><td><a href="rect.html#Rect.move">Rect.move</a> - <font size=-1>moves the rectangle</font></td><td>moves the rectangle</td></tr>
8baaf192284f Additions for Overlay.
pygame
parents: 640
diff changeset
63 <tr><td><a href="rect.html#Rect.move_ip">Rect.move_ip</a> - <font size=-1>moves the rectangle, in place</font></td><td>moves the rectangle, in place</td></tr>
8baaf192284f Additions for Overlay.
pygame
parents: 640
diff changeset
64 <tr><td><a href="rect.html#Rect.inflate">Rect.inflate</a> - <font size=-1>grow or shrink the rectangle size</font></td><td>grow or shrink the rectangle size</td></tr>
8baaf192284f Additions for Overlay.
pygame
parents: 640
diff changeset
65 <tr><td><a href="rect.html#Rect.inflate_ip">Rect.inflate_ip</a> - <font size=-1>grow or shrink the rectangle size, in place</font></td><td>grow or shrink the rectangle size, in place</td></tr>
8baaf192284f Additions for Overlay.
pygame
parents: 640
diff changeset
66 <tr><td><a href="rect.html#Rect.clamp">Rect.clamp</a> - <font size=-1>moves the rectangle inside another</font></td><td>moves the rectangle inside another</td></tr>
8baaf192284f Additions for Overlay.
pygame
parents: 640
diff changeset
67 <tr><td><a href="rect.html#Rect.clamp_ip">Rect.clamp_ip</a> - <font size=-1>moves the rectangle inside another, in place</font></td><td>moves the rectangle inside another, in place</td></tr>
8baaf192284f Additions for Overlay.
pygame
parents: 640
diff changeset
68 <tr><td><a href="rect.html#Rect.clip">Rect.clip</a> - <font size=-1>crops a rectangle inside another</font></td><td>crops a rectangle inside another</td></tr>
8baaf192284f Additions for Overlay.
pygame
parents: 640
diff changeset
69 <tr><td><a href="rect.html#Rect.union">Rect.union</a> - <font size=-1>joins two rectangles into one</font></td><td>joins two rectangles into one</td></tr>
8baaf192284f Additions for Overlay.
pygame
parents: 640
diff changeset
70 <tr><td><a href="rect.html#Rect.union_ip">Rect.union_ip</a> - <font size=-1>joins two rectangles into one, in place</font></td><td>joins two rectangles into one, in place</td></tr>
8baaf192284f Additions for Overlay.
pygame
parents: 640
diff changeset
71 <tr><td><a href="rect.html#Rect.unionall">Rect.unionall</a> - <font size=-1>the union of many rectangles</font></td><td>the union of many rectangles</td></tr>
8baaf192284f Additions for Overlay.
pygame
parents: 640
diff changeset
72 <tr><td><a href="rect.html#Rect.unionall_ip">Rect.unionall_ip</a> - <font size=-1>the union of many rectangles, in place</font></td><td>the union of many rectangles, in place</td></tr>
8baaf192284f Additions for Overlay.
pygame
parents: 640
diff changeset
73 <tr><td><a href="rect.html#Rect.fit">Rect.fit</a> - <font size=-1>resize and move a rectangle with aspect ratio</font></td><td>resize and move a rectangle with aspect ratio</td></tr>
8baaf192284f Additions for Overlay.
pygame
parents: 640
diff changeset
74 <tr><td><a href="rect.html#Rect.normalize">Rect.normalize</a> - <font size=-1>correct negative sizes</font></td><td>correct negative sizes</td></tr>
8baaf192284f Additions for Overlay.
pygame
parents: 640
diff changeset
75 <tr><td><a href="rect.html#Rect.contains">Rect.contains</a> - <font size=-1>test if one rectangle is inside another</font></td><td>test if one rectangle is inside another</td></tr>
8baaf192284f Additions for Overlay.
pygame
parents: 640
diff changeset
76 <tr><td><a href="rect.html#Rect.collidepoint">Rect.collidepoint</a> - <font size=-1>test if a point is inside a rectangle</font></td><td>test if a point is inside a rectangle</td></tr>
8baaf192284f Additions for Overlay.
pygame
parents: 640
diff changeset
77 <tr><td><a href="rect.html#Rect.colliderect">Rect.colliderect</a> - <font size=-1>test if two rectangles overlap</font></td><td>test if two rectangles overlap</td></tr>
8baaf192284f Additions for Overlay.
pygame
parents: 640
diff changeset
78 <tr><td><a href="rect.html#Rect.collidelist">Rect.collidelist</a> - <font size=-1>test if one rectangle in a list intersects</font></td><td>test if one rectangle in a list intersects</td></tr>
8baaf192284f Additions for Overlay.
pygame
parents: 640
diff changeset
79 <tr><td><a href="rect.html#Rect.collidelistall">Rect.collidelistall</a> - <font size=-1>test if all rectangles in a list intersect</font></td><td>test if all rectangles in a list intersect</td></tr>
8baaf192284f Additions for Overlay.
pygame
parents: 640
diff changeset
80 <tr><td><a href="rect.html#Rect.collidedict">Rect.collidedict</a> - <font size=-1>test if one rectangle in a dictionary intersects</font></td><td>test if one rectangle in a dictionary intersects</td></tr>
8baaf192284f Additions for Overlay.
pygame
parents: 640
diff changeset
81 <tr><td><a href="rect.html#Rect.collidedictall">Rect.collidedictall</a> - <font size=-1>test if all rectangles in a dictionary intersect</font></td><td>test if all rectangles in a dictionary intersect</td></tr>
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
82 </table></small></ul>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
83 <p>Pygame uses Rect objects to store and manipulate rectangular areas. <tt>A</tt> Rect can be created from a combination of left, top, width, and height values. Rects can also be created from python objects that are already a Rect or have an attribute named "rect". </p>
629
85f2ac863647 documentation revisions from Dan Richter
pygame
parents: 627
diff changeset
84 <p>Any Pygame function that requires a Rect argument also accepts any of these values to construct a Rect. This makes it easier to create Rects on the fly as arguments to functions. </p>
710
28bbafc4d9de More documentation fixes from Dan Richter
pygame
parents: 678
diff changeset
85 <p>The Rect functions that change the position or size of a Rect return a new copy of the Rect with the affected changes. The original Rect is not modified. Some methods have an alternate "in-place" version that returns None but effects the original Rect. These "in-place" methods are denoted with the "ip" suffix. </p>
629
85f2ac863647 documentation revisions from Dan Richter
pygame
parents: 627
diff changeset
86 <p>The Rect object has several virtual attributes which can be used to move and align the Rect: </p>
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
87 <pre> top, left, bottom, right
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
88 topleft, bottomleft, topright, bottomright
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
89 midtop, midleft, midbottom, midright
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
90 center, centerx, centery
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
91 size, width, height
786
4caa22563398 Almost ready for the 1.8.0rc1 release.
Rene Dudfield <renesd@gmail.com>
parents: 710
diff changeset
92 w,h
629
85f2ac863647 documentation revisions from Dan Richter
pygame
parents: 627
diff changeset
93 </pre><p>All of these attributes can be assigned to: </p>
85f2ac863647 documentation revisions from Dan Richter
pygame
parents: 627
diff changeset
94 <pre> rect1.right = 10
85f2ac863647 documentation revisions from Dan Richter
pygame
parents: 627
diff changeset
95 rect2.center = (20,30)
85f2ac863647 documentation revisions from Dan Richter
pygame
parents: 627
diff changeset
96 </pre><p>Assigning to size, width or height changes the dimensions of the rectangle; all other assignments move the rectangle without resizing it. Notice that some attributes are integers and others are pairs of integers. </p>
85f2ac863647 documentation revisions from Dan Richter
pygame
parents: 627
diff changeset
97 <p>If a Rect has a nonzero width or height, it will return True for a nonzero test. Some methods return a Rect with 0 size to represent an invalid rectangle. </p>
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
98 <p>The coordinates for Rect objects are all integers. The size values can be programmed to have negative values, but these are considered illegal Rects for most operations. </p>
629
85f2ac863647 documentation revisions from Dan Richter
pygame
parents: 627
diff changeset
99 <p>There are several collision tests between other rectangles. Most python containers can be searched for collisions against a single Rect. </p>
85f2ac863647 documentation revisions from Dan Richter
pygame
parents: 627
diff changeset
100 <p>The area covered by a Rect does not include the right- and bottom-most edge of pixels. If one Rect's bottom border is another Rect's top border <tt>(i.e.</tt>, <tt>rect1.bottom=rect2.top)</tt>, the two meet exactly on the screen but do not overlap, and <tt>rect1.colliderect(rect2)</tt> returns false. </p>
1839
02c1e8e9c102 merged changes from trunk to math_module branch
lorenz
parents: 1781
diff changeset
101 <p>Though Rect can be subclassed, methods that return new rectangles are not subclass aware. That is, move or copy return a new <tt>pygame.Rect</tt> instance, not an instance of the subclass. This may change. To make subclass awareness work though, subclasses may have to maintain the same constructor signature as Rect. </p>
640
228ab19991cf Updated header image, and docs links.
Rene Dudfield <renesd@gmail.com>
parents: 629
diff changeset
102 <!--COMMENTS:pygame.Rect--> &nbsp;<br>
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
103
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
104
1506
a60459a910fd Bugzilla feature request 25: add Rect.copy method
Lenard Lindstrom <len-l@telus.net>
parents: 1448
diff changeset
105 <a name="Rect.copy">
a60459a910fd Bugzilla feature request 25: add Rect.copy method
Lenard Lindstrom <len-l@telus.net>
parents: 1448
diff changeset
106 <big><b>Rect.copy</big></b><br><ul>
a60459a910fd Bugzilla feature request 25: add Rect.copy method
Lenard Lindstrom <len-l@telus.net>
parents: 1448
diff changeset
107 <i>copy the rectangle</i><br>
a60459a910fd Bugzilla feature request 25: add Rect.copy method
Lenard Lindstrom <len-l@telus.net>
parents: 1448
diff changeset
108 <tt>Rect.copy(): return Rect</tt><br>
a60459a910fd Bugzilla feature request 25: add Rect.copy method
Lenard Lindstrom <len-l@telus.net>
parents: 1448
diff changeset
109 <p>Returns a new rectangle having the same position and size as the orginal. </p>
1849
301bc61643a9 merged changes from trunk
lorenz
parents: 1839
diff changeset
110 <p>New in pygame <tt>1.9</tt> </p>
1506
a60459a910fd Bugzilla feature request 25: add Rect.copy method
Lenard Lindstrom <len-l@telus.net>
parents: 1448
diff changeset
111 <!--COMMENTS:Rect.copy--> &nbsp;<br>
a60459a910fd Bugzilla feature request 25: add Rect.copy method
Lenard Lindstrom <len-l@telus.net>
parents: 1448
diff changeset
112 <br></ul>
a60459a910fd Bugzilla feature request 25: add Rect.copy method
Lenard Lindstrom <len-l@telus.net>
parents: 1448
diff changeset
113
a60459a910fd Bugzilla feature request 25: add Rect.copy method
Lenard Lindstrom <len-l@telus.net>
parents: 1448
diff changeset
114
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
115 <a name="Rect.move">
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
116 <big><b>Rect.move</big></b><br><ul>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
117 <i>moves the rectangle</i><br>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
118 <tt>Rect.move(x, y): return Rect</tt><br>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
119 <p>Returns a new rectangle that is moved by the given offset. The x and y arguments can be any integer value, positive or negative. </p>
640
228ab19991cf Updated header image, and docs links.
Rene Dudfield <renesd@gmail.com>
parents: 629
diff changeset
120 <!--COMMENTS:Rect.move--> &nbsp;<br>
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
121 <br></ul>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
122
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
123
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
124 <a name="Rect.move_ip">
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
125 <big><b>Rect.move_ip</big></b><br><ul>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
126 <i>moves the rectangle, in place</i><br>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
127 <tt>Rect.move_ip(x, y): return None</tt><br>
651
8baaf192284f Additions for Overlay.
pygame
parents: 640
diff changeset
128 <p>Same as the <tt><a href="rect.html#Rect.move">Rect.move</a> - <font size=-1>moves the rectangle</font></tt> method, but operates in place. </p>
640
228ab19991cf Updated header image, and docs links.
Rene Dudfield <renesd@gmail.com>
parents: 629
diff changeset
129 <!--COMMENTS:Rect.move_ip--> &nbsp;<br>
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
130 <br></ul>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
131
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
132
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
133 <a name="Rect.inflate">
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
134 <big><b>Rect.inflate</big></b><br><ul>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
135 <i>grow or shrink the rectangle size</i><br>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
136 <tt>Rect.inflate(x, y): return Rect</tt><br>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
137 <p>Returns a new rectangle with the size changed by the given offset. The rectangle remains centered around its current center. Negative values will shrink the rectangle. </p>
640
228ab19991cf Updated header image, and docs links.
Rene Dudfield <renesd@gmail.com>
parents: 629
diff changeset
138 <!--COMMENTS:Rect.inflate--> &nbsp;<br>
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
139 <br></ul>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
140
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
141
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
142 <a name="Rect.inflate_ip">
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
143 <big><b>Rect.inflate_ip</big></b><br><ul>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
144 <i>grow or shrink the rectangle size, in place</i><br>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
145 <tt>Rect.inflate_ip(x, y): return None</tt><br>
651
8baaf192284f Additions for Overlay.
pygame
parents: 640
diff changeset
146 <p>Same as the <tt><a href="rect.html#Rect.inflate">Rect.inflate</a> - <font size=-1>grow or shrink the rectangle size</font></tt> method, but operates in place. </p>
640
228ab19991cf Updated header image, and docs links.
Rene Dudfield <renesd@gmail.com>
parents: 629
diff changeset
147 <!--COMMENTS:Rect.inflate_ip--> &nbsp;<br>
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
148 <br></ul>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
149
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
150
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
151 <a name="Rect.clamp">
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
152 <big><b>Rect.clamp</big></b><br><ul>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
153 <i>moves the rectangle inside another</i><br>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
154 <tt>Rect.clamp(Rect): return Rect</tt><br>
629
85f2ac863647 documentation revisions from Dan Richter
pygame
parents: 627
diff changeset
155 <p>Returns a new rectangle that is moved to be completely inside the argument Rect. If the rectangle is too large to fit inside, it is centered inside the argument Rect, but its size is not changed. </p>
640
228ab19991cf Updated header image, and docs links.
Rene Dudfield <renesd@gmail.com>
parents: 629
diff changeset
156 <!--COMMENTS:Rect.clamp--> &nbsp;<br>
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
157 <br></ul>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
158
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
159
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
160 <a name="Rect.clamp_ip">
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
161 <big><b>Rect.clamp_ip</big></b><br><ul>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
162 <i>moves the rectangle inside another, in place</i><br>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
163 <tt>Rect.clamp_ip(Rect): return None</tt><br>
651
8baaf192284f Additions for Overlay.
pygame
parents: 640
diff changeset
164 <p>Same as the <tt><a href="rect.html#Rect.clamp">Rect.clamp</a> - <font size=-1>moves the rectangle inside another</font></tt> method, but operates in place. </p>
640
228ab19991cf Updated header image, and docs links.
Rene Dudfield <renesd@gmail.com>
parents: 629
diff changeset
165 <!--COMMENTS:Rect.clamp_ip--> &nbsp;<br>
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
166 <br></ul>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
167
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
168
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
169 <a name="Rect.clip">
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
170 <big><b>Rect.clip</big></b><br><ul>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
171 <i>crops a rectangle inside another</i><br>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
172 <tt>Rect.clip(Rect): return Rect</tt><br>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
173 <p>Returns a new rectangle that is cropped to be completely inside the argument Rect. If the two rectangles do not overlap to begin with, a Rect with 0 size is returned. </p>
640
228ab19991cf Updated header image, and docs links.
Rene Dudfield <renesd@gmail.com>
parents: 629
diff changeset
174 <!--COMMENTS:Rect.clip--> &nbsp;<br>
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
175 <br></ul>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
176
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
177
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
178 <a name="Rect.union">
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
179 <big><b>Rect.union</big></b><br><ul>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
180 <i>joins two rectangles into one</i><br>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
181 <tt>Rect.union(Rect): return Rect</tt><br>
629
85f2ac863647 documentation revisions from Dan Richter
pygame
parents: 627
diff changeset
182 <p>Returns a new rectangle that completely covers the area of the two provided rectangles. There may be area inside the new Rect that is not covered by the originals. </p>
640
228ab19991cf Updated header image, and docs links.
Rene Dudfield <renesd@gmail.com>
parents: 629
diff changeset
183 <!--COMMENTS:Rect.union--> &nbsp;<br>
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
184 <br></ul>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
185
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
186
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
187 <a name="Rect.union_ip">
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
188 <big><b>Rect.union_ip</big></b><br><ul>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
189 <i>joins two rectangles into one, in place</i><br>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
190 <tt>Rect.union_ip(Rect): return None</tt><br>
651
8baaf192284f Additions for Overlay.
pygame
parents: 640
diff changeset
191 <p>Same as the <tt><a href="rect.html#Rect.union">Rect.union</a> - <font size=-1>joins two rectangles into one</font></tt> method, but operates in place. </p>
640
228ab19991cf Updated header image, and docs links.
Rene Dudfield <renesd@gmail.com>
parents: 629
diff changeset
192 <!--COMMENTS:Rect.union_ip--> &nbsp;<br>
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
193 <br></ul>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
194
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
195
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
196 <a name="Rect.unionall">
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
197 <big><b>Rect.unionall</big></b><br><ul>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
198 <i>the union of many rectangles</i><br>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
199 <tt>Rect.unionall(Rect_sequence): return Rect</tt><br>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
200 <p>Returns the union of one rectangle with a sequence of many rectangles. </p>
640
228ab19991cf Updated header image, and docs links.
Rene Dudfield <renesd@gmail.com>
parents: 629
diff changeset
201 <!--COMMENTS:Rect.unionall--> &nbsp;<br>
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
202 <br></ul>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
203
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
204
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
205 <a name="Rect.unionall_ip">
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
206 <big><b>Rect.unionall_ip</big></b><br><ul>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
207 <i>the union of many rectangles, in place</i><br>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
208 <tt>Rect.unionall_ip(Rect_sequence): return None</tt><br>
651
8baaf192284f Additions for Overlay.
pygame
parents: 640
diff changeset
209 <p>The same as the <tt><a href="rect.html#Rect.unionall">Rect.unionall</a> - <font size=-1>the union of many rectangles</font></tt> method, but operates in place. </p>
640
228ab19991cf Updated header image, and docs links.
Rene Dudfield <renesd@gmail.com>
parents: 629
diff changeset
210 <!--COMMENTS:Rect.unionall_ip--> &nbsp;<br>
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
211 <br></ul>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
212
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
213
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
214 <a name="Rect.fit">
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
215 <big><b>Rect.fit</big></b><br><ul>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
216 <i>resize and move a rectangle with aspect ratio</i><br>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
217 <tt>Rect.fit(Rect): return Rect</tt><br>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
218 <p>Returns a new rectangle that is moved and resized to fit another. The aspect ratio of the original Rect is preserved, so the new rectangle may be smaller than the target in either width or height. </p>
640
228ab19991cf Updated header image, and docs links.
Rene Dudfield <renesd@gmail.com>
parents: 629
diff changeset
219 <!--COMMENTS:Rect.fit--> &nbsp;<br>
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
220 <br></ul>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
221
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
222
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
223 <a name="Rect.normalize">
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
224 <big><b>Rect.normalize</big></b><br><ul>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
225 <i>correct negative sizes</i><br>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
226 <tt>Rect.normalize(): return None</tt><br>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
227 <p>This will flip the width or height of a rectangle if it has a negative size. The rectangle will remain in the same place, with only the sides swapped. </p>
640
228ab19991cf Updated header image, and docs links.
Rene Dudfield <renesd@gmail.com>
parents: 629
diff changeset
228 <!--COMMENTS:Rect.normalize--> &nbsp;<br>
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
229 <br></ul>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
230
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
231
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
232 <a name="Rect.contains">
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
233 <big><b>Rect.contains</big></b><br><ul>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
234 <i>test if one rectangle is inside another</i><br>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
235 <tt>Rect.contains(Rect): return bool</tt><br>
629
85f2ac863647 documentation revisions from Dan Richter
pygame
parents: 627
diff changeset
236 <p>Returns true when the argument is completely inside the Rect. </p>
640
228ab19991cf Updated header image, and docs links.
Rene Dudfield <renesd@gmail.com>
parents: 629
diff changeset
237 <!--COMMENTS:Rect.contains--> &nbsp;<br>
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
238 <br></ul>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
239
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
240
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
241 <a name="Rect.collidepoint">
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
242 <big><b>Rect.collidepoint</big></b><br><ul>
629
85f2ac863647 documentation revisions from Dan Richter
pygame
parents: 627
diff changeset
243 <i>test if a point is inside a rectangle</i><br>
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
244 <tt>Rect.collidepoint(x, y): return bool</tt><br>
786
4caa22563398 Almost ready for the 1.8.0rc1 release.
Rene Dudfield <renesd@gmail.com>
parents: 710
diff changeset
245 <tt>Rect.collidepoint((x,y)): return bool</tt><br>
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
246 <p>Returns true if the given point is inside the rectangle. <tt>A</tt> point along the right or bottom edge is not considered to be inside the rectangle. </p>
640
228ab19991cf Updated header image, and docs links.
Rene Dudfield <renesd@gmail.com>
parents: 629
diff changeset
247 <!--COMMENTS:Rect.collidepoint--> &nbsp;<br>
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
248 <br></ul>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
249
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
250
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
251 <a name="Rect.colliderect">
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
252 <big><b>Rect.colliderect</big></b><br><ul>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
253 <i>test if two rectangles overlap</i><br>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
254 <tt>Rect.colliderect(Rect): return bool</tt><br>
629
85f2ac863647 documentation revisions from Dan Richter
pygame
parents: 627
diff changeset
255 <p>Returns true if any portion of either rectangle overlap (except the top+bottom or left+right edges). </p>
640
228ab19991cf Updated header image, and docs links.
Rene Dudfield <renesd@gmail.com>
parents: 629
diff changeset
256 <!--COMMENTS:Rect.colliderect--> &nbsp;<br>
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
257 <br></ul>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
258
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
259
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
260 <a name="Rect.collidelist">
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
261 <big><b>Rect.collidelist</big></b><br><ul>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
262 <i>test if one rectangle in a list intersects</i><br>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
263 <tt>Rect.collidelist(list): return index</tt><br>
629
85f2ac863647 documentation revisions from Dan Richter
pygame
parents: 627
diff changeset
264 <p>Test whether the rectangle collides with any in a sequence of rectangles. The index of the first collision found is returned. If no collisions are found an index of -1 is returned. </p>
640
228ab19991cf Updated header image, and docs links.
Rene Dudfield <renesd@gmail.com>
parents: 629
diff changeset
265 <!--COMMENTS:Rect.collidelist--> &nbsp;<br>
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
266 <br></ul>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
267
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
268
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
269 <a name="Rect.collidelistall">
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
270 <big><b>Rect.collidelistall</big></b><br><ul>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
271 <i>test if all rectangles in a list intersect</i><br>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
272 <tt>Rect.collidelistall(list): return indices</tt><br>
629
85f2ac863647 documentation revisions from Dan Richter
pygame
parents: 627
diff changeset
273 <p>Returns a list of all the indices that contain rectangles that collide with the Rect. If no intersecting rectangles are found, an empty list is returned. </p>
640
228ab19991cf Updated header image, and docs links.
Rene Dudfield <renesd@gmail.com>
parents: 629
diff changeset
274 <!--COMMENTS:Rect.collidelistall--> &nbsp;<br>
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
275 <br></ul>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
276
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
277
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
278 <a name="Rect.collidedict">
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
279 <big><b>Rect.collidedict</big></b><br><ul>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
280 <i>test if one rectangle in a dictionary intersects</i><br>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
281 <tt>Rect.collidedict(dict): return (key, value)</tt><br>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
282 <p>Returns the key and value of the first dictionary value that collides with the Rect. If no collisions are found, None is returned. </p>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
283 <p>Rect objects are not hashable and cannot be used as keys in a dictionary, only as values. </p>
640
228ab19991cf Updated header image, and docs links.
Rene Dudfield <renesd@gmail.com>
parents: 629
diff changeset
284 <!--COMMENTS:Rect.collidedict--> &nbsp;<br>
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
285 <br></ul>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
286
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
287
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
288 <a name="Rect.collidedictall">
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
289 <big><b>Rect.collidedictall</big></b><br><ul>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
290 <i>test if all rectangles in a dictionary intersect</i><br>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
291 <tt>Rect.collidedictall(dict): return [(key, value), ...]</tt><br>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
292 <p>Returns a list of all the key and value pairs that intersect with the Rect. If no collisions are found an empty dictionary is returned. </p>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
293 <p>Rect objects are not hashable and cannot be used as keys in a dictionary, only as values. </p>
640
228ab19991cf Updated header image, and docs links.
Rene Dudfield <renesd@gmail.com>
parents: 629
diff changeset
294 <!--COMMENTS:Rect.collidedictall--> &nbsp;<br>
627
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
295 <br></ul>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
296 <br></ul>
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
297
18b5fa9180bf new reference documentation system
pygame
parents:
diff changeset
298 </body></html>