pygame documentation | || Home || Help Contents || || CD || Channel || Font || Joystick || Movie || Rect || Sound || || Surface || pygame || UserRect || cdrom || constants || cursors || display || || draw || event || font || image || joystick || key || mixer || || mixer_music || mouse || movie || surfarray || time || transform || version ||

## pygame.draw

Contains routines to draw onto a surface.
Note that all drawing routines use direct pixel access, so the surfaces must be locked for use. The draw functions will temporarily lock the surface if needed, but if performing many drawing routines together, it would be best to surround the drawing code with a lock/unlock pair.

circle | - draw a circle on a surface
ellipse | - draw an ellipse on a surface
line | - draw a line on a surface
lines | - draw multiple connected lines on a surface
polygon | - draws a polygon on a surface
rect | - draws a polygon on a surface

circle
`pygame.draw.circle(Surface, color, pos, radius, width) -> Rect`

Draws a circular shape on the Surface. The given position is the center of the circle, and radius is the size. The width argument is the thickness to draw the outer edge. If width is zero then the ellipse will be filled.
The color argument can be either a RGB sequence or mapped color integer.
This function will temporarily lock the surface.

ellipse
`pygame.draw.ellipse(Surface, color, Rect, width) -> Rect`

Draws a circular shape on the Surface. The given rectangle is the area that the circle will fill. The width argument is the thickness to draw the outer edge. If width is zero then the ellipse will be filled.
The color argument can be either a RGB sequence or mapped color integer.
This function will temporarily lock the surface.

line
`pygame.draw.line(Surface, color, startpos, endpos, width=1) -> Rect`

Draws a line on a surface. This will respect the clipping rectangle. A bounding box of the effected area is returned as a rectangle.
The color argument can be either a RGB sequence or mapped color integer.
This function will temporarily lock the surface.

lines
`pygame.draw.lines(Surface, color, closed, point_array, width=1) -> Rect`

Draws a sequence on a surface. You must pass at least two points in the sequence of points. The closed argument is a simple boolean and if true, a line will be draw between the first and last points. Note that specifying a linewidth wider than 1 does not fill in the gaps between the lines. Therefore wide lines and sharp corners won't be joined seamlessly.
This will respect the clipping rectangle. A bounding box of the effected area is returned as a rectangle.
The color argument can be either a RGB sequence or mapped color integer.
This function will temporarily lock the surface.

polygon
`pygame.draw.polygon(Surface, color, pointslist, width) -> Rect`

Draws a polygonal shape on the Surface. The given pointlist is the vertices of the polygon. The width argument is the thickness to draw the outer edge. If width is zero then the ellipse will be filled.
The color argument can be either a RGB sequence or mapped color integer.
This function will temporarily lock the surface.

rect
`pygame.draw.rect(Surface, color, Rect, width) -> Rect`

Draws a polygonal shape on the Surface. The given Rect is the area of the rectangle. The width argument is the thickness to draw the outer edge. If width is zero then the ellipse will be filled.
The color argument can be either a RGB sequence or mapped color integer.
This function will temporarily lock the surface.
Keep in mind the Surface.fill() method works just as well for drawing filled rectangles. In fact the Surface.fill() can be hardware accelerated when the moons are in alignement.