~ubuntu-branches/ubuntu/gutsy/pygame/gutsy

« back to all changes in this revision

Viewing changes to docs/ref/Rect.html

  • Committer: Bazaar Package Importer
  • Author(s): Ed Boraas
  • Date: 2002-02-20 06:39:24 UTC
  • Revision ID: james.westby@ubuntu.com-20020220063924-amlzj7tqkeods4eq
Tags: upstream-1.4
ImportĀ upstreamĀ versionĀ 1.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<html>
 
2
<title>Rect</title>
 
3
<body bgcolor=#aaeebb text=#000000 link=#331111 vlink=#331111>
 
4
 
 
5
 
 
6
<table cellspacing=3 width=100%><tr><td bgcolor=#00000>
 
7
<table width=100%><tr><td bgcolor=c2fc20 align=center>
 
8
    <a href=http://www.pygame.org>
 
9
    <img src=../pygame_tiny.gif border=0 width=200 height=60></a><br>
 
10
    <b>pygame&nbsp;&nbsp;&nbsp;documentation</b>
 
11
</td><td bgcolor=6aee28 align=center valign=top width=100%>
 
12
 
 
13
        ||&nbsp;
 
14
        <a href=http://www.pygame.org>Home</a> &nbsp;||&nbsp;
 
15
        <a href=../index.html>Help Contents</a> &nbsp;||
 
16
        <br>&nbsp;<br>
 
17
 
 
18
|| <a href=pygame.html>pygame</a> || 
 
19
<a href=pygame_cdrom.html>cdrom</a> || 
 
20
<a href=pygame_constants.html>constants</a> || 
 
21
<a href=pygame_display.html>display</a> || 
 
22
<a href=pygame_draw.html>draw</a> || 
 
23
<a href=pygame_event.html>event</a> ||<br>
 
24
|| <a href=pygame_font.html>font</a> || 
 
25
<a href=pygame_image.html>image</a> || 
 
26
<a href=pygame_joystick.html>joystick</a> || 
 
27
<a href=pygame_key.html>key</a> || 
 
28
<a href=pygame_mixer.html>mixer</a> || 
 
29
<a href=pygame_mixer_music.html>mixer_music</a> ||<br>
 
30
|| <a href=pygame_mouse.html>mouse</a> || 
 
31
<a href=pygame_movie.html>movie</a> || 
 
32
<a href=pygame_surfarray.html>surfarray</a> || 
 
33
<a href=pygame_time.html>time</a> || 
 
34
<a href=pygame_transform.html>transform</a> ||<br>
 
35
&nbsp;<br>|| <a href=CD.html>CD</a> || 
 
36
<a href=Channel.html>Channel</a> || 
 
37
<a href=Clock.html>Clock</a> || 
 
38
<a href=Font.html>Font</a> || 
 
39
<a href=Joystick.html>Joystick</a> || 
 
40
<a href=Movie.html>Movie</a> ||<br>
 
41
|| <a href=Rect.html>Rect</a> || 
 
42
<a href=Sound.html>Sound</a> || 
 
43
<a href=Surface.html>Surface</a> ||<br>
 
44
&nbsp;<br>|| <a href=pygame_cursors.html>cursors</a> || 
 
45
<a href=pygame_sprite.html>sprite</a> || 
 
46
<a href=pygame_version.html>version</a> ||<br>
 
47
 
 
48
 
 
49
</td></tr></table></td></tr></table>
 
50
<br>
 
51
<h2 align=center>Rect</h2>
 
52
The rectangle object is a useful object
 
53
representing a rectangle area. Rectangles are
 
54
created from the <a href=pygame.html#Rect>pygame.Rect()</a> function. This routine
 
55
is also in the locals module, so importing the locals
 
56
into your namespace allows you to just use <a href=pygame.html#Rect>Rect()</a>.
 
57
<br>&nbsp;<br>
 
58
Rect contains helpful methods, as well as a list of
 
59
modifiable members:
 
60
top, bottom, left, right, topleft, topright,
 
61
bottomleft, bottomright, size, width, height,
 
62
center, centerx, centery, midleft, midright, midtop,
 
63
midbottom. When changing thesemembers, the rectangle
 
64
will be moved to the given assignment. (except when
 
65
changing the size, width, or height member, which will
 
66
resize the rectangle from the topleft corner)
 
67
<br>&nbsp;<br>
 
68
The rectstyle arguments used frequently with the
 
69
Rect object (and elsewhere in pygame) is one of
 
70
the following things. First, an actual Rect
 
71
object. Second, a sequence of [xpos, ypos, width,
 
72
height]. Lastly, a pair of sequences, representing
 
73
the position and size [[xpos, ypos], [width,
 
74
height]]. Also, if a method takes a rectstyle
 
75
argument as its only argument, you can simply pass
 
76
four arguments representing xpos, ypos, width,
 
77
height.
 
78
 
 
79
<hr>
 
80
 
 
81
<table>
 
82
<tr><td><a href=#clamp>clamp</a></td><td> -
 
