# BoxAccumulator

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

*** ** * ** ***

Common/AllAndroid/JVMNative/C/iOS
- Cmn

  ```
  class BoxAccumulator
  ```

*** ** * ** ***

A helper class for accumulating the minimum bounding boxes of zero or more geometry objects. In colloquial terms, this can be used to find the smallest Box that contains a set of objects.

## Summary

| ### Public constructors |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/ink/geometry/BoxAccumulator#BoxAccumulator()()` | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/ink/geometry/BoxAccumulator#BoxAccumulator(androidx.ink.geometry.Box)(box: https://developer.android.com/reference/kotlin/androidx/ink/geometry/Box)` Constructs a `https://developer.android.com/reference/kotlin/androidx/ink/geometry/BoxAccumulator`, populating the to accumulated bounding box from `https://developer.android.com/reference/kotlin/androidx/ink/geometry/BoxAccumulator#(androidx.ink.geometry.Box)`. | Cmn |

| ### Public functions |
|---|---|---|
| `https://developer.android.com/reference/kotlin/androidx/ink/geometry/BoxAccumulator` | `https://developer.android.com/reference/kotlin/androidx/ink/geometry/BoxAccumulator#add(androidx.ink.geometry.Box)(box: https://developer.android.com/reference/kotlin/androidx/ink/geometry/Box?)` Expands the accumulated bounding box (if necessary) such that it also contains `https://developer.android.com/reference/kotlin/androidx/ink/geometry/BoxAccumulator#add(androidx.ink.geometry.Box)`. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/ink/geometry/BoxAccumulator` | `https://developer.android.com/reference/kotlin/androidx/ink/geometry/BoxAccumulator#add(androidx.ink.geometry.PartitionedMesh)(mesh: https://developer.android.com/reference/kotlin/androidx/ink/geometry/PartitionedMesh)` Expands the accumulated bounding box (if necessary) such that it also contains `https://developer.android.com/reference/kotlin/androidx/ink/geometry/BoxAccumulator#add(androidx.ink.geometry.PartitionedMesh)`. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/ink/geometry/BoxAccumulator` | `https://developer.android.com/reference/kotlin/androidx/ink/geometry/BoxAccumulator#add(androidx.ink.geometry.BoxAccumulator)(other: https://developer.android.com/reference/kotlin/androidx/ink/geometry/BoxAccumulator?)` Expands the accumulated bounding box (if necessary) such that it also contains `https://developer.android.com/reference/kotlin/androidx/ink/geometry/BoxAccumulator#add(androidx.ink.geometry.BoxAccumulator)`. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/ink/geometry/BoxAccumulator` | `https://developer.android.com/reference/kotlin/androidx/ink/geometry/BoxAccumulator#add(androidx.ink.geometry.Parallelogram)(parallelogram: https://developer.android.com/reference/kotlin/androidx/ink/geometry/Parallelogram)` Expands the accumulated bounding box (if necessary) such that it also contains `https://developer.android.com/reference/kotlin/androidx/ink/geometry/BoxAccumulator#add(androidx.ink.geometry.Parallelogram)`. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/ink/geometry/BoxAccumulator` | `https://developer.android.com/reference/kotlin/androidx/ink/geometry/BoxAccumulator#add(androidx.ink.geometry.Vec)(point: https://developer.android.com/reference/kotlin/androidx/ink/geometry/Vec)` Expands the accumulated bounding box (if necessary) such that it also contains `Point`. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/ink/geometry/BoxAccumulator` | `https://developer.android.com/reference/kotlin/androidx/ink/geometry/BoxAccumulator#add(androidx.ink.geometry.Segment)(segment: https://developer.android.com/reference/kotlin/androidx/ink/geometry/Segment)` Expands the accumulated bounding box (if necessary) such that it also contains `https://developer.android.com/reference/kotlin/androidx/ink/geometry/BoxAccumulator#add(androidx.ink.geometry.Segment)`. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/ink/geometry/BoxAccumulator` | `https://developer.android.com/reference/kotlin/androidx/ink/geometry/BoxAccumulator#add(androidx.ink.geometry.Triangle)(triangle: https://developer.android.com/reference/kotlin/androidx/ink/geometry/Triangle)` Expands the accumulated bounding box (if necessary) such that it also contains `https://developer.android.com/reference/kotlin/androidx/ink/geometry/BoxAccumulator#add(androidx.ink.geometry.Triangle)`. | Cmn |
| `open operator https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/ink/geometry/BoxAccumulator#equals(kotlin.Any)(other: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?)` | Cmn |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/ink/geometry/BoxAccumulator#hashCode()()` | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/ink/geometry/BoxAccumulator#isAlmostEqual(androidx.ink.geometry.BoxAccumulator,kotlin.Float)( other: https://developer.android.com/reference/kotlin/androidx/ink/geometry/BoxAccumulator, 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/BoxAccumulator` with `https://developer.android.com/reference/kotlin/androidx/ink/geometry/BoxAccumulator#isAlmostEqual(androidx.ink.geometry.BoxAccumulator,kotlin.Float)`, and returns true if either: Both this and `https://developer.android.com/reference/kotlin/androidx/ink/geometry/BoxAccumulator#isAlmostEqual(androidx.ink.geometry.BoxAccumulator,kotlin.Float)` are empty, or neither this and `https://developer.android.com/reference/kotlin/androidx/ink/geometry/BoxAccumulator#isAlmostEqual(androidx.ink.geometry.BoxAccumulator,kotlin.Float)` are empty and their `https://developer.android.com/reference/kotlin/androidx/ink/geometry/BoxAccumulator#box()`es are almost equal per `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Box#isAlmostEqual(androidx.ink.geometry.Box,kotlin.Float)` | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/ink/geometry/BoxAccumulator#isEmpty()()` Returns true if this `https://developer.android.com/reference/kotlin/androidx/ink/geometry/BoxAccumulator` is not empty; this is equivalent to checking if the `https://developer.android.com/reference/kotlin/androidx/ink/geometry/BoxAccumulator#box()` property is null. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/ink/geometry/BoxAccumulator` | `https://developer.android.com/reference/kotlin/androidx/ink/geometry/BoxAccumulator#populateFrom(androidx.ink.geometry.Box)(input: https://developer.android.com/reference/kotlin/androidx/ink/geometry/Box?)` Resets the `https://developer.android.com/reference/kotlin/androidx/ink/geometry/BoxAccumulator` instance to contain just `https://developer.android.com/reference/kotlin/androidx/ink/geometry/BoxAccumulator#populateFrom(androidx.ink.geometry.Box)`. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/ink/geometry/BoxAccumulator` | `https://developer.android.com/reference/kotlin/androidx/ink/geometry/BoxAccumulator#reset()()` Reset this object to have no bounds. | Cmn |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/kotlin/androidx/ink/geometry/BoxAccumulator#toString()()` | Cmn |

