distributeHorizontally

fun List<Rectangle>.distributeHorizontally(within: Rectangle = bounds): List<Rectangle>(source)

Distributes the rectangles in the list horizontally within a specified bounding rectangle.

Each rectangle is positioned at regular intervals, ensuring equal spacing between them. The method maintains the height and y-coordinate of each rectangle, only adjusting their x-coordinates.

Return

A new list of rectangles with updated positions that are evenly distributed horizontally.

Parameters

within

The bounding rectangle within which the rectangles are horizontally distributed. Defaults to the bounding rectangle covering all rectangles in the list.