Draw
pygame module for drawing shapes
Draw several simple shapes to a Surface. These functions will work for rendering to any format of Surface. Rendering to hardware Surfaces will be slower than regular software Surfaces.
Most of the functions take a width argument to represent the size of stroke around the edge of the shape. If a width of 0 is passed the function will actually solid fill the entire shape.
All the drawing functions respect the clip area for the Surface, and will be constrained to that area. The functions return a rectangle representing the bounding area of changed pixels.
Most of the arguments accept a color argument that is an RGB triplet. These can also accept an RGBA quadruplet. The alpha value will be written directly into the Surface if it contains pixel alphas, but the draw function will not draw transparently. The color argument can also be an integer pixel value that is already mapped to the Surface's pixel format.
These functions must temporarily lock the Surface they are operating on. Many sequential drawing calls can be sped up by locking and unlocking the Surface object around the draw calls.
Keep in mind the Surface.fill - fill Surface with a solid color method works just as well for drawing filled rectangles. In fact the Surface.fill - fill Surface with a solid color can be hardware accelerated on some platforms with both software and hardware display modes.
For aapolygon, use aalines with the 'closed' parameter.
This does not draw any endcaps or miter joints. Lines with sharp corners and wide line widths can have improper looking corners.
Draw several simple shapes to a Surface. These functions will work for rendering to any format of Surface. Rendering to hardware Surfaces will be slower than regular software Surfaces.
Most of the functions take a width argument to represent the size of stroke around the edge of the shape. If a width of 0 is passed the function will actually solid fill the entire shape.
All the drawing functions respect the clip area for the Surface, and will be constrained to that area. The functions return a rectangle representing the bounding area of changed pixels.
Most of the arguments accept a color argument that is an RGB triplet. These can also accept an RGBA quadruplet. The alpha value will be written directly into the Surface if it contains pixel alphas, but the draw function will not draw transparently. The color argument can also be an integer pixel value that is already mapped to the Surface's pixel format.
These functions must temporarily lock the Surface they are operating on. Many sequential drawing calls can be sped up by locking and unlocking the Surface object around the draw calls.
pygame.draw.rect
draw a rectangle shapepygame.draw.rect(Surface, color, Rect, width=0): return RectDraws a rectangular 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 rectangle will be filled.
Keep in mind the Surface.fill - fill Surface with a solid color method works just as well for drawing filled rectangles. In fact the Surface.fill - fill Surface with a solid color can be hardware accelerated on some platforms with both software and hardware display modes.
pygame.draw.polygon
draw a shape with any number of sidespygame.draw.polygon(Surface, color, pointlist, width=0): return RectDraws a polygonal shape on the Surface. The pointlist argument is the vertices of the polygon. The width argument is the thickness to draw the outer edge. If width is zero then the polygon will be filled.
For aapolygon, use aalines with the 'closed' parameter.
pygame.draw.circle
draw a circle around a pointpygame.draw.circle(Surface, color, pos, radius, width=0): return RectDraws a circular shape on the Surface. The pos argument 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 circle will be filled.
pygame.draw.ellipse
draw a round shape inside a rectanglepygame.draw.ellipse(Surface, color, Rect, width=0): return RectDraws an elliptical 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.
pygame.draw.arc
draw a partial section of an ellipsepygame.draw.arc(Surface, color, Rect, start_angle, stop_angle, width=1): return RectDraws an elliptical arc on the Surface. The rect argument is the area that the ellipse will fill. The two angle arguments are the initial and final angle in radians, with the zero on the right. The width argument is the thickness to draw the outer edge.
pygame.draw.line
draw a straight line segmentpygame.draw.line(Surface, color, start_pos, end_pos, width=1): return RectDraw a straight line segment on a Surface. There are no endcaps, the ends are squared off for thick lines.
pygame.draw.lines
draw multiple contiguous line segmentspygame.draw.lines(Surface, color, closed, pointlist, width=1): return RectDraw a sequence of lines on a Surface. The pointlist argument is a series of points that are connected by a line. If the closed argument is true an additional line segment is drawn between the first and last points.
This does not draw any endcaps or miter joints. Lines with sharp corners and wide line widths can have improper looking corners.
pygame.draw.aaline
draw fine antialiased linespygame.draw.aaline(Surface, color, startpos, endpos, blend=1): return RectDraws an anti-aliased line on a surface. This will respect the clipping rectangle. A bounding box of the affected area is returned returned as a rectangle. If blend is true, the shades will be be blended with existing pixel shades instead of overwriting them. This function accepts floating point values for the end points.
pygame.draw.aalines
pygame.draw.aalines(Surface, color, closed, pointlist, blend=1): return RectDraws 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. The boolean blend argument set to true will blend the shades with existing shades instead of overwriting them. This function accepts floating point values for the end points.
2007年01月27日(土) 17:25:14 Modified by py_gamer