polygon
Functionpolygon(
states: list[State],
sides: int = 5,
radius: float = 100,
rotation: float = 0,
center: Point2D = Point2D(x=0, y=0),
alignment: ElementAlignment = <ElementAlignment.PRESERVE: 'preserve'>,
element_rotation_offset: float = 0,
element_rotation_offset_fn: Optional[Callable[[float], float]] = None
) -> list[State]
Arrange states evenly distributed around a regular polygon.
Elements are placed at vertices and along edges based on distribution.
Parameters
-
states - List of states to arrange
-
sides - Number of sides (vertices) of the polygon
-
radius - Distance from center to each vertex
-
rotation - Rotation in degrees (0° = top)
-
cx - X coordinate of polygon center
-
cy - Y coordinate of polygon center
-
alignment - How to align each element relative to the polygon. PRESERVE keeps original rotation, LAYOUT aligns to edge angle (or perpendicular at vertices), UPRIGHT starts from vertical position.
-
element_rotation_offset - Additional rotation in degrees added to the alignment base.
-
element_rotation_offset_fn - Function that takes position angle (degrees) and returns rotation offset. If provided, this overrides element_rotation_offset parameter.
Returns
New list of states with polygon positions