RectangleGrid

class RectangleGrid(val grid: List<List<Rectangle>>) : List<List<Rectangle>> (source)

Represents a rectangular grid structure composed of lists of Rectangle instances.

This class provides a convenient abstraction for working with 2D grids, where each cell is represented by a Rectangle. The class delegates to the underlying grid structure, which is implemented as a list of lists, allowing it to be used interchangeably with other list-based data structures.

Constructors

Link copied to clipboard
constructor(grid: List<List<Rectangle>>)

Properties

Link copied to clipboard
@get:JvmName(name = "segmentBounds")
val Iterable<Segment2D>.bounds: Rectangle

Evaluates the bounds around all Segment instances in the Iterable

@get:JvmName(name = "shapeContourBounds")
val Iterable<ShapeContour>.bounds: Rectangle

Evaluates the bounds around all ShapeContour instances in the Iterable

@get:JvmName(name = "shapeBounds")
val Iterable<Shape>.bounds: Rectangle

Evaluates the bounds around all Shape instances in the Iterable

@get:JvmName(name = "getRectangleListBounds")
val List<List<Rectangle>>.bounds: Rectangle

Computes the bounding rectangle that encompasses all the rectangles contained in the lists.

Link copied to clipboard
val grid: List<List<Rectangle>>

The 2D list structure containing Rectangle elements.

Link copied to clipboard
open override val size: Int

Functions

Link copied to clipboard
fun List<Rectangle>.alignToHorizontally(to: Rectangle, anchor: Double = 0.5): List<Rectangle>

Aligns a list of rectangles horizontally relative to a specified rectangle.

Link copied to clipboard
fun List<Rectangle>.alignToVertically(to: Rectangle, anchor: Double = 0.5): List<Rectangle>

Aligns the rectangles in the list vertically to a reference rectangle. The vertical position of each rectangle is determined based on the reference rectangle and the specified vertical anchor point.

Link copied to clipboard
fun List<Vector2>.alphaShape(): Shape

Create an alpha shape from list of Vector2

Link copied to clipboard
fun RectangleGrid.block(x: Int, y: Int, width: Int, height: Int): RectangleGrid

Extracts a sub-block from a 2D list of rectangles based on the specified coordinates and dimensions.

Link copied to clipboard
fun List<Vector2>.catmullRom(alpha: Double = 0.5, closed: Boolean): CatmullRomChain2
fun List<Vector3>.catmullRom(alpha: Double = 0.5, closed: Boolean): CatmullRomChain3
Link copied to clipboard
fun List<List<Rectangle>>.column(index: Int): List<Rectangle>

Retrieves a column of rectangles from a 2D list of rectangles.

Link copied to clipboard
open operator override fun contains(element: List<Rectangle>): Boolean
Link copied to clipboard
open override fun containsAll(elements: Collection<List<Rectangle>>): Boolean
Link copied to clipboard
fun List<Rectangle>.distributeHorizontally(within: Rectangle = bounds): List<Rectangle>

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

Link copied to clipboard
fun List<Rectangle>.distributeVertically(within: Rectangle = bounds): List<Rectangle>

Distributes the rectangles in the list vertically within the given bounding rectangle. The rectangles are spaced evenly, ensuring an equal distance between them, while maintaining their original height and width.

Link copied to clipboard

Drops the first n columns from a 2D list of Rectangles.

Link copied to clipboard

Removes the last n columns from each row (inner list) within a two-dimensional list.

Link copied to clipboard
fun List<Rectangle>.fitHorizontally(within: Rectangle = bounds, gutter: Double = 0.0): List<Rectangle>

Distributes a list of rectangles horizontally within a given container rectangle, maintaining their relative width proportions and adding an optional gutter between them.

Link copied to clipboard
fun List<Rectangle>.fitVertically(within: Rectangle = bounds, gutter: Double = 0.0): List<Rectangle>

Fits a list of rectangles within a given vertical rectangular area. Each rectangle's height is adjusted proportionally based on its original height relative to the total height of all rectangles in the list. The rectangles are then distributed vertically, with an optional gutter spacing between them.

Link copied to clipboard
fun List<Vector3>.frames(up0: Vector3): List<Matrix44>

