Package-level declarations

Types

Link copied to clipboard
data class Arc(val center: Vector2, val radius: Double, val angle0: Double, val angle1: Double) : LinearType<Arc> , GeometricPrimitive2D

Represents an arc defined by a center point, a radius, and a range of angles.

Link copied to clipboard
data class Net(val point0: Vector2, val point1: Vector2, val circle: Circle) : LinearType<Net> , GeometricPrimitive2D

Represents a net defined by two points and a circle. The net can be seen as a structure that connects the two points with the circle in between, forming a string-like shape.

Link copied to clipboard
data class Pulley(val circle0: Circle, val circle1: Circle) : LinearType<Pulley> , GeometricPrimitive2D

Represents a pulley system defined by two circles.

Link copied to clipboard
class RectangleGrid(val grid: List<List<Rectangle>>) : List<List<Rectangle>>

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

Link copied to clipboard
data class RoundedRectangle(val corner: Vector2, val width: Double, val height: Double, val radius: Double)
Link copied to clipboard
data class Tear(val point: Vector2, val circle: Circle) : LinearType<Tear> , GeometricPrimitive2D

Represents a "Tear" consisting of a point and a circle.

Properties

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

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

Functions

Link copied to clipboard
fun Rectangle.adjacent(left: Double? = null, right: Double? = null, top: Double? = null, bottom: Double? = null, width: Double? = null, height: Double? = null): Rectangle

Adjusts the dimensions and position of the rectangle based on the provided parameters. The method calculates the new dimensions and coordinates of the rectangle based on specified values for left, right, top, bottom, width, or height. If conflicting parameters are provided (e.g., both left and right or top and bottom), an error is thrown.

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 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<List<Rectangle>>.column(index: Int): List<Rectangle>

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

Link copied to clipboard
fun Circle.contour(segments: Int): ShapeContour

Convert Circle to ShapeContour with a number of segments equal to segments

fun Ellipse.contour(segments: Int): ShapeContour

Convert Ellipse to ShapeContour with a number of segments equal to segments

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
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 Rectangle.grid(cellWidth: Double, cellHeight: Double, minMarginX: Double = 0.0, minMarginY: Double = 0.0, gutterX: Double = 0.0, gutterY: Double = 0.0): RectangleGrid
fun Rectangle.grid(columns: Int, rows: Int, marginX: Double = 0.0, marginY: Double = 0.0, gutterX: Double = 0.0, gutterY: Double = 0.0): RectangleGrid

Splits Rectangle into a grid of Rectangles

fun Box.grid(cellWidth: Double, cellHeight: Double, cellDepth: Double, minMarginX: Double = 0.0, minMarginY: Double = 0.0, minMarginZ: Double = 0.0, gutterX: Double = 0.0, gutterY: Double = 0.0, gutterZ: Double = 0.0): List<List<List<Box>>>
fun Box.grid(columns: Int, rows: Int, slices: Int, marginX: Double = 0.0, marginY: Double = 0.0, marginZ: Double = 0.0, gutterX: Double = 0.0, gutterY: Double = 0.0, gutterZ: Double = 0.0): List<List<List<Box>>>

Split Box into a grid of Boxes

Link copied to clipboard
fun Box.intersection(other: Box): Box

Computes the intersection of the current box with another box. If the two boxes intersect, the resulting box represents the overlapping region. If the two boxes do not intersect, an empty box is returned.

fun Rectangle.intersection(other: Rectangle): Rectangle

Computes the intersection of two rectangles and returns the resulting rectangle. If the rectangles do not intersect, an empty rectangle is returned.

Link copied to clipboard
fun Circle.invert(point: Vector2): Vector2

Performs circle inversion of a point.

fun Circle.invert(circle: Circle): GeometricPrimitive2D

Performs circle inversion of another circle.

fun Circle.invert(segment: LineSegment): GeometricPrimitive2D
Link copied to clipboard
fun Circle.invertConformal(circle: Circle): GeometricPrimitive2D

Performs conformal inversion of another circle.

Link copied to clipboard
fun Rectangle.irregularGrid(columnWeights: List<Double>, rowWeights: List<Double>, marginX: Double = 0.0, marginY: Double = 0.0): RectangleGrid

Divides a rectangle into a grid of sub-rectangles with irregular spacing, based on the specified column and row weights. Optionally, margins can be applied on both the horizontal and vertical directions.

Link copied to clipboard
fun Box.place(item: Box, anchor: Vector3 = Vector3(0.5, 0.5, 0.5), itemAnchor: Vector3 = anchor): Box

Places a given box relative to this box using specified anchor points. This method computes the position of the placed box based on the anchor points of both the current box and the given box. The resulting box maintains the dimensions of the given box and is positioned at the calculated location.

fun Rectangle.place(item: Rectangle, anchor: Vector2 = Vector2(0.5, 0.5), itemAnchor: Vector2 = anchor): Rectangle

Places a given rectangle (item) within the bounds of the current rectangle (this), positioning it based on the specified anchor point.

