radial_grid

Function
radial_grid(
    states: list[State],
    rings: int = 3,
    segments: int = 8,
    ring_spacing: float = 50,
    inner_radius: float = 50,
    center: Point2D = Point2D(x=0, y=0),
    rotation: float = 0,
    clockwise: bool = True,
    alignment: ElementAlignment = <ElementAlignment.PRESERVE: 'preserve'>,
    element_rotation_offset: float = 0,
    element_rotation_offset_fn: Optional[Callable[[int, int, float], float]] = None,
    include_center: bool = False
) -> list[State]

Arrange states in a radial (polar coordinate) grid with rings and segments.

Creates a circular grid with concentric rings divided into equal angular segments. Elements are placed at the intersection of each ring and segment.

Parameters

states
List of states to arrange
rings
Number of concentric rings
segments
Number of angular segments (divisions around the circle)
ring_spacing
Distance between consecutive rings
inner_radius
Radius of the innermost ring (set to 0 to start from center)
cx
X coordinate of grid center
cy
Y coordinate of grid center
rotation
Rotation offset in degrees (0° = top)
clockwise
If True, segments arranged clockwise; if False, counterclockwise
alignment
How to align each element relative to the grid. PRESERVE keeps original rotation, LAYOUT aligns radially outward, UPRIGHT starts from vertical position.
element_rotation_offset
Additional rotation in degrees added to the alignment base.
element_rotation_offset_fn
Function that takes (ring_index, segment_index, angle) and returns rotation offset. If provided, overrides element_rotation_offset.
include_center
If True, place first element at center point (0,0)

Returns

New list of states with radial grid positions

Examples

# Simple radial grid
    radial_grid(states, rings=3, segments=8)

    # Radial grid with center element
    radial_grid(states, rings=3, segments=6, include_center=True)

    # Elements pointing outward from center
    radial_grid(states, rings=4, segments=12, alignment=ElementAlignment.LAYOUT)