MutableBox


class MutableBox : Box


A mutable axis-aligned rectangle. See ImmutableBox for an immutable version.

Note that unlike android.graphics.RectF, this does not express an opinion about axis direction (e.g. the positive Y axis being "down"), because it is intended to be used with any coordinate system rather than just Android screen/View space.

Summary

Public constructors

Constructs a MutableBox without any initial data.

Public functions

open operator Boolean
equals(other: Any?)
open Int
MutableBox
populateFrom(input: Box)

Fills this MutableBox with the same values contained in input.

MutableBox
populateFromCenterAndDimensions(
    center: Vec,
    width: @FloatRange(from = 0.0) Float,
    height: @FloatRange(from = 0.0) Float
)

Constructs a MutableBox with a given center, width, and height.

MutableBox
populateFromTwoPoints(point1: Vec, point2: Vec)

Constructs the smallest MutableBox containing the two given points.

MutableBox
setXBounds(x1: Float, x2: Float)

Sets the lower and upper bounds in the X direction to new values.

MutableBox
setYBounds(y1: Float, y2: Float)

Sets the lower and upper bounds in the Y direction to new values.

open String

Public properties

open Float

The upper bound in the X direction.

open Float

The lower bound in the X direction.

open Float

The upper bound in the Y direction.

open Float

The lower bound in the Y direction.

Inherited functions

From androidx.ink.geometry.Box
MutableVec

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

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

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

operator Boolean
contains(otherBox: Box)

Returns whether the other Box is contained within this Box.

operator Boolean
contains(point: Vec)

Returns whether the given point is contained within the Box.

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.

Inherited properties

From androidx.ink.geometry.Box
Float

The height of the rectangle.

Float

The width of the rectangle.

Public constructors

MutableBox

Added in 1.0.0-alpha01
MutableBox()

Constructs a MutableBox without any initial data. Fill with the appropriate setters or factory functions.

Public functions

equals

open operator fun equals(other: Any?): Boolean

hashCode

open fun hashCode(): Int

populateFrom

Added in 1.0.0-alpha01
fun populateFrom(input: Box): MutableBox

Fills this MutableBox with the same values contained in input.

populateFromCenterAndDimensions

Added in 1.0.0-alpha01
fun populateFromCenterAndDimensions(
    center: Vec,
    width: @FloatRange(from = 0.0) Float,
    height: @FloatRange(from = 0.0) Float
): MutableBox

Constructs a MutableBox with a given center, width, and height. width and height must be non-negative numbers.

populateFromTwoPoints

Added in 1.0.0-alpha01
fun populateFromTwoPoints(point1: Vec, point2: Vec): MutableBox

Constructs the smallest MutableBox containing the two given points.

setXBounds

Added in 1.0.0-alpha01
fun setXBounds(x1: Float, x2: Float): MutableBox

Sets the lower and upper bounds in the X direction to new values. The minimum value becomes xMin, and the maximum value becomes xMax. Returns the same instance to chain function calls.

setYBounds

Added in 1.0.0-alpha01
fun setYBounds(y1: Float, y2: Float): MutableBox

Sets the lower and upper bounds in the Y direction to new values. The minimum value becomes yMin, and the maximum value becomes yMax. Returns the same instance to chain function calls.

toString

open fun toString(): String

Public properties

xMax

Added in 1.0.0-alpha01
open val xMaxFloat

The upper bound in the X direction.

xMin

Added in 1.0.0-alpha01
open val xMinFloat

The lower bound in the X direction.

yMax

Added in 1.0.0-alpha01
open val yMaxFloat

The upper bound in the Y direction.

yMin

Added in 1.0.0-alpha01
open val yMinFloat

The lower bound in the Y direction.