| ### Public properties |
|---|---|---|
| `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Box?` | `https://developer.android.com/reference/kotlin/androidx/ink/geometry/BoxAccumulator#box()` The currently accumulated bounding box, or null if empty. | Cmn |

| ### Extension functions |
|---|---|---|
| `https://developer.android.com/reference/kotlin/androidx/ink/geometry/BoxAccumulator` | `https://developer.android.com/reference/kotlin/androidx/ink/geometry/BoxAccumulator.https://developer.android.com/reference/kotlin/androidx/ink/geometry/BoxAccumulator#(androidx.ink.geometry.BoxAccumulator).add(android.graphics.RectF)(rect: https://developer.android.com/reference/android/graphics/RectF.html)` Expands the accumulated bounding box (if necessary) such that it also contains `https://developer.android.com/reference/kotlin/androidx/ink/geometry/package-summary#(androidx.ink.geometry.BoxAccumulator).add(android.graphics.RectF)`. | android |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/ink/geometry/BoxAccumulator.https://developer.android.com/reference/kotlin/androidx/ink/geometry/BoxAccumulator#(androidx.ink.geometry.BoxAccumulator).getBounds(android.graphics.RectF)(outRect: https://developer.android.com/reference/android/graphics/RectF.html)` Fill the given `https://developer.android.com/reference/android/graphics/RectF.html` with the bounds of this `https://developer.android.com/reference/kotlin/androidx/ink/geometry/BoxAccumulator`, returning whether or not the object was actually overwritten. | android |
| `https://developer.android.com/reference/kotlin/androidx/ink/geometry/BoxAccumulator` | `https://developer.android.com/reference/kotlin/androidx/ink/geometry/BoxAccumulator.https://developer.android.com/reference/kotlin/androidx/ink/geometry/BoxAccumulator#(androidx.ink.geometry.BoxAccumulator).add(androidx.compose.ui.geometry.MutableRect)(rect: https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/MutableRect)` Expands the accumulated bounding box (if necessary) such that it also contains `https://developer.android.com/reference/kotlin/androidx/ink/geometry/compose/package-summary#(androidx.ink.geometry.BoxAccumulator).add(androidx.compose.ui.geometry.MutableRect)`. | android |
| `https://developer.android.com/reference/kotlin/androidx/ink/geometry/BoxAccumulator` | `https://developer.android.com/reference/kotlin/androidx/ink/geometry/BoxAccumulator.https://developer.android.com/reference/kotlin/androidx/ink/geometry/BoxAccumulator#(androidx.ink.geometry.BoxAccumulator).add(androidx.compose.ui.geometry.Rect)(rect: https://developer.android.com/reference/kotlin/androidx/compose/ui/geometry/Rect)` Expands the accumulated bounding box (if necessary) such that it also contains `https://developer.android.com/reference/kotlin/androidx/ink/geometry/compose/package-summary#(androidx.ink.geometry.BoxAccumulator).add(androidx.compose.ui.geometry.Rect)`. | android |