Link copied to clipboard
fun Box.placeIn(container: Box, anchor: Vector3 = Vector3(0.5, 0.5, 0.5), itemAnchor: Vector3 = anchor): Box

Places this box inside the specified container box using anchor points to determine the relative positioning.

fun Rectangle.placeIn(container: Rectangle, anchor: Vector2 = Vector2(0.5, 0.5), itemAnchor: Vector2 = anchor): Rectangle

Positions the current rectangle (this) within the given container rectangle. The placement is determined by aligning the itemAnchor of the current rectangle to the anchor point within the container rectangle.

Link copied to clipboard
fun regularPolygon(sides: Int, center: Vector2 = Vector2.ZERO, radius: Double = 100.0, phase: Double = 0.0): ShapeContour

Creates a regular polygon at center with the given sides and radius. Specify a phase in degrees to rotate it.

Link copied to clipboard
fun regularPolygonBeveled(sides: Int, bevelFactor: Double = 0.5, center: Vector2 = Vector2.ZERO, radius: Double = 100.0, phase: Double = 0.0): ShapeContour

Creates a beveled polygon at center with the given sides and radius. Specify a phase in degrees to rotate it. If 0.0 <bevelFactor< 1.0 the number of sides is doubled. Using 0.5 all sides have equal length. With other values bevelFactor determines the length ratio between even and odd sides.

Link copied to clipboard
fun regularPolygonRounded(sides: Int, roundFactor: Double = 0.5, center: Vector2 = Vector2.ZERO, radius: Double = 100.0, phase: Double = 0.0): ShapeContour

Creates a rounded polygon at center with the given sides and radius. Specify a phase in degrees to rotate it. roundFactor 0.0 = no rounding, 0.5 = default, 1.0 = full rounding.

Link copied to clipboard
fun regularStar(points: Int, innerRadius: Double, outerRadius: Double, center: Vector2 = Vector2.ZERO, phase: Double = 0.0): ShapeContour
Link copied to clipboard
fun regularStarBeveled(points: Int, innerRadius: Double, outerRadius: Double, innerFactor: Double, outerFactor: Double, center: Vector2 = Vector2.ZERO, phase: Double = 0.0): ShapeContour
Link copied to clipboard
fun regularStarRounded(points: Int, innerRadius: Double, outerRadius: Double, innerFactor: Double, outerFactor: Double, center: Vector2 = Vector2.ZERO, phase: Double = 0.0): ShapeContour
Link copied to clipboard
fun Drawer.roundedRectangle(roundedRectangle: RoundedRectangle)
fun Drawer.roundedRectangle(position: Vector2, width: Double, height: Double, radius: Double)
fun Drawer.roundedRectangle(x: Double, y: Double, width: Double, height: Double, radius: Double)
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
fun Box.splitAtX(x: Double): List<Box>

Splits the current Box into two smaller Boxes at the specified x-coordinate if the coordinate resides within the box's x-axis range.

fun Rectangle.splitAtX(x: Double): List<Rectangle>

Splits the current Rectangle into two smaller rectangles at a specified x-coordinate.

Link copied to clipboard
fun Box.splitAtY(y: Double): List<Box>

Splits the current Box object into two separate boxes along the given Y-coordinate. If the Y-coordinate falls within the vertical range of the box, the method produces two new boxes divided at the specified Y-coordinate. If the Y-coordinate is outside the vertical range, the method returns the original box unchanged.

fun Rectangle.splitAtY(y: Double): List<Rectangle>

Splits the rectangle horizontally at the specified y value if the value lies within the rectangle's vertical range.

Link copied to clipboard
fun Box.splitAtZ(z: Double): List<Box>

Splits the current Box into two smaller boxes along the z-axis at the specified position. If the provided z position lies outside the z-range of the current Box, the method returns a list containing only the original Box.

Link copied to clipboard
fun Box.sub(uvw: Box): Box

Creates a sub-box from the current box using the dimensions defined by another box.

fun Rectangle.sub(uv: Rectangle): Rectangle

Creates a sub-rectangle from the current rectangle using the dimensions defined by another 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.

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

Subtracts the given Box from the current Box and returns the remaining parts of the current Box that do not intersect with the given Box.

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

Subtracts the given rectangle other from the current rectangle, splitting and removing overlapping areas and returning the remaining non-overlapping parts as a list of rectangles.

Link copied to clipboard
fun Rectangle.take(left: Double? = null, top: Double? = null, right: Double? = null, bottom: Double? = null, width: Double? = null, height: Double? = null): Rectangle

Creates a new Rectangle by modifying its dimensions and position based on the provided parameters. The method adjusts the position and size of the rectangle depending on which of the optional parameters are supplied. Any omitted parameters are calculated to maintain the rectangle's overall layout.

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
fun Circle.tangents(point: Vector2): Pair<Vector2, Vector2>

Computes the tangent points from a given external point to a circle.

fun Circle.tangents(other: Circle, isInner: Boolean = false): List<Pair<Vector2, Vector2>>

Calculates the tangent lines between this circle and another circle.

Link copied to clipboard
fun Rectangle.toRounded(radius: Double): RoundedRectangle
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.