83
move rectangle inside another</td></tr>
 
84
 
 
85
 
 
86
<tr><td><a href=#clamp_ip>clamp_ip</a></td><td> -
 
87
moves the rectangle inside another</td></tr>
 
88
 
 
89
 
 
90
<tr><td><a href=#clip>clip</a></td><td> -
 
91
rectangle cropped inside another</td></tr>
 
92
 
 
93
 
 
94
<tr><td><a href=#collidelist>collidelist</a></td><td> -
 
95
find overlapping rectangle</td></tr>
 
96
 
 
97
 
 
98
<tr><td><a href=#collidelistall>collidelistall</a></td><td> -
 
99
find all overlapping rectangles</td></tr>
 
100
 
 
101
 
 
102
<tr><td><a href=#collidepoint>collidepoint</a></td><td> -
 
103
point inside rectangle</td></tr>
 
104
 
 
105
 
 
106
<tr><td><a href=#colliderect>colliderect</a></td><td> -
 
107
check overlapping rectangles</td></tr>
 
108
 
 
109
 
 
110
<tr><td><a href=#contains>contains</a></td><td> -
 
111
check if rectangle fully inside another</td></tr>
 
112
 
 
113
 
 
114
<tr><td><a href=#inflate>inflate</a></td><td> -
 
115
new rectangle with size changed</td></tr>
 
116
 
 
117
 
 
118
<tr><td><a href=#inflate_ip>inflate_ip</a></td><td> -
 
119
changes the Rect size</td></tr>
 
120
 
 
121
 
 
122
<tr><td><a href=#move>move</a></td><td> -
 
123
new rectangle with position changed</td></tr>
 
124
 
 
125
 
 
126
<tr><td><a href=#move_ip>move_ip</a></td><td> -
 
127
move the Rect by the given offset</td></tr>
 
128
 
 
129
 
 
130
<tr><td><a href=#normalize>normalize</a></td><td> -
 
131
corrects negative sizes</td></tr>
 
132
 
 
133
 
 
134
<tr><td><a href=#union>union</a></td><td> -
 
135
makes new rectangle covering both inputs</td></tr>
 
136
 
 
137
 
 
138
<tr><td><a href=#union_ip>union_ip</a></td><td> -
 
139
rectangle covering both input</td></tr>
 
140
 
 
141
 
 
142
<tr><td><a href=#unionall>unionall</a></td><td> -
 
143
rectangle covering all inputs</td></tr>
 
144
 
 
145
 
 
146
<tr><td><a href=#unionall_ip>unionall_ip</a></td><td> -
 
147
rectangle covering all inputs</td></tr>
 
148
 
 
149
 
 
150
</table>
 
151
 
 
152
<hr>
 
153
 
 
154
<a name=clamp><font size=+2><b>clamp
 
155
</b></font><br><font size=+1><tt>
 
156
Rect.clamp(rectstyle) -> Rect
 
157
</tt></font><ul>
 
158
Returns a new rectangle that is moved to be
 
159
completely inside the argument rectangle. If the base
 
160
rectangle is too large for the argument rectangle in
 
161
an axis, it will be centered on that axis.
 
162
</ul><br>&nbsp;<br>
 
163
 
 
164
<a name=clamp_ip><font size=+2><b>clamp_ip
 
165
</b></font><br><font size=+1><tt>
 
166
Rect.clamp_ip(rectstyle) -> None
 
167
</tt></font><ul>
 
168
Moves the Rect to be
 
169
completely inside the argument rectangle. If the given
 
170
rectangle is too large for the argument rectangle in
 
171
an axis, it will be centered on that axis.
 
172
</ul><br>&nbsp;<br>
 
173
 
 
174
<a name=clip><font size=+2><b>clip
 
175
</b></font><br><font size=+1><tt>
 
176
Rect.clip(rectstyle) -> Rect
 
177
</tt></font><ul>
 
178
Returns a new rectangle that is the given
 
179
rectangle cropped to the inside of the base
 
180
rectangle. If the two rectangles do not overlap to
 
181
begin with, you will get a rectangle with 0 size.
 
182
</ul><br>&nbsp;<br>
 
183
 
 
184
<a name=collidelist><font size=+2><b>collidelist
 
185
</b></font><br><font size=+1><tt>
 
186
Rect.collidelist(rectstyle list) -> int index
 
187
</tt></font><ul>
 
188
Returns the index of the first rectangle in the
 
189
list to overlap the base rectangle. Once an
 
190
overlap is found, this will stop checking the
 
191
remaining list. If no overlap is found, it will
 
192
return -1.
 
193
</ul><br>&nbsp;<br>
 
194
 
 
195
<a name=collidelistall><font size=+2><b>collidelistall
 
196
</b></font><br><font size=+1><tt>
 
197
Rect.collidelistall(rectstyle list) -> int index
 
198
</tt></font><ul>
 
199
Returns a list of the indexes that contain
 
200
rectangles overlapping the base rectangle. If no
 