## Public constructors

### BoxAccumulator

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

```
BoxAccumulator()
```

### BoxAccumulator

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

```
BoxAccumulator(box: Box)
```

Constructs a `https://developer.android.com/reference/kotlin/androidx/ink/geometry/BoxAccumulator`, populating the to accumulated bounding box from `https://developer.android.com/reference/kotlin/androidx/ink/geometry/BoxAccumulator#(androidx.ink.geometry.Box)`.

## Public functions

### add

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

```
fun add(box: Box?): BoxAccumulator
```

Expands the accumulated bounding box (if necessary) such that it also contains `https://developer.android.com/reference/kotlin/androidx/ink/geometry/BoxAccumulator#add(androidx.ink.geometry.Box)`. If `https://developer.android.com/reference/kotlin/androidx/ink/geometry/BoxAccumulator#add(androidx.ink.geometry.Box)` is null, this is a no-op.

Returns the modified instance to allow chaining function calls.

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/ink/geometry/BoxAccumulator` | `this` |

### add

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

```
fun add(mesh: PartitionedMesh): BoxAccumulator
```

Expands the accumulated bounding box (if necessary) such that it also contains `https://developer.android.com/reference/kotlin/androidx/ink/geometry/BoxAccumulator#add(androidx.ink.geometry.PartitionedMesh)`. If `https://developer.android.com/reference/kotlin/androidx/ink/geometry/BoxAccumulator#add(androidx.ink.geometry.PartitionedMesh)` is empty, this is a no-op.

Returns the modified instance to allow chaining function calls.

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/ink/geometry/BoxAccumulator` | `this` |

### add

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

```
fun add(other: BoxAccumulator?): BoxAccumulator
```

Expands the accumulated bounding box (if necessary) such that it also contains `https://developer.android.com/reference/kotlin/androidx/ink/geometry/BoxAccumulator#add(androidx.ink.geometry.BoxAccumulator)`. If `https://developer.android.com/reference/kotlin/androidx/ink/geometry/BoxAccumulator#add(androidx.ink.geometry.BoxAccumulator)` is null, this is a no-op.

Returns the modified instance to allow chaining function calls.

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/ink/geometry/BoxAccumulator` | `this` |

### add

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

```
fun add(parallelogram: Parallelogram): BoxAccumulator
```

Expands the accumulated bounding box (if necessary) such that it also contains `https://developer.android.com/reference/kotlin/androidx/ink/geometry/BoxAccumulator#add(androidx.ink.geometry.Parallelogram)`.

Returns the modified instance to allow chaining function calls.

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/ink/geometry/BoxAccumulator` | `this` |

### add

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

```
fun add(point: Vec): BoxAccumulator
```

Expands the accumulated bounding box (if necessary) such that it also contains `Point`.

Returns the modified instance to allow chaining function calls.

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/ink/geometry/BoxAccumulator` | `this` |

### add

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

```
fun add(segment: Segment): BoxAccumulator
```

Expands the accumulated bounding box (if necessary) such that it also contains `https://developer.android.com/reference/kotlin/androidx/ink/geometry/BoxAccumulator#add(androidx.ink.geometry.Segment)`.

Returns the modified instance to allow chaining function calls.

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/ink/geometry/BoxAccumulator` | `this` |

### add

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

```
fun add(triangle: Triangle): BoxAccumulator
```

Expands the accumulated bounding box (if necessary) such that it also contains `https://developer.android.com/reference/kotlin/androidx/ink/geometry/BoxAccumulator#add(androidx.ink.geometry.Triangle)`.

Returns the modified instance to allow chaining function calls.

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/ink/geometry/BoxAccumulator` | `this` |

### equals

Cmn

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

### hashCode

Cmn

```
open fun hashCode(): Int
```

### isAlmostEqual

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

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

Compares this `https://developer.android.com/reference/kotlin/androidx/ink/geometry/BoxAccumulator` with `https://developer.android.com/reference/kotlin/androidx/ink/geometry/BoxAccumulator#isAlmostEqual(androidx.ink.geometry.BoxAccumulator,kotlin.Float)`, and returns true if either: Both this and `https://developer.android.com/reference/kotlin/androidx/ink/geometry/BoxAccumulator#isAlmostEqual(androidx.ink.geometry.BoxAccumulator,kotlin.Float)` are empty, or neither this and `https://developer.android.com/reference/kotlin/androidx/ink/geometry/BoxAccumulator#isAlmostEqual(androidx.ink.geometry.BoxAccumulator,kotlin.Float)` are empty and their `https://developer.android.com/reference/kotlin/androidx/ink/geometry/BoxAccumulator#box()`es are almost equal per `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Box#isAlmostEqual(androidx.ink.geometry.Box,kotlin.Float)`

