Learn Before
Drawing Shapes in Pygame
Drawing Polygons in Pygame
The draw.polygon() function allows you to draw a polygon. The function takes in the surface, color, tuple or list of 3 or more xy coordinates for the vertices, and optional width. The width is used to determine line thickness or if the polygon should be filled. When the width is 0, the polygon will be filled. If it's greater than 0, it will determine the thickness of the line. If it's less than 0, nothing will be drawn.
displaySurface = pygame.display.set_mode((1920, 1080)) displayColor = (0, 0, 0) vertices = [(x1, y1), (x2, y2), (x3, y3)] width = 0 pygame.draw.polygon(displaySurface, displayColor, vertices, width)
0
1
4 years ago
Tags
Python Programming Language
Data Science
Related
Drawing Rectangles in Pygame
Drawing Polygons in Pygame
Drawing Circles in Pygame
Drawing Ellipses in PyGame
Drawing Arcs in Pygame
Drawing Lines in Pygame