# MutableBox

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

*** ** * ** ***

<br />

```
public final class MutableBox 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.MutableBox](https://developer.android.com/reference/androidx/ink/geometry/MutableBox) |

*** ** * ** ***

A mutable axis-aligned rectangle. See `https://developer.android.com/reference/androidx/ink/geometry/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 |
|---|
| `https://developer.android.com/reference/androidx/ink/geometry/MutableBox#MutableBox()()` Constructs a `https://developer.android.com/reference/androidx/ink/geometry/MutableBox` without any initial data. |

| ### Public methods |
|---|---|
| `boolean` | `https://developer.android.com/reference/androidx/ink/geometry/MutableBox#equals(kotlin.Any)(https://developer.android.com/reference/java/lang/Object.html other)` |
| `float` | `https://developer.android.com/reference/androidx/ink/geometry/MutableBox#getXMax()()` The upper bound in the `X` direction. |
| `float` | `https://developer.android.com/reference/androidx/ink/geometry/MutableBox#getXMin()()` The lower bound in the `X` direction. |
| `float` | `https://developer.android.com/reference/androidx/ink/geometry/MutableBox#getYMax()()` The upper bound in the `Y` direction. |
| `float` | `https://developer.android.com/reference/androidx/ink/geometry/MutableBox#getYMin()()` The lower bound in the `Y` direction. |
| `int` | `https://developer.android.com/reference/androidx/ink/geometry/MutableBox#hashCode()()` |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/geometry/MutableBox` | `https://developer.android.com/reference/androidx/ink/geometry/MutableBox#populateFrom(androidx.ink.geometry.Box)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/geometry/Box input)` Fills this `https://developer.android.com/reference/androidx/ink/geometry/MutableBox` with the same values contained in `https://developer.android.com/reference/androidx/ink/geometry/MutableBox#populateFrom(androidx.ink.geometry.Box)`. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/geometry/MutableBox` | `https://developer.android.com/reference/androidx/ink/geometry/MutableBox#populateFromCenterAndDimensions(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 a `https://developer.android.com/reference/androidx/ink/geometry/MutableBox` with a given `https://developer.android.com/reference/androidx/ink/geometry/MutableBox#populateFromCenterAndDimensions(androidx.ink.geometry.Vec,kotlin.Float,kotlin.Float)`, `https://developer.android.com/reference/androidx/ink/geometry/MutableBox#populateFromCenterAndDimensions(androidx.ink.geometry.Vec,kotlin.Float,kotlin.Float)`, and `https://developer.android.com/reference/androidx/ink/geometry/MutableBox#populateFromCenterAndDimensions(androidx.ink.geometry.Vec,kotlin.Float,kotlin.Float)`. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/geometry/MutableBox` | `https://developer.android.com/reference/androidx/ink/geometry/MutableBox#populateFromTwoPoints(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/MutableBox` containing the two given points. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/geometry/MutableBox` | `https://developer.android.com/reference/androidx/ink/geometry/MutableBox#setXBounds(kotlin.Float,kotlin.Float)(float x1, float x2)` Sets the lower and upper bounds in the `X` direction to new values. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/geometry/MutableBox` | `https://developer.android.com/reference/androidx/ink/geometry/MutableBox#setYBounds(kotlin.Float,kotlin.Float)(float y1, float y2)` Sets the lower and upper bounds in the `Y` direction to new values. |
| `@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/MutableBox#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/MutableBox#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 constructors

### MutableBox

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

```
public MutableBox()
```

Constructs a `https://developer.android.com/reference/androidx/ink/geometry/MutableBox` without any initial data. Fill with the appropriate setters or factory functions.

## Public methods

### equals

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

### 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()
```

### populateFrom

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

```
public final @NonNull MutableBox populateFrom(@NonNull Box input)
```

Fills this `https://developer.android.com/reference/androidx/ink/geometry/MutableBox` with the same values contained in `https://developer.android.com/reference/androidx/ink/geometry/MutableBox#populateFrom(androidx.ink.geometry.Box)`.

### populateFromCenterAndDimensions

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

```
public final @NonNull MutableBox populateFromCenterAndDimensions(
    @NonNull Vec center,
    @FloatRange(from = 0.0) float width,
    @FloatRange(from = 0.0) float height
)
```

Constructs a `https://developer.android.com/reference/androidx/ink/geometry/MutableBox` with a given `https://developer.android.com/reference/androidx/ink/geometry/MutableBox#populateFromCenterAndDimensions(androidx.ink.geometry.Vec,kotlin.Float,kotlin.Float)`, `https://developer.android.com/reference/androidx/ink/geometry/MutableBox#populateFromCenterAndDimensions(androidx.ink.geometry.Vec,kotlin.Float,kotlin.Float)`, and `https://developer.android.com/reference/androidx/ink/geometry/MutableBox#populateFromCenterAndDimensions(androidx.ink.geometry.Vec,kotlin.Float,kotlin.Float)`. `https://developer.android.com/reference/androidx/ink/geometry/MutableBox#populateFromCenterAndDimensions(androidx.ink.geometry.Vec,kotlin.Float,kotlin.Float)` and `https://developer.android.com/reference/androidx/ink/geometry/MutableBox#populateFromCenterAndDimensions(androidx.ink.geometry.Vec,kotlin.Float,kotlin.Float)` must be non-negative numbers.

### populateFromTwoPoints

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

```
public final @NonNull MutableBox populateFromTwoPoints(@NonNull Vec point1, @NonNull Vec point2)
```

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

### setXBounds

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

```
public final @NonNull MutableBox setXBounds(float x1, float x2)
```

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](https://developer.android.com/jetpack/androidx/releases/ink#1.0.0)

```
public final @NonNull MutableBox setYBounds(float y1, float y2)
```

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.

### 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()
```