|pygame.gfxdraw.pixel||—||place a pixel|
|pygame.gfxdraw.hline||—||draw a horizontal line|
|pygame.gfxdraw.vline||—||draw a vertical line|
|pygame.gfxdraw.rectangle||—||draw a rectangle|
|pygame.gfxdraw.box||—||draw a box|
|pygame.gfxdraw.line||—||draw a line|
|pygame.gfxdraw.circle||—||draw a circle|
|pygame.gfxdraw.arc||—||draw an arc|
|pygame.gfxdraw.aacircle||—||draw an anti-aliased circle|
|pygame.gfxdraw.filled_circle||—||draw a filled circle|
|pygame.gfxdraw.ellipse||—||draw an ellipse|
|pygame.gfxdraw.aaellipse||—||draw an anti-aliased ellipse|
|pygame.gfxdraw.filled_ellipse||—||draw a filled ellipse|
|pygame.gfxdraw.pie||—||draw a pie|
|pygame.gfxdraw.trigon||—||draw a triangle|
|pygame.gfxdraw.aatrigon||—||draw an anti-aliased triangle|
|pygame.gfxdraw.filled_trigon||—||draw a filled trigon|
|pygame.gfxdraw.polygon||—||draw a polygon|
|pygame.gfxdraw.aapolygon||—||draw an anti-aliased polygon|
|pygame.gfxdraw.filled_polygon||—||draw a filled polygon|
|pygame.gfxdraw.textured_polygon||—||draw a textured polygon|
|pygame.gfxdraw.bezier||—||draw a bezier curve|
EXPERIMENTAL!: meaning this api may change, or dissapear in later pygame releases. If you use this, your code will break with the next pygame release.
Draw several shapes to a surface.
Most of the functions accept a color argument that is an RGB triplet. These can also accept an RGBA quadruplet. The color argument can also be an integer pixel value that is already mapped to the Surface’s pixel format.
For all functions the arguments are strictly positional. Only integers are accepted for coordinates and radii.
For functions like rectangle that accept a rect argument any (x, y, w, h) sequence is accepted, though pygame.Rectpygame object for storing rectangular coordinates instances are prefered. Note that for a pygame.Rectpygame object for storing rectangular coordinates the drawing will not include Rect.bottomright. The right and bottom attributes of a Rect lie one pixel outside of the Rect’s boarder.
To draw an anti aliased and filled shape, first use the aa* version of the function, and then use the filled version. For example
col = (255, 0, 0) surf.fill((255, 255, 255)) pygame.gfxdraw.aacircle(surf, x, y, 30, col) pygame.gfxdraw.filled_circle(surf, x, y, 30, col)
Note that pygame does not automatically import pygame.gfxdraw, so you need to import pygame.gfxdraw before using it.
Threading note: each of the functions releases the GIL during the C part of the call.
The pygame.gfxdraw module differs from the draw module in the API it uses, and also the different functions available to draw. It also wraps the primitives from the library called SDL_gfx, rather than using modified versions.
New in pygame 1.9.0.
Draws a single pixel onto a surface.
Draws a straight horizontal line on a Surface from x1 to x2 for the given y coordinate.
Draws a straight vertical line on a Surface from y1 to y2 on the given x coordinate.
Draws the rectangle edges onto the surface. The given Rect is the area of the rectangle.
Keep in mind the Surface.fill() method works just as well for drawing filled rectangles. In fact the Surface.fill() can be hardware accelerated on some platforms with both software and hardware display modes.
Draws a box (a rect) onto a surface.
Draws a straight line on a Surface. There are no endcaps.
Draws the edges of a circular shape on the Surface. The pos argument is the center of the circle, and radius is the size. The circle is not filled with color.
Draws an arc onto a surface.
Draws the edges of an anti aliased circle onto a surface.
Draws a filled circle onto a surface. So the inside of the circle will be filled with the given color.
Draws the edges of an ellipse onto a surface.
Draws anti aliased edges of an ellipse onto a surface.
Draws a filled ellipse onto a surface. So the inside of the elipse will be filled with the given color.
Draws a pie onto the surface.
Draws the edges of a trigon onto a surface. A trigon is a triangle.
Draws the anti aliased edges of a trigon onto a surface. A trigon is a triangle.
Draws a filled trigon onto a surface. So the inside of the trigon will be filled with the given color.
Draws the edges of a polygon onto a surface.
Draws the anti aliased edges of a polygon onto a surface.
Draws a filled polygon onto a surface. So the inside of the polygon will be filled with the given color.
Draws a textured polygon onto a surface.
A per-pixel alpha texture blit to a per-pixel alpha surface will differ from a Surface.blit() blit. Also, a per-pixel alpha texture cannot be used with an 8-bit per pixel destination.
Draws a bezier onto a surface.