Box
-
Cmn
abstract class Box
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 |
||
|---|---|---|
ImmutableVec |
Returns the center of the |
Cmn
|
MutableVec |
computeCenter(outVec: MutableVec)Populates |
Cmn
|
List<ImmutableVec> |
Returns a list containing the 4 corners of the |
Cmn
|
Unit |
computeCorners(Populates the 4 output points with the corners of the |
Cmn
|
operator Boolean |
Returns whether the other Box is contained within this Box. |
Cmn
|
operator Boolean |
Returns whether the given point is contained within the Box. |
Cmn
|
Boolean |
isAlmostEqual(other: Box, tolerance: @FloatRange(from = 0.0) Float)Compares this |
Cmn
|
abstract ImmutableBox |
Returns an immutable copy of this object. |
Cmn
|
Public properties |
||
|---|---|---|
Float |
The height of the rectangle. |
Cmn
|
Float |
The width of the rectangle. |
Cmn
|
abstract Float |
The upper bound in the |
Cmn
|
abstract Float |
The lower bound in the |
Cmn
|
abstract Float |
The upper bound in the |
Cmn
|
abstract Float |
The lower bound in the |
Cmn
|
Extension functions |
||
|---|---|---|
RectF |
Box.populateRectF(out: RectF) |
android
|
RectF |
android
|
|
MutableRect |
android
|
|
Rect |
android
|
Public functions
computeCenter
fun computeCenter(): ImmutableVec
Returns the center of the Box.
Performance-sensitive code should use the computeCenter overload that takes a pre-allocated MutableVec, so that instance can be reused across multiple calls.
computeCenter
fun computeCenter(outVec: MutableVec): MutableVec
Populates outVec with the center of the Box, and returns outVec.
computeCorners
fun computeCorners(): List<ImmutableVec>
Returns a list containing the 4 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).
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 from this and xMin from other is less than tolerance, and likewise for xMax, yMin, and yMax.
toImmutable
abstract fun toImmutable(): ImmutableBox
Returns an immutable copy of this object. This will return itself if called on an immutable instance.
Public properties
Extension functions
Box.populateRectF
fun Box.populateRectF(out: RectF): RectF
Writes the values from this Box to out.
Returns the modified RectF instance to allow chaining calls.
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 |