~ubuntu-branches/debian/experimental/pygame/experimental

« back to all changes in this revision

Viewing changes to docs/_sources/ref/gfxdraw.txt

  • Committer: Package Import Robot
  • Author(s): Vincent Cheng
  • Date: 2013-02-21 00:23:03 UTC
  • mfrom: (1.1.6)
  • Revision ID: package-import@ubuntu.com-20130221002303-08xmo02oym2hxjee
Tags: 1.9.2~pre~r3189-1
* New upstream hg snapshot (rev 3189).
* Avoid potentially overriding a symlink in python3.2-dev. (Closes: #700997)
* Generate correct versioned dependency on python-numpy following ABI change
  using the dh_numpy and dh_numpy3 helpers. (Closes: #698169)
  - Add build-depends on python3-numpy.
* Fix a number of failing tests that rely on pygame being tested with OpenGL
  and a graphical display available, as well as audio/video devices.
* Remove deprecated DMUA flag in debian/control.
* Fix lintian tag vcs-field-not-canonical.
* Update Standards version from 3.9.3 to 3.9.4, no updates required.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
.. include:: common.txt
2
 
 
3
 
:mod:`pygame.gfxdraw`
4
 
=====================
5
 
 
6
 
.. module:: pygame.gfxdraw
7
 
   :synopsis: pygame module for drawing shapes
8
 
 
9
 
| :sl:`pygame module for drawing shapes`
10
 
 
11
 
EXPERIMENTAL!: meaning this api may change, or dissapear in later pygame
12
 
releases. If you use this, your code will break with the next pygame release.
13
 
 
14
 
Draw several shapes to a surface.
15
 
 
16
 
Most of the functions accept a color argument that is an ``RGB`` triplet. These
17
 
can also accept an ``RGBA`` quadruplet. The color argument can also be an
18
 
integer pixel value that is already mapped to the Surface's pixel format.
19
 
 
20
 
For all functions the arguments are strictly positional. Only integers are
21
 
accepted for coordinates and radii.
22
 
 
23
 
For functions like rectangle that accept a rect argument any (x, y, w, h)
24
 
sequence is accepted, though :mod:`pygame.Rect` instances are prefered. Note
25
 
that for a :mod:`pygame.Rect` the drawing will not include
26
 
``Rect.bottomright``. The right and bottom attributes of a Rect lie one pixel
27
 
outside of the Rect's boarder.
28
 
 
29
 
To draw an anti aliased and filled shape, first use the aa* version of 
30
 
the function, and then use the filled version.  For example ::
31
 
 
32
 
   col = (255, 0, 0)
33
 
   surf.fill((255, 255, 255))
34
 
   pygame.gfxdraw.aacircle(surf, x, y, 30, col)
35
 
   pygame.gfxdraw.filled_circle(surf, x, y, 30, col)
36
 
 
37
 
Note that pygame does not automatically import pygame.gfxdraw, so you need to
38
 
import pygame.gfxdraw before using it.
39
 
 
40
 
Threading note: each of the functions releases the GIL during the C part of the call.
41
 
 
42
 
The pygame.gfxdraw module differs from the draw module in the API it uses, and
43
 
also the different functions available to draw.  It also wraps the primitives 
44
 
from the library called SDL_gfx, rather than using modified versions.
45
 
 
46
 
 
47
 
New in pygame 1.9.0.
48
 
 
49
 
.. function:: pixel
50
 
 
51
 
   | :sl:`place a pixel`
52
 
   | :sg:`pixel(surface, x, y, color) -> None`
53
 
 
54
 
   Draws a single pixel onto a surface.
55
 
 
56
 
   .. ## pygame.gfxdraw.pixel ##
57
 
 
58
 
.. function:: hline
59
 
 
60
 
   | :sl:`draw a horizontal line`
61
 
   | :sg:`hline(surface, x1, x2, y, color) -> None`
62
 
 
63
 
   Draws a straight horizontal line on a Surface from x1 to x2 for
64
 
   the given y coordinate.
65
 
 
66
 
   .. ## pygame.gfxdraw.hline ##
67
 
 
68
 
.. function:: vline
69
 
 
70
 
   | :sl:`draw a vertical line`
71
 
   | :sg:`vline(surface, x, y1, y2, color) -> None`
72
 
 
73
 
   Draws a straight vertical line on a Surface from y1 to y2 on
74
 
   the given x coordinate.
75
 
 
76
 
   .. ## pygame.gfxdraw.vline ##
77
 
 
78
 
.. function:: rectangle
79
 
 
80
 
   | :sl:`draw a rectangle`
81
 
   | :sg:`rectangle(surface, rect, color) -> None`
82
 
 
83
 
   Draws the rectangle edges onto the surface. The given Rect is the area of the
84
 
   rectangle.
85
 
 
86
 
   Keep in mind the ``Surface.fill()`` method works just as well for drawing
87
 
   filled rectangles. In fact the ``Surface.fill()`` can be hardware
88
 
   accelerated on some platforms with both software and hardware display modes.
89
 
 
90
 
   .. ## pygame.gfxdraw.rectangle ##
91
 
 
92
 
.. function:: box
93
 
 
94
 
   | :sl:`draw a box`
95
 
   | :sg:`box(surface, rect, color) -> None`
96
 
 
97
 
   Draws a box (a rect) onto a surface.
98
 
 
99
 
   .. ## pygame.gfxdraw.box ##
100
 
 
101
 
.. function:: line
102
 
 
103
 
   | :sl:`draw a line`
104
 
   | :sg:`line(surface, x1, y1, x2, y2, color) -> None`
105
 
 
106
 
   Draws a straight line on a Surface. There are no endcaps.
107
 
 
108
 
   .. ## pygame.gfxdraw.line ##
109
 
 
110
 
.. function:: circle
111
 
 
112
 
   | :sl:`draw a circle`
113
 
   | :sg:`circle(surface, x, y, r, color) -> None`
114
 
 
115
 
   Draws the edges of a circular shape on the Surface. The pos argument is 
116
 
   the center of the circle, and radius is the size.  The circle is not 
117
 
   filled with color.
118
 
 
119
 
   .. ## pygame.gfxdraw.circle ##
120
 
 
121
 
.. function:: arc
122
 
 
123
 
   | :sl:`draw an arc`
124
 
   | :sg:`arc(surface, x, y, r, start, end, color) -> None`
125
 
 
126
 
   Draws an arc onto a surface.
127
 
 
128
 
   .. ## pygame.gfxdraw.arc ##
129
 
 
130
 
.. function:: aacircle
131
 
 
132
 
   | :sl:`draw an anti-aliased circle`
133
 
   | :sg:`aacircle(surface, x, y, r, color) -> None`
134
 
 
135
 
   Draws the edges of an anti aliased circle onto a surface.
136
 
 
137
 
   .. ## pygame.gfxdraw.aacircle ##
138
 
 
139
 
.. function:: filled_circle
140
 
 
141
 
   | :sl:`draw a filled circle`
142
 
   | :sg:`filled_circle(surface, x, y, r, color) -> None`
143
 
 
144
 
   Draws a filled circle onto a surface.  So the inside of the circle will 
145
 
   be filled with the given color.
146
 
 
147
 
   .. ## pygame.gfxdraw.filled_circle ##
148
 
 
149
 
.. function:: ellipse
150
 
 
151
 
   | :sl:`draw an ellipse`
152
 
   | :sg:`ellipse(surface, x, y, rx, ry, color) -> None`
153
 
 
154
 
   Draws the edges of an ellipse onto a surface.
155
 
 
156
 
   .. ## pygame.gfxdraw.ellipse ##
157
 
 
158
 
.. function:: aaellipse
159
 
 
160
 
   | :sl:`draw an anti-aliased ellipse`
161
 
   | :sg:`aaellipse(surface, x, y, rx, ry, color) -> None`
162
 
 
163
 
   Draws anti aliased edges of an ellipse onto a surface.
164
 
 
165
 
   .. ## pygame.gfxdraw.aaellipse ##
166
 
 
167
 
.. function:: filled_ellipse
168
 
 
169
 
   | :sl:`draw a filled ellipse`
170
 
   | :sg:`filled_ellipse(surface, x, y, rx, ry, color) -> None`
171
 
 
172
 
   Draws a filled ellipse onto a surface.  So the inside of the elipse will 
173
 
   be filled with the given color.
174
 
 
175
 
   .. ## pygame.gfxdraw.filled_ellipse ##
176
 
 
177
 
.. function:: pie
178
 
 
179
 
   | :sl:`draw a pie`
180
 
   | :sg:`pie(surface, x, y, r, start, end, color) -> None`
181
 
 
182
 
   Draws a pie onto the surface.
183
 
 
184
 
   .. ## pygame.gfxdraw.pie ##
185
 
 
186
 
.. function:: trigon
187
 
 
188
 
   | :sl:`draw a triangle`
189
 
   | :sg:`trigon(surface, x1, y1, x2, y2, x3, y3, color) -> None`
190
 
 
191
 
   Draws the edges of a trigon onto a surface.  A trigon is a triangle.
192
 
 
193
 
   .. ## pygame.gfxdraw.trigon ##
194
 
 
195
 
.. function:: aatrigon
196
 
 
197
 
   | :sl:`draw an anti-aliased triangle`
198
 
   | :sg:`aatrigon(surface, x1, y1, x2, y2, x3, y3, color) -> None`
199
 
 
200
 
   Draws the anti aliased edges of a trigon onto a surface.  A trigon is a triangle.
201
 
 
202
 
   .. ## pygame.gfxdraw.aatrigon ##
203
 
 
204
 
.. function:: filled_trigon
205
 
 
206
 
   | :sl:`draw a filled trigon`
207
 
   | :sg:`filled_trigon(surface, x1, y1, x2, y2, x3, y3, color) -> None`
208
 
 
209
 
   Draws a filled trigon onto a surface.  So the inside of the trigon will 
210
 
   be filled with the given color.
211
 
 
212
 
   .. ## pygame.gfxdraw.filled_trigon ##
213
 
 
214
 
.. function:: polygon
215
 
 
216
 
   | :sl:`draw a polygon`
217
 
   | :sg:`polygon(surface, points, color) -> None`
218
 
 
219
 
   Draws the edges of a polygon onto a surface.
220
 
 
221
 
   .. ## pygame.gfxdraw.polygon ##
222
 
 
223
 
.. function:: aapolygon
224
 
 
225
 
   | :sl:`draw an anti-aliased polygon`
226
 
   | :sg:`aapolygon(surface, points, color) -> None`
227
 
 
228
 
   Draws the anti aliased edges of a polygon onto a surface.
229
 
 
230
 
   .. ## pygame.gfxdraw.aapolygon ##
231
 
 
232
 
.. function:: filled_polygon
233
 
 
234
 
   | :sl:`draw a filled polygon`
235
 
   | :sg:`filled_polygon(surface, points, color) -> None`
236
 
 
237
 
   Draws a filled polygon onto a surface.  So the inside of the polygon will 
238
 
   be filled with the given color.
239
 
 
240
 
   .. ## pygame.gfxdraw.filled_polygon ##
241
 
 
242
 
.. function:: textured_polygon
243
 
 
244
 
   | :sl:`draw a textured polygon`
245
 
   | :sg:`textured_polygon(surface, points, texture, tx, ty) -> None`
246
 
 
247
 
   Draws a textured polygon onto a surface.
248
 
 
249
 
   A per-pixel alpha texture blit to a per-pixel alpha surface will differ from
250
 
   a ``Surface.blit()`` blit. Also, a per-pixel alpha texture cannot be used
251
 
   with an 8-bit per pixel destination.
252
 
 
253
 
   .. ## pygame.gfxdraw.textured_polygon ##
254
 
 
255
 
.. function:: bezier
256
 
 
257
 
   | :sl:`draw a bezier curve`
258
 
   | :sg:`bezier(surface, points, steps, color) -> None`
259
 
 
260
 
   Draws a bezier onto a surface.
261
 
 
262
 
   .. ## pygame.gfxdraw.bezier ##
263
 
 
264
 
.. ## pygame.gfxdraw ##