Polygon
Represents a polygon shape defined by a sequence of points.
Constructor
Represents a polygon shape defined by a sequence of points.
Properties
| Name | Description | Type |
|---|---|---|
area | Get the area of the polygon. | float |
centroid | Get the centroid of the polygon. | Vec2 |
perimeter | Get the perimeter of the polygon. | float |
points | The list of Vec2 points that define the polygon vertices. | list[Vec2] |
Methods
Copy
Get Rect
get_rect() → RectGet the axis-aligned bounding rectangle of the polygon. Returns
Rect : The bounding rectangle.
Rotate
rotate(angle: SupportsFloat, pivot: Any = None) → NoneRotate the polygon around a pivot point.
Args
angle: The rotation angle in radians.pivot: The normalized point relative to the polygon's bounding box to rotate around. Defaults to center (0.5, 0.5).
Scale
scale(factor: SupportsFloat, pivot: Any = None) → NoneScale the polygon uniformly from a pivot point.
Args
factor: The scaling factor.pivot: The normalized point relative to the polygon's bounding box to scale from. Defaults to center (0.5, 0.5).
scale(factor: Vec2, pivot: Any = None) → NoneScale the polygon non-uniformly from a pivot point.
Args
factor: The scaling factors for x and y.pivot: The normalized point relative to the polygon's bounding box to scale from. Defaults to center (0.5, 0.5).