VertexContours
A shape defined by an outer contour and optional holes
This represents a potentially multi-contour shape: - outer: The outer boundary (VertexLoop, must be closed) - holes: List of inner boundaries that create vertex loops (all must be closed) The outer contour should have counter-clockwise winding (positive area). vertex loops should have clockwise winding (negative area).
Constructor
VertexContours(
outer: VertexLoop,
holes: Optional[List[VertexLoop]] = None
)
Initialize vertex contours
Parameters
-
outer - Outer boundary loop (must be closed)
-
holes - Optional list of hole loops (all must be closed)
Methods
all_loops
all_loops()
Get all loops (outer + holes) as a list
bounds
bounds()
Calculate bounding box of the entire shape (min_x, min_y, max_x, max_y)
centroid
centroid()
Calculate centroid of the outer contour
from_single_loop
from_single_loop(vertices: Points2D, closed: bool = True) -> VertexContours
Create VertexContours from a single loop (no holes)
from_vertices_lists
from_vertices_lists(
outer_vertices: Points2D,
holes_vertices: Optional[List[Points2D]] = None
) -> VertexContours
Create VertexContours from lists of vertex tuples
Parameters
-
outer_vertices - Vertices for outer contour holes_vertices: Optional list of vertex lists for holes
num_holes
num_holes()
Get the number of holes
rotate
rotate(
angle_degrees: float,
center: Optional[Point2D] = None
) -> VertexContours
Rotate all contours in-place around center
Parameters
-
angle_degrees - Rotation angle in degrees (positive = counter-clockwise)
-
center - Center of rotation (default is origin) Returns self for method chaining.
scale
scale(sx: float, sy: Optional[float] = None) -> VertexContours
Scale all contours in-place by (sx, sy)
total_vertices
total_vertices()
Get total number of vertices across all contours
translate
translate(dx: float, dy: float) -> VertexContours
Translate all contours in-place by (dx, dy)
Properties
has_holes- Check if this shape has any holes
holes- Get the list of holes
outer- Get the outer contour