Description:
Draws a polygon on the specified surface by connecting a series of
points in order. The final point is automatically connected back to
the first, forming a closed shape. Depending on the width
parameter, the polygon can be rendered as either an outlined shape
or a filled shape.
from VertexEngine import VertexScreen
vs = VertexScreen()
points = [(100, 60), (200, 140), (160, 240), (40, 180)]
# Draw a filled polygon
vs.Draw.polygon(
surface,
(0, 200, 120),
points=points,
width=0
)
surface (Surface):
The surface on which the polygon will be drawn, such as the main
display surface or an off-screen rendering buffer.
color (tuple):
The RGB color of the polygon, specified as (R, G, B).
points (list of tuples):
A list of (x, y) coordinate pairs defining the
vertices of the polygon. At least three points are required.
width (int):
The thickness of the polygon edges in pixels. Set to
0 to draw a filled polygon.
None — This method draws directly onto the surface and does not return a value.