• android
    abstract class Box
Known direct subclasses
ImmutableBox

An immutable axis-aligned rectangle.

MutableBox

A mutable axis-aligned rectangle.


Represents an axis-aligned rectangle. See ImmutableBox and MutableBox for concrete classes implementing Box.

The Box interface is the read-only view of the underlying data which may or may not be mutable.

Summary

Public functions

MutableVec

Populates outVec with the center of the Box, and returns outVec.

android
Unit
computeCorners(
    outVecXMinYMin: MutableVec,
    outVecXMaxYMin: MutableVec,
    outVecXMaxYMax: MutableVec,
    outVecXMinYMax: MutableVec
)

Populates the 4 output points with the corners of the Box.

android
operator Boolean
contains(otherBox: Box)

Returns whether the other Box is contained within this Box.

android
operator Boolean
contains(point: Vec)

Returns whether the given point is contained within the Box.

android
Boolean
isAlmostEqual(other: Box, tolerance: @FloatRange(from = 0.0) Float)

Compares this Box with other, and returns true if the difference between xMin and other.xMin is less than tolerance, and likewise for xMax, yMin, and yMax.

android

Public properties

Float

The height of the rectangle.

android
Float

The width of the rectangle.

android
abstract Float

The upper bound in the X direction.

android
abstract Float

The lower bound in the X direction.

android
abstract Float

The upper bound in the Y direction.

android
abstract Float

The lower bound in the Y direction.

android

Extension functions

RectF

Writes the values from this Box to out.

android
RectF

Constructs a Rect with the same coordinates as the Box

android
MutableRect

Writes the values from this Box to out.

android
Rect

Constructs a Rect with the values from this Box.

android

Public functions

computeCenter

fun computeCenter(outVec: MutableVec): MutableVec

Populates outVec with the center of the Box, and returns outVec.

computeCorners

fun computeCorners(
    outVecXMinYMin: MutableVec,
    outVecXMaxYMin: MutableVec,
    outVecXMaxYMax: MutableVec,
    outVecXMinYMax: MutableVec
): Unit

Populates the 4 output points with the corners of the Box. The order of the corners is: (x_min, y_min), (x_max, y_min), (x_max, y_max), (x_min, y_max)

contains

operator fun contains(otherBox: Box): Boolean

Returns whether the other Box is contained within this Box. Edges of the other Box that overlap with this one's boundary are considered to be contained.

contains

operator fun contains(point: Vec): Boolean

Returns whether the given point is contained within the Box. Points that lie exactly on the Box's boundary are considered to be contained.

isAlmostEqual

fun isAlmostEqual(other: Box, tolerance: @FloatRange(from = 0.0) Float): Boolean

Compares this Box with other, and returns true if the difference between xMin and other.xMin is less than tolerance, and likewise for xMax, yMin, and yMax.

Public properties

height

val heightFloat

The height of the rectangle. This can never be negative.

width

val widthFloat

The width of the rectangle. This can never be negative.

xMax

abstract val xMaxFloat

The upper bound in the X direction.

xMin

abstract val xMinFloat

The lower bound in the X direction.

yMax

abstract val yMaxFloat

The upper bound in the Y direction.

yMin

abstract val yMinFloat

The lower bound in the Y direction.

Extension functions

populateRectF

fun Box.populateRectF(out: RectF): RectF

Writes the values from this Box to out.

Returns the modified RectF instance to allow chaining calls.

Returns
RectF

out

toRectF

fun Box.toRectF(): RectF

Constructs a Rect with the same coordinates as the Box

populateMutableRect

fun Box.populateMutableRect(out: MutableRect): MutableRect

Writes the values from this Box to out.

Returns the modified MutableRect instance to allow chaining calls.

Returns
MutableRect

out

fun Box.toRect(): Rect

Constructs a Rect with the values from this Box.