# Box

Artifact: [androidx.ink:ink-geometry](https://developer.android.com/jetpack/androidx/releases/ink) [View Source](https://cs.android.com/search?q=file:androidx/ink/geometry/Box.kt+class:androidx.ink.geometry.Box) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/ink#1.0.0)

*** ** * ** ***

Common/AllAndroid/JVMNative/C/iOS
- Cmn

  ```
  abstract class Box
  ```
Known direct subclasses [ImmutableBox](https://developer.android.com/reference/kotlin/androidx/ink/geometry/ImmutableBox), [MutableBox](https://developer.android.com/reference/kotlin/androidx/ink/geometry/MutableBox)

|---|---|
| `https://developer.android.com/reference/kotlin/androidx/ink/geometry/ImmutableBox` | An immutable axis-aligned rectangle. |
| `https://developer.android.com/reference/kotlin/androidx/ink/geometry/MutableBox` | A mutable axis-aligned rectangle. |

*** ** * ** ***

Represents an axis-aligned rectangle. See `https://developer.android.com/reference/kotlin/androidx/ink/geometry/ImmutableBox` and `https://developer.android.com/reference/kotlin/androidx/ink/geometry/MutableBox` for concrete classes implementing `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Box`.

The `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Box` interface is the read-only view of the underlying data which may or may not be mutable.

## Summary

| ### Public functions |
|---|---|---|
| `https://developer.android.com/reference/kotlin/androidx/ink/geometry/ImmutableVec` | `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Box#computeCenter()()` Returns the center of the `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Box`. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/ink/geometry/MutableVec` | `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Box#computeCenter(androidx.ink.geometry.MutableVec)(outVec: https://developer.android.com/reference/kotlin/androidx/ink/geometry/MutableVec)` Populates `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Box#computeCenter(androidx.ink.geometry.MutableVec)` with the center of the `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Box`, and returns `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Box#computeCenter(androidx.ink.geometry.MutableVec)`. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/kotlin/androidx/ink/geometry/ImmutableVec>` | `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Box#computeCorners()()` Returns a list containing the 4 corners of the `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Box`. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Box#computeCorners(androidx.ink.geometry.MutableVec,androidx.ink.geometry.MutableVec,androidx.ink.geometry.MutableVec,androidx.ink.geometry.MutableVec)( outVecXMinYMin: https://developer.android.com/reference/kotlin/androidx/ink/geometry/MutableVec, outVecXMaxYMin: https://developer.android.com/reference/kotlin/androidx/ink/geometry/MutableVec, outVecXMaxYMax: https://developer.android.com/reference/kotlin/androidx/ink/geometry/MutableVec, outVecXMinYMax: https://developer.android.com/reference/kotlin/androidx/ink/geometry/MutableVec )` Populates the 4 output points with the corners of the `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Box`. | Cmn |
| `operator https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Box#contains(androidx.ink.geometry.Box)(otherBox: https://developer.android.com/reference/kotlin/androidx/ink/geometry/Box)` Returns whether the other Box is contained within this Box. | Cmn |
| `operator https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Box#contains(androidx.ink.geometry.Vec)(point: https://developer.android.com/reference/kotlin/androidx/ink/geometry/Vec)` Returns whether the given point is contained within the Box. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Box#isAlmostEqual(androidx.ink.geometry.Box,kotlin.Float)(other: https://developer.android.com/reference/kotlin/androidx/ink/geometry/Box, tolerance: @https://developer.android.com/reference/kotlin/androidx/annotation/FloatRange(from = 0.0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html)` Compares this `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Box` with `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Box#isAlmostEqual(androidx.ink.geometry.Box,kotlin.Float)`, and returns true if the difference between `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Box#xMin()` from `this` and `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Box#xMin()` from `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Box#isAlmostEqual(androidx.ink.geometry.Box,kotlin.Float)` is less than `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Box#isAlmostEqual(androidx.ink.geometry.Box,kotlin.Float)`, and likewise for `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Box#xMax()`, `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Box#yMin()`, and `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Box#yMax()`. | Cmn |
| `abstract https://developer.android.com/reference/kotlin/androidx/ink/geometry/ImmutableBox` | `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Box#toImmutable()()` Returns an immutable copy of this object. | Cmn |

| ### Public properties |
|---|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Box#height()` The height of the rectangle. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Box#width()` The width of the rectangle. | Cmn |
| `abstract https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Box#xMax()` The upper bound in the `X` direction. | Cmn |
| `abstract https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Box#xMin()` The lower bound in the `X` direction. | Cmn |
| `abstract https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Box#yMax()` The upper bound in the `Y` direction. | Cmn |
| `abstract https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Box#yMin()` The lower bound in the `Y` direction. | Cmn |

| ### Extension functions |
|---|---|---|
| `https://developer.android.com/reference/android/graphics/RectF.html` | `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Box.https://developer.android.com/reference/kotlin/androidx/ink/geometry/Box#(androidx.ink.geometry.Box).populateRectF(android.graphics.RectF)(out: https://developer.android.com/reference/android/graphics/RectF.html)` Writes the values from this `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Box` to `https://developer.android.com/reference/kotlin/androidx/ink/geometry/package-summary#(androidx.ink.geometry.Box).populateRectF(android.graphics.RectF)`. | android |
| `https://developer.android.com/reference/android/graphics/RectF.html` | `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Box.https://developer.android.com/reference/kotlin/androidx/ink/geometry/Box#(androidx.ink.geometry.Box).toRectF()()` Constructs a `https://developer.android.com/reference/android/graphics/RectF.html` with the same coordinates as the `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Box` | android |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/MutableRect` | `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Box.https://developer.android.com/reference/kotlin/androidx/ink/geometry/Box#(androidx.ink.geometry.Box).populateMutableRect(androidx.compose.ui.geometry.MutableRect)(out: https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/MutableRect)` Writes the values from this `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Box` to `https://developer.android.com/reference/kotlin/androidx/ink/geometry/compose/package-summary#(androidx.ink.geometry.Box).populateMutableRect(androidx.compose.ui.geometry.MutableRect)`. | android |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Rect` | `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Box.https://developer.android.com/reference/kotlin/androidx/ink/geometry/Box#(androidx.ink.geometry.Box).toRect()()` Constructs a `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Rect` with the values from this `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Box`. | android |

## Public functions

### computeCenter

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/ink#1.0.0)

```
fun computeCenter(): ImmutableVec
```

Returns the center of the `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Box`.

Performance-sensitive code should use the `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Box#computeCenter()` overload that takes a pre-allocated `https://developer.android.com/reference/kotlin/androidx/ink/geometry/MutableVec`, so that instance can be reused across multiple calls.

### computeCenter

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/ink#1.0.0)

```
fun computeCenter(outVec: MutableVec): MutableVec
```

Populates `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Box#computeCenter(androidx.ink.geometry.MutableVec)` with the center of the `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Box`, and returns `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Box#computeCenter(androidx.ink.geometry.MutableVec)`.

### computeCorners

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/ink#1.0.0)

```
fun computeCorners(): List<ImmutableVec>
```

Returns a list containing the 4 corners of the `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Box`. The order of the corners is: (x_min, y_min), (x_max, y_min), (x_max, y_max), (x_min, y_max).

### computeCorners

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/ink#1.0.0)

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

Populates the 4 output points with the corners of the `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Box`. The order of the corners is: (x_min, y_min), (x_max, y_min), (x_max, y_max), (x_min, y_max)

### contains

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/ink#1.0.0)

```
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

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/ink#1.0.0)

```
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

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/ink#1.0.0)

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

Compares this `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Box` with `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Box#isAlmostEqual(androidx.ink.geometry.Box,kotlin.Float)`, and returns true if the difference between `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Box#xMin()` from `this` and `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Box#xMin()` from `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Box#isAlmostEqual(androidx.ink.geometry.Box,kotlin.Float)` is less than `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Box#isAlmostEqual(androidx.ink.geometry.Box,kotlin.Float)`, and likewise for `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Box#xMax()`, `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Box#yMin()`, and `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Box#yMax()`.

### toImmutable

Cmn Added in [1.1.0-alpha11](https://developer.android.com/jetpack/androidx/releases/ink#1.1.0-alpha11)

```
abstract fun toImmutable(): ImmutableBox
```

Returns an immutable copy of this object. This will return itself if called on an immutable instance.

## Public properties

### height

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/ink#1.0.0)

```
val height: Float
```

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

### width

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/ink#1.0.0)

```
val width: Float
```

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

### xMax

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/ink#1.0.0)

```
abstract val xMax: Float
```

The upper bound in the `X` direction.

### xMin

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/ink#1.0.0)

```
abstract val xMin: Float
```

The lower bound in the `X` direction.

### yMax

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/ink#1.0.0)

```
abstract val yMax: Float
```

The upper bound in the `Y` direction.

### yMin

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/ink#1.0.0)

```
abstract val yMin: Float
```

The lower bound in the `Y` direction.

## Extension functions

### Box.populateRectF

android Artifact: [androidx.ink:ink-geometry](https://developer.android.com/jetpack/androidx/releases/ink) [View Source](https://cs.android.com/search?q=file:androidx/ink/geometry/AndroidGraphicsConversionExtensions.android.kt+function:populateRectF)

```
fun Box.populateRectF(out: RectF): RectF
```

Writes the values from this `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Box` to `https://developer.android.com/reference/kotlin/androidx/ink/geometry/package-summary#(androidx.ink.geometry.Box).populateRectF(android.graphics.RectF)`.

Returns the modified `https://developer.android.com/reference/android/graphics/RectF.html` instance to allow chaining calls.

| Returns |
|---|---|
| `https://developer.android.com/reference/android/graphics/RectF.html` | `https://developer.android.com/reference/kotlin/androidx/ink/geometry/package-summary#(androidx.ink.geometry.Box).populateRectF(android.graphics.RectF)` |

### Box.toRectF

android Artifact: [androidx.ink:ink-geometry](https://developer.android.com/jetpack/androidx/releases/ink) [View Source](https://cs.android.com/search?q=file:androidx/ink/geometry/AndroidGraphicsConversionExtensions.android.kt+function:toRectF)

```
fun Box.toRectF(): RectF
```

Constructs a `https://developer.android.com/reference/android/graphics/RectF.html` with the same coordinates as the `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Box`

### Box.populateMutableRect

android Artifact: [androidx.ink:ink-geometry-compose](https://developer.android.com/jetpack/androidx/releases/ink) [View Source](https://cs.android.com/search?q=file:androidx/ink/geometry/compose/ComposeConversionExtensions.kt+function:populateMutableRect)

```
fun Box.populateMutableRect(out: MutableRect): MutableRect
```

Writes the values from this `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Box` to `https://developer.android.com/reference/kotlin/androidx/ink/geometry/compose/package-summary#(androidx.ink.geometry.Box).populateMutableRect(androidx.compose.ui.geometry.MutableRect)`.

Returns the modified `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/MutableRect` instance to allow chaining calls.

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/MutableRect` | `https://developer.android.com/reference/kotlin/androidx/ink/geometry/compose/package-summary#(androidx.ink.geometry.Box).populateMutableRect(androidx.compose.ui.geometry.MutableRect)` |

### Box.toRect

android Artifact: [androidx.ink:ink-geometry-compose](https://developer.android.com/jetpack/androidx/releases/ink) [View Source](https://cs.android.com/search?q=file:androidx/ink/geometry/compose/ComposeConversionExtensions.kt+function:toRect)

```
fun Box.toRect(): Rect
```

Constructs a `https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Rect` with the values from this `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Box`.