Calculate frames (pose matrices) using parallel transport

Link copied to clipboard
open operator override fun get(index: Int): List<Rectangle>
Link copied to clipboard
operator fun RectangleGrid.get(x: Int, y: Int): Rectangle

Retrieves a Rectangle from a two-dimensional list of Rectangles based on the specified x and y indices.

operator fun RectangleGrid.get(x: Int, yRange: IntRange): List<Rectangle>

Retrieves a list of rectangles at a specific x-coordinate for a range of y-coordinates from a 2D list of rectangles.

operator fun RectangleGrid.get(xRange: IntRange, y: Int): List<Rectangle>

Retrieves a sublist of Rectangle objects from a two-dimensional List given a range of indices for rows and a specific column index.

operator fun RectangleGrid.get(xRange: IntRange, yRange: IntRange): RectangleGrid

Retrieves a subgrid from a 2D list of Rectangles based on the specified ranges.

Link copied to clipboard
fun List<Vector2>.hilbertOrder(scale: Double = 1.0, permutation: Axis2DPermutation = Axis2DPermutation.XY, bits: Int = 16): List<Vector2>
fun List<Vector3>.hilbertOrder(scale: Double = 1.0, permutation: Axis3DPermutation = Axis3DPermutation.XYZ, bits: Int): List<Vector3>
Link copied to clipboard
open override fun indexOf(element: List<Rectangle>): Int
Link copied to clipboard
open override fun isEmpty(): Boolean
Link copied to clipboard
open operator override fun iterator(): Iterator<List<Rectangle>>
Link copied to clipboard
open override fun lastIndexOf(element: List<Rectangle>): Int
Link copied to clipboard
open override fun listIterator(): ListIterator<List<Rectangle>>
open override fun listIterator(index: Int): ListIterator<List<Rectangle>>
Link copied to clipboard
fun List<Vector2>.mortonOrder(scale: Double = 1.0, permutation: Axis2DPermutation = Axis2DPermutation.XY, bits: Int = 16): List<Vector2>
fun List<Vector3>.mortonOrder(scale: Double = 1.0, permutation: Axis3DPermutation = Axis3DPermutation.XYZ, bits: Int = 10): List<Vector3>
Link copied to clipboard
fun List<List<Rectangle>>.row(index: Int): List<Rectangle>

Retrieves the row from a 2D list of Rectangle objects at the specified index.

Link copied to clipboard

Selects specific columns from a two-dimensional list of rectangles. The method slices each inner list based on the provided column indices.

Slices the specified range of columns from each row of a two-dimensional list.

Link copied to clipboard
open override fun subList(fromIndex: Int, toIndex: Int): List<List<Rectangle>>
Link copied to clipboard
fun List<Box>.subtract(other: Box): List<Box>

Subtracts a given Box from each Box in the list and returns a list of the resulting Boxes.

fun List<Rectangle>.subtract(other: Rectangle): List<Rectangle>

Subtracts a rectangle from a list of rectangles, removing overlapping areas and returning the non-overlapping parts of the original rectangles.

Link copied to clipboard

Selects the first n columns from each row in a 2D list of Rectangle objects.

Link copied to clipboard

Returns a new list where each sub-list contains only the last n elements of the original sub-list.

Link copied to clipboard

Transposes a 2D list of rectangles, switching rows and columns.

Link copied to clipboard
fun List<List<Rectangle>>.uniform(random: Random): Rectangle

Selects a random Rectangle from a nested list of rectangles using the provided random generator.

Link copied to clipboard
fun RectangleGrid.uniformBlock(minWidth: Int = 1, maxWidth: Int = this[0].size, minHeight: Int = 1, maxHeight: Int = this.size, random: Random = Random.Default): RectangleGrid

Extracts a uniform random sub-block of rectangles from a 2D list within the specified constraints.

Link copied to clipboard
fun <E> List<E>.update(vararg updates: Pair<Int, E>): List<E>
Link copied to clipboard
fun List<Double>.weldAscending(epsilon: Double = 1.0E-6): List<Double>

Removes values from a list of doubles that are within a specified tolerance (epsilon) of the last added value, while preserving the ascending order of the list. The input list must already be in ascending order.