# ImmutableBox

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/ImmutableBox.kt+class:androidx.ink.geometry.ImmutableBox) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/ink#1.0.0)

*** ** * ** ***


```
public final class ImmutableBox extends Box
```

<br />

|---|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object.html) |||
| ↳ | [androidx.ink.geometry.Box](https://developer.android.com/reference/androidx/ink/geometry/Box) ||
|   | ↳ | [androidx.ink.geometry.ImmutableBox](https://developer.android.com/reference/androidx/ink/geometry/ImmutableBox) |

*** ** * ** ***

An immutable axis-aligned rectangle. See `https://developer.android.com/reference/androidx/ink/geometry/MutableBox` for a mutable 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

| ### Nested types |
|---|
| `public static class https://developer.android.com/reference/androidx/ink/geometry/ImmutableBox.Companion` |

| ### Public methods |
|---|---|
| `boolean` | `https://developer.android.com/reference/androidx/ink/geometry/ImmutableBox#equals(kotlin.Any)(https://developer.android.com/reference/java/lang/Object.html other)` |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/geometry/ImmutableBox` | `https://developer.android.com/reference/androidx/ink/geometry/ImmutableBox#fromCenterAndDimensions(androidx.ink.geometry.Vec,kotlin.Float,kotlin.Float)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/geometry/Vec center, @https://developer.android.com/reference/androidx/annotation/FloatRange(from = 0.0) float width, @https://developer.android.com/reference/androidx/annotation/FloatRange(from = 0.0) float height )` Constructs an `https://developer.android.com/reference/androidx/ink/geometry/ImmutableBox` with a given `https://developer.android.com/reference/androidx/ink/geometry/ImmutableBox.Companion#fromCenterAndDimensions(androidx.ink.geometry.Vec,kotlin.Float,kotlin.Float)`, `https://developer.android.com/reference/androidx/ink/geometry/ImmutableBox.Companion#fromCenterAndDimensions(androidx.ink.geometry.Vec,kotlin.Float,kotlin.Float)`, and `https://developer.android.com/reference/androidx/ink/geometry/ImmutableBox.Companion#fromCenterAndDimensions(androidx.ink.geometry.Vec,kotlin.Float,kotlin.Float)`. |
| `static final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/geometry/ImmutableBox` | `https://developer.android.com/reference/androidx/ink/geometry/ImmutableBox#fromTwoPoints(androidx.ink.geometry.Vec,androidx.ink.geometry.Vec)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/geometry/Vec point1, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/geometry/Vec point2)` Constructs the smallest `https://developer.android.com/reference/androidx/ink/geometry/ImmutableBox` containing the two given points. |
| `float` | `https://developer.android.com/reference/androidx/ink/geometry/ImmutableBox#getXMax()()` The upper bound in the `X` direction. |
| `float` | `https://developer.android.com/reference/androidx/ink/geometry/ImmutableBox#getXMin()()` The lower bound in the `X` direction. |
| `float` | `https://developer.android.com/reference/androidx/ink/geometry/ImmutableBox#getYMax()()` The upper bound in the `Y` direction. |
| `float` | `https://developer.android.com/reference/androidx/ink/geometry/ImmutableBox#getYMin()()` The lower bound in the `Y` direction. |
| `int` | `https://developer.android.com/reference/androidx/ink/geometry/ImmutableBox#hashCode()()` |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/geometry/ImmutableBox` | `https://developer.android.com/reference/androidx/ink/geometry/ImmutableBox#toImmutable()()` Returns an immutable copy of this object. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html` | `https://developer.android.com/reference/androidx/ink/geometry/ImmutableBox#toString()()` |

| ### Inherited methods |
|---|
| From [androidx.ink.geometry.Box](https://developer.android.com/reference/androidx/ink/geometry/Box) |---|---| | `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/geometry/ImmutableVec` | `https://developer.android.com/reference/androidx/ink/geometry/Box#computeCenter()()` Returns the center of the `https://developer.android.com/reference/androidx/ink/geometry/Box`. | | `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/geometry/MutableVec` | `https://developer.android.com/reference/androidx/ink/geometry/Box#computeCenter(androidx.ink.geometry.MutableVec)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/geometry/MutableVec outVec)` Populates `https://developer.android.com/reference/androidx/ink/geometry/Box#computeCenter(androidx.ink.geometry.MutableVec)` with the center of the `https://developer.android.com/reference/androidx/ink/geometry/Box`, and returns `https://developer.android.com/reference/androidx/ink/geometry/Box#computeCenter(androidx.ink.geometry.MutableVec)`. | | `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/List.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/geometry/ImmutableVec>` | `https://developer.android.com/reference/androidx/ink/geometry/Box#computeCorners()()` Returns a list containing the 4 corners of the `https://developer.android.com/reference/androidx/ink/geometry/Box`. | | `final void` | `https://developer.android.com/reference/androidx/ink/geometry/Box#computeCorners(androidx.ink.geometry.MutableVec,androidx.ink.geometry.MutableVec,androidx.ink.geometry.MutableVec,androidx.ink.geometry.MutableVec)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/geometry/MutableVec outVecXMinYMin, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/geometry/MutableVec outVecXMaxYMin, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/geometry/MutableVec outVecXMaxYMax, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/geometry/MutableVec outVecXMinYMax )` Populates the 4 output points with the corners of the `https://developer.android.com/reference/androidx/ink/geometry/Box`. | | `final boolean` | `https://developer.android.com/reference/androidx/ink/geometry/Box#contains(androidx.ink.geometry.Box)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/geometry/Box otherBox)` Returns whether the other Box is contained within this Box. | | `final boolean` | `https://developer.android.com/reference/androidx/ink/geometry/Box#contains(androidx.ink.geometry.Vec)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/geometry/Vec point)` Returns whether the given point is contained within the Box. | | `final @https://developer.android.com/reference/androidx/annotation/FloatRange(from = 0.0) float` | `https://developer.android.com/reference/androidx/ink/geometry/Box#getHeight()()` The height of the rectangle. | | `final @https://developer.android.com/reference/androidx/annotation/FloatRange(from = 0.0) float` | `https://developer.android.com/reference/androidx/ink/geometry/Box#getWidth()()` The width of the rectangle. | | `final boolean` | `https://developer.android.com/reference/androidx/ink/geometry/Box#isAlmostEqual(androidx.ink.geometry.Box,kotlin.Float)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/geometry/Box other, @https://developer.android.com/reference/androidx/annotation/FloatRange(from = 0.0) float tolerance)` Compares this `https://developer.android.com/reference/androidx/ink/geometry/Box` with `https://developer.android.com/reference/androidx/ink/geometry/Box#isAlmostEqual(androidx.ink.geometry.Box,kotlin.Float)`, and returns true if the difference between `https://developer.android.com/reference/androidx/ink/geometry/Box#xMin()` from `this` and `https://developer.android.com/reference/androidx/ink/geometry/Box#xMin()` from `https://developer.android.com/reference/androidx/ink/geometry/Box#isAlmostEqual(androidx.ink.geometry.Box,kotlin.Float)` is less than `https://developer.android.com/reference/androidx/ink/geometry/Box#isAlmostEqual(androidx.ink.geometry.Box,kotlin.Float)`, and likewise for `https://developer.android.com/reference/androidx/ink/geometry/Box#xMax()`, `https://developer.android.com/reference/androidx/ink/geometry/Box#yMin()`, and `https://developer.android.com/reference/androidx/ink/geometry/Box#yMax()`. | |

## Public methods

### equals

```
public boolean equals(Object other)
```

### fromCenterAndDimensions

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

```
public static final @NonNull ImmutableBox fromCenterAndDimensions(
    @NonNull Vec center,
    @FloatRange(from = 0.0) float width,
    @FloatRange(from = 0.0) float height
)
```

Constructs an `https://developer.android.com/reference/androidx/ink/geometry/ImmutableBox` with a given `https://developer.android.com/reference/androidx/ink/geometry/ImmutableBox.Companion#fromCenterAndDimensions(androidx.ink.geometry.Vec,kotlin.Float,kotlin.Float)`, `https://developer.android.com/reference/androidx/ink/geometry/ImmutableBox.Companion#fromCenterAndDimensions(androidx.ink.geometry.Vec,kotlin.Float,kotlin.Float)`, and `https://developer.android.com/reference/androidx/ink/geometry/ImmutableBox.Companion#fromCenterAndDimensions(androidx.ink.geometry.Vec,kotlin.Float,kotlin.Float)`.

### fromTwoPoints

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

```
public static final @NonNull ImmutableBox fromTwoPoints(@NonNull Vec point1, @NonNull Vec point2)
```

Constructs the smallest `https://developer.android.com/reference/androidx/ink/geometry/ImmutableBox` containing the two given points.

### getXMax

```
public float getXMax()
```

The upper bound in the `X` direction.

### getXMin

```
public float getXMin()
```

The lower bound in the `X` direction.

### getYMax

```
public float getYMax()
```

The upper bound in the `Y` direction.

### getYMin

```
public float getYMin()
```

The lower bound in the `Y` direction.

### hashCode

```
public int hashCode()
```

### toImmutable

```
public @NonNull ImmutableBox toImmutable()
```

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

### toString

```
public @NonNull String toString()
```