scatter

Function
scatter(
    states: list[State],
    x_range: Tuple[float, float] = (-100, 100),
    y_range: Tuple[float, float] = (-100, 100),
    alignment: ElementAlignment = <ElementAlignment.PRESERVE: 'preserve'>,
    element_rotation_offset: float = 0,
    seed: Optional[int] = None
) -> list[State]

Arrange states randomly (scatter) within a bounding box.

Each element is placed at a random position within the specified x/y ranges. Preserves all other state attributes (color, scale, opacity, etc.) while only modifying x and y positions.

Parameters

states
List of states to arrange
x_range
Tuple (min_x, max_x) for horizontal bounds
y_range
Tuple (min_y, max_y) for vertical bounds
alignment
How to align each element relative to the layout. PRESERVE keeps original rotation, LAYOUT applies element_rotation_offset, UPRIGHT sets rotation to 0.
element_rotation_offset
Additional rotation in degrees added to the alignment base.
seed
Optional random seed for reproducibility

Returns

New list of states with random positions