### isEmpty

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

```
fun isEmpty(): Boolean
```

Returns true if this `https://developer.android.com/reference/kotlin/androidx/ink/geometry/BoxAccumulator` is not empty; this is equivalent to checking if the `https://developer.android.com/reference/kotlin/androidx/ink/geometry/BoxAccumulator#box()` property is null.

Note that a zero-area `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Box` is not considered empty, as a `https://developer.android.com/reference/kotlin/androidx/ink/geometry/Box` contains its boundary; so `https://developer.android.com/reference/kotlin/androidx/ink/geometry/BoxAccumulator#isEmpty()` will return false even if you have added only a single point to the `https://developer.android.com/reference/kotlin/androidx/ink/geometry/BoxAccumulator`.

### populateFrom

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

```
fun populateFrom(input: Box?): BoxAccumulator
```

Resets the `https://developer.android.com/reference/kotlin/androidx/ink/geometry/BoxAccumulator` instance to contain just `https://developer.android.com/reference/kotlin/androidx/ink/geometry/BoxAccumulator#populateFrom(androidx.ink.geometry.Box)`. If `https://developer.android.com/reference/kotlin/androidx/ink/geometry/BoxAccumulator#populateFrom(androidx.ink.geometry.Box)` is null, the instance will be reset to empty.

Returns the modified instance to allow chaining function calls.

A `https://developer.android.com/reference/kotlin/androidx/ink/geometry/BoxAccumulator` can be efficiently set to the same values as another `https://developer.android.com/reference/kotlin/androidx/ink/geometry/BoxAccumulator` with `populateFrom(other.box)`.

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/ink/geometry/BoxAccumulator` | `this` |

### reset

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

```
fun reset(): BoxAccumulator
```

Reset this object to have no bounds.

Returns the modified instance to allow chaining function calls.

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/ink/geometry/BoxAccumulator` | `this` |

### toString

Cmn

```
open fun toString(): String
```

## Public properties

### box

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

```
val box: Box?
```

The currently accumulated bounding box, or null if empty.

## Extension functions

### BoxAccumulator.add

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:add)

```
fun BoxAccumulator.add(rect: RectF): BoxAccumulator
```

Expands the accumulated bounding box (if necessary) such that it also contains `https://developer.android.com/reference/kotlin/androidx/ink/geometry/package-summary#(androidx.ink.geometry.BoxAccumulator).add(android.graphics.RectF)`. If `https://developer.android.com/reference/kotlin/androidx/ink/geometry/package-summary#(androidx.ink.geometry.BoxAccumulator).add(android.graphics.RectF)` is null, this is a no-op.

This is functionally equivalent to, but more efficient than: `add(ImmutableBox.from(rect))`

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/ink/geometry/BoxAccumulator` | `this` |

### BoxAccumulator.getBounds

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:getBounds)

```
fun BoxAccumulator.getBounds(outRect: RectF): Boolean
```

Fill the given `https://developer.android.com/reference/android/graphics/RectF.html` with the bounds of this `https://developer.android.com/reference/kotlin/androidx/ink/geometry/BoxAccumulator`, returning whether or not the object was actually overwritten.

### BoxAccumulator.add

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:add)

```
fun BoxAccumulator.add(rect: MutableRect): BoxAccumulator
```

Expands the accumulated bounding box (if necessary) such that it also contains `https://developer.android.com/reference/kotlin/androidx/ink/geometry/compose/package-summary#(androidx.ink.geometry.BoxAccumulator).add(androidx.compose.ui.geometry.MutableRect)`. If `https://developer.android.com/reference/kotlin/androidx/ink/geometry/compose/package-summary#(androidx.ink.geometry.BoxAccumulator).add(androidx.compose.ui.geometry.MutableRect)` is empty, this is a no-op.

Returns the modified instance to allow chaining calls.

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/ink/geometry/BoxAccumulator` | `this` |

### BoxAccumulator.add

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:add)

```
fun BoxAccumulator.add(rect: Rect): BoxAccumulator
```

Expands the accumulated bounding box (if necessary) such that it also contains `https://developer.android.com/reference/kotlin/androidx/ink/geometry/compose/package-summary#(androidx.ink.geometry.BoxAccumulator).add(androidx.compose.ui.geometry.Rect)`. If `https://developer.android.com/reference/kotlin/androidx/ink/geometry/compose/package-summary#(androidx.ink.geometry.BoxAccumulator).add(androidx.compose.ui.geometry.Rect)` is empty, this is a no-op.

Returns the modified instance to allow chaining calls.

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/ink/geometry/BoxAccumulator` | `this` |