201
overlap is found, it will return an empty
 
202
sequence.
 
203
</ul><br>&nbsp;<br>
 
204
 
 
205
<a name=collidepoint><font size=+2><b>collidepoint
 
206
</b></font><br><font size=+1><tt>
 
207
Rect.collidepoint(x, y) -> bool
 
208
</tt></font><ul>
 
209
Returns true if the given point position is inside
 
210
the rectangle. If a point is on the border, it is
 
211
counted as inside.
 
212
</ul><br>&nbsp;<br>
 
213
 
 
214
<a name=colliderect><font size=+2><b>colliderect
 
215
</b></font><br><font size=+1><tt>
 
216
Rect.colliderect(rectstyle) -> bool
 
217
</tt></font><ul>
 
218
Returns true if any area of the two rectangles
 
219
overlaps.
 
220
</ul><br>&nbsp;<br>
 
221
 
 
222
<a name=contains><font size=+2><b>contains
 
223
</b></font><br><font size=+1><tt>
 
224
Rect.contains(rectstyle) -> bool
 
225
</tt></font><ul>
 
226
Returns true when the given rectangle is entirely
 
227
inside the base rectangle.
 
228
</ul><br>&nbsp;<br>
 
229
 
 
230
<a name=inflate><font size=+2><b>inflate
 
231
</b></font><br><font size=+1><tt>
 
232
Rect.inflate(x, y) -> Rect
 
233
</tt></font><ul>
 
234
Returns a new rectangle which has the sizes
 
235
changed by the given amounts. The rectangle
 
236
shrinks and expands around the rectangle's center.
 
237
Negative values will shrink the rectangle.
 
238
</ul><br>&nbsp;<br>
 
239
 
 
240
<a name=inflate_ip><font size=+2><b>inflate_ip
 
241
</b></font><br><font size=+1><tt>
 
242
Rect.inflate_ip(x, y) -> None
 
243
</tt></font><ul>
 
244
Changes the Rect by the given amounts. The rectangle
 
245
shrinks and expands around the rectangle's center.
 
246
Negative values will shrink the rectangle.
 
247
</ul><br>&nbsp;<br>
 
248
 
 
249
<a name=move><font size=+2><b>move
 
250
</b></font><br><font size=+1><tt>
 
251
Rect.move(x, y) -> Rect
 
252
</tt></font><ul>
 
253
Returns a new rectangle which is the base
 
254
rectangle moved by the given amount.
 
255
</ul><br>&nbsp;<br>
 
256
 
 
257
<a name=move_ip><font size=+2><b>move_ip
 
258
</b></font><br><font size=+1><tt>
 
259
Rect.move_ip(x, y) -> None
 
260
</tt></font><ul>
 
261
Moves the rectangle which by the given amount.
 
262
</ul><br>&nbsp;<br>
 
263
 
 
264
<a name=normalize><font size=+2><b>normalize
 
265
</b></font><br><font size=+1><tt>
 
266
Rect.normalize() -> None
 
267
</tt></font><ul>
 
268
If the rectangle has a a negative size in width or
 
269
height, this will flip that axis so the sizes are
 
270
positive, and the rectangle remains in the same
 
271
place.
 
272
</ul><br>&nbsp;<br>
 
273
 
 
274
<a name=union><font size=+2><b>union
 
275
</b></font><br><font size=+1><tt>
 
276
Rect.union(rectstyle) -> Rect
 
277
</tt></font><ul>
 
278
Creates a new Rect to completely cover the
 
279
given input. There may be area inside the new
 
280
Rect that is not covered by either input.
 
281
</ul><br>&nbsp;<br>
 
282
 
 
283
<a name=union_ip><font size=+2><b>union_ip
 
284
</b></font><br><font size=+1><tt>
 
285
Rect.union_ip(rectstyle) -> None
 
286
</tt></font><ul>
 
287
Resizes the Rect to completely cover the
 
288
given input. There may be area inside the new
 
289
dimensions that is not covered by either input.
 
290
</ul><br>&nbsp;<br>
 
291
 
 
292
<a name=unionall><font size=+2><b>unionall
 
293
</b></font><br><font size=+1><tt>
 
294
Rect.unionall(sequence_of_rectstyles) -> Rect
 
295
</tt></font><ul>
 
296
Returns a new rectangle that completely covers all the
 
297
given inputs. There may be area inside the new
 
298
rectangle that is not covered by the inputs.
 
299
</ul><br>&nbsp;<br>
 
300
 
 
301
<a name=unionall_ip><font size=+2><b>unionall_ip
 
302
</b></font><br><font size=+1><tt>
 
303
Rect.unionall_ip(sequence_of_rectstyles) -> None
 
304
</tt></font><ul>
 
305
Returns a new rectangle that completely covers all the
 
306
given inputs. There may be area inside the new
 
307
rectangle that is not covered by the inputs.
 
308
</ul><br>&nbsp;<br>
 
309
 
 
310
 
 
311
<hr>
 
312
</body></html>