VertexAstroid

Astroid as a VertexLoop - star-like shape with inward-curving cusps

Generates an astroid shape with cusps (pointed tips) connected by inward-bending circular arcs. The classic astroid has 4 cusps, but this implementation supports any number. The num_vertices parameter is crucial for morphing - shapes with the same num_vertices can morph smoothly between each other.

Constructor

VertexAstroid(
    center: Point2D = Point2D(x=0, y=0),
    radius: float = 50.0,
    num_cusps: int = 4,
    curvature: float = 0.7,
    num_vertices: int = 128
)

Create an astroid as a vertex loop

Parameters

center
Center point
radius
Distance from center to cusp points
num_cusps
Number of cusps (points) - 4 for classic astroid
curvature
Controls arc depth (0-1). Higher = deeper inward curves
num_vertices
Number of vertices distributed along perimeter (important for morphing!)

Methods

area

area()

Calculate the signed area of the loop

bounds

bounds()

Calculate bounding box (min_x, min_y, max_x, max_y)

centroid

centroid()

Calculate the centroid (geometric center) of the vertices

is_clockwise

is_clockwise()

Check if the loop has clockwise winding (negative area)

reverse

reverse()

Return a new VertexLoop with reversed vertex order

rotate

rotate(
    angle_degrees: float,
    center: Point2D | None = None
) -> VertexLoop

Rotate all vertices by angle_degrees around center (default: origin). Returns self for chaining.

scale

scale(sx: float, sy: float | None = None) -> VertexLoop

Scale all vertices by (sx, sy). If sy is None, uses sx for both axes. Returns self for chaining.

translate

translate(dx: float, dy: float) -> VertexLoop

Translate all vertices by (dx, dy). Returns self for chaining.

Properties

closed
Whether this loop is closed
vertices
Get vertices as list of tuples