# MutableStrokeInputBatch

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

*** ** * ** ***

Common/All
- Cmn

  ```
  class MutableStrokeInputBatch : StrokeInputBatch
  ```

|---|---|---|
| [kotlin.Any](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html) |||
| ↳ | [androidx.ink.strokes.StrokeInputBatch](https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInputBatch) ||
|   | ↳ | [androidx.ink.strokes.MutableStrokeInputBatch](https://developer.android.com/reference/kotlin/androidx/ink/strokes/MutableStrokeInputBatch) |

*** ** * ** ***

A mutable implementation of `https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInputBatch`. For an immutable alternative, see `https://developer.android.com/reference/kotlin/androidx/ink/strokes/ImmutableStrokeInputBatch`.

Each appended `https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInput` value is validated compared to the existing batch contents. This means:

1. All floating point values are required to be finite and the format of all inputs must be consistent. This means all inputs must have the same set of optional member variables that hold a value. For example, every input holds a `https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInput#pressure()` value if-and-only-if every other input holds a `https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInput#pressure()` value. This is also true for `https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInput#tiltRadians()`, `https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInput#orientationRadians()`, and barrel twist via `https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInput#getBarrelTwistRadians()`.

2. The sequence of `https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInput` values must not contain repeated x-y-t triplets, and the time values must be non-negative and non-decreasing.

3. Values of `https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInput#strokeUnitLengthCm()` must be finite and positive, or be `https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInput#NO_STROKE_UNIT_LENGTH()`.

4. Values of `https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInput#pressure()` must fall within the range of 0, 1 or be `https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInput#NO_PRESSURE()`

5. Values of `https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInput#tiltRadians()` must fall within the range of 0, π/2 or be `https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInput#NO_TILT()`.

6. Values of `https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInput#orientationRadians()` must fall within the range of \[0, 2π) or be `https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInput#NO_ORIENTATION()`.

7. Values returned by `https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInput#getBarrelTwistRadians()` must fall within the range of \[0, 2π) or be `https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInput.Companion#NO_BARREL_TWIST()`.

8. The `https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInput#toolType()` and `https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInput#strokeUnitLengthCm()` values must be the same across all inputs.

## Summary

| ### Public constructors |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/ink/strokes/MutableStrokeInputBatch#MutableStrokeInputBatch()()` | Cmn |

| ### Public functions |
|---|---|---|
| `https://developer.android.com/reference/kotlin/androidx/ink/strokes/MutableStrokeInputBatch` | `https://developer.android.com/reference/kotlin/androidx/ink/strokes/MutableStrokeInputBatch#add(androidx.ink.strokes.StrokeInputBatch)(inputBatch: https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInputBatch)` Validates and appends an `https://developer.android.com/reference/kotlin/androidx/ink/strokes/MutableStrokeInputBatch#add(androidx.ink.strokes.StrokeInputBatch)`. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/ink/strokes/MutableStrokeInputBatch` | `https://developer.android.com/reference/kotlin/androidx/ink/strokes/MutableStrokeInputBatch#add(androidx.ink.strokes.StrokeInput)(input: https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInput)` Adds an `https://developer.android.com/reference/kotlin/androidx/ink/strokes/MutableStrokeInputBatch#add(androidx.ink.strokes.StrokeInput)` to the batch if valid. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/ink/strokes/MutableStrokeInputBatch` | `https://developer.android.com/reference/kotlin/androidx/ink/strokes/MutableStrokeInputBatch#add(kotlin.collections.Collection)(inputs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-collection/index.html<https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInput>)` Validates and appends a collection of `https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInput`. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/ink/strokes/MutableStrokeInputBatch` | `https://developer.android.com/reference/kotlin/androidx/ink/strokes/MutableStrokeInputBatch#add(androidx.ink.brush.InputToolType,kotlin.Float,kotlin.Float,kotlin.Long,kotlin.Float,kotlin.Float,kotlin.Float,kotlin.Float)( type: https://developer.android.com/reference/kotlin/androidx/ink/brush/InputToolType, x: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, y: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, elapsedTimeMillis: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, strokeUnitLengthCm: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, pressure: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, tiltRadians: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html, orientationRadians: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html )` Variant of `https://developer.android.com/reference/kotlin/androidx/ink/strokes/MutableStrokeInputBatch#add(androidx.ink.brush.InputToolType,kotlin.Float,kotlin.Float,kotlin.Long,kotlin.Float,kotlin.Float,kotlin.Float,kotlin.Float)` that takes individual parameters instead of a `https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInput`. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/ink/strokes/MutableStrokeInputBatch#clear()()` | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/ink/strokes/MutableStrokeInputBatch#setNoiseSeed(kotlin.Int)(seed: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Sets the per-stroke seed value that should be used when regenerating a stroke from this input batch. | Cmn |
| `open https://developer.android.com/reference/kotlin/androidx/ink/strokes/ImmutableStrokeInputBatch` | `https://developer.android.com/reference/kotlin/androidx/ink/strokes/MutableStrokeInputBatch#toImmutable()()` Create `https://developer.android.com/reference/kotlin/androidx/ink/strokes/ImmutableStrokeInputBatch` with the accumulated StrokeInputs. | Cmn |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/kotlin/androidx/ink/strokes/MutableStrokeInputBatch#toString()()` | Cmn |

### Inherited functions

From [androidx.ink.strokes.StrokeInputBatch](https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInputBatch) `operator https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInput` `https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInputBatch#get(kotlin.Int)(index: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`

Gets the value of the i-th input.
Cmn `@https://developer.android.com/reference/kotlin/androidx/annotation/FloatRange(from = 0.0, to = 1.0, toInclusive = false) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` `https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInputBatch#getBasePaintAnimationPhase()()`

Returns the \[0, 1) value that will determine the stroke's overall paint animation progress at some arbitrary zero clock state, so that different strokes can be animated correctly relative to each other.
Cmn `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` `https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInputBatch#getDurationMillis()()`

The duration between the first and last input in milliseconds.
Cmn `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` `https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInputBatch#getNoiseSeed()()`

Returns the seed value that should be used for seeding any noise generators for brush behaviors when a full stroke is regenerated with this input batch.
Cmn `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` `https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInputBatch#getStrokeUnitLengthCm()()`

The physical distance in centimeters that the pointer must travel in order to produce an input motion of one stroke unit.
Cmn `https://developer.android.com/reference/kotlin/androidx/ink/brush/InputToolType` `https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInputBatch#getToolType()()`

How this input stream should be interpreted, as coming from a `https://developer.android.com/reference/kotlin/androidx/ink/brush/InputToolType#MOUSE()`, `https://developer.android.com/reference/kotlin/androidx/ink/brush/InputToolType#TOUCH()`, or `https://developer.android.com/reference/kotlin/androidx/ink/brush/InputToolType#STYLUS()`.
Cmn `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInputBatch#hasOrientation()()`

Whether all of the individual inputs have a defined value for `https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInput#orientationRadians()`.
Cmn `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInputBatch#hasPressure()()`

Whether all of the individual inputs have a defined value for `https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInput#pressure()`.
Cmn `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInputBatch#hasStrokeUnitLength()()`

Whether `https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInput#strokeUnitLengthCm()` has a valid value, which is something other than `https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInput#NO_STROKE_UNIT_LENGTH()`.
Cmn `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInputBatch#hasTilt()()`

Whether all of the individual inputs have a defined value for `https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInput#tiltRadians()`.
Cmn `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInputBatch#isEmpty()()`

`true` if there are no `https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInput` objects in the batch, and `false` otherwise.
Cmn `https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInput` `https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInputBatch#populate(kotlin.Int,androidx.ink.strokes.StrokeInput)(index: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, outStrokeInput: https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInput)`

Gets the value of the i-th input and overwrites `https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInputBatch#populate(kotlin.Int,androidx.ink.strokes.StrokeInput)`, which it then returns.
Cmn

### Inherited properties

From [androidx.ink.strokes.StrokeInputBatch](https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInputBatch) `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` `https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInputBatch#size()`

Number of `https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInput` objects in the batch.
Cmn

## Public constructors

### MutableStrokeInputBatch

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

```
MutableStrokeInputBatch()
```

## Public functions

### add

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

```
fun add(inputBatch: StrokeInputBatch): MutableStrokeInputBatch
```

Validates and appends an `https://developer.android.com/reference/kotlin/androidx/ink/strokes/MutableStrokeInputBatch#add(androidx.ink.strokes.StrokeInputBatch)`. Invalid `https://developer.android.com/reference/kotlin/androidx/ink/strokes/MutableStrokeInputBatch#add(androidx.ink.strokes.StrokeInputBatch)` will result in no change. An exception will be thrown for invalid additions.

### add

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

```
fun add(input: StrokeInput): MutableStrokeInputBatch
```

Adds an `https://developer.android.com/reference/kotlin/androidx/ink/strokes/MutableStrokeInputBatch#add(androidx.ink.strokes.StrokeInput)` to the batch if valid.

Inputs are invalid if they contain values out of the valid range, duplicate a previous input, have an elapsed time before a previous input, or have a different tool type or set different optional fields (pressure, tilt, orientation, or barrel twist) than the inputs already in the batch.

Returns this instance to allow call chaining.

| Parameters |
|---|---|
| `input: https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInput` | The `https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInput` to add to the batch. |

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

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | If the input is not valid. Note that this can be a common occurrence with real user input on certain devices, in particular due to duplicate or out-of-order inputs. Therefore, users should either catch and handle this exception or sanitize the input to avoid ensure validity before passing it to this function. |

### add

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

```
fun add(inputs: Collection<StrokeInput>): MutableStrokeInputBatch
```

Validates and appends a collection of `https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInput`. Invalid `https://developer.android.com/reference/kotlin/androidx/ink/strokes/MutableStrokeInputBatch#add(kotlin.collections.Collection)` will result in no change. An exception will be thrown for invalid additions.

Returns this instance to allow call chaining.

| Parameters |
|---|---|
| `inputs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-collection/index.html<https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInput>` | `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-collection/index.html` of `https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInput`s to add to the batch. |

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

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | If the input is not valid. Note that this can be a common occurrence with real user input on certain devices, in particular due to duplicate or out-of-order inputs. Therefore, users should either catch and handle this exception or sanitize the input to avoid ensure validity before passing it to this function. |

### add

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

```
fun add(
    type: InputToolType,
    x: Float,
    y: Float,
    elapsedTimeMillis: Long,
    strokeUnitLengthCm: Float = StrokeInput.NO_STROKE_UNIT_LENGTH,
    pressure: Float = StrokeInput.NO_PRESSURE,
    tiltRadians: Float = StrokeInput.NO_TILT,
    orientationRadians: Float = StrokeInput.NO_ORIENTATION
): MutableStrokeInputBatch
```

Variant of `https://developer.android.com/reference/kotlin/androidx/ink/strokes/MutableStrokeInputBatch#add(androidx.ink.brush.InputToolType,kotlin.Float,kotlin.Float,kotlin.Long,kotlin.Float,kotlin.Float,kotlin.Float,kotlin.Float)` that takes individual parameters instead of a `https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInput`.

Returns this instance to allow call chaining.

| Parameters |
|---|---|
| `type: https://developer.android.com/reference/kotlin/androidx/ink/brush/InputToolType` | The `https://developer.android.com/reference/kotlin/androidx/ink/brush/InputToolType` to use for the input. |
| `x: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | The x-coordinate of the input position in stroke space. |
| `y: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | The y-coordinate of the input position in stroke space. |
| `elapsedTimeMillis: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | Marks the number of milliseconds since the stroke started. On Android, this should be a non-negative timestamp in the `android.os.SystemClock.elapsedRealtime` time base. |
| `strokeUnitLengthCm: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html = StrokeInput.NO_STROKE_UNIT_LENGTH` | The physical distance in centimeters that the pointer must travel in order to produce an input motion of one stroke unit. For stylus/touch, this is the real-world distance that the stylus/fingertip must move in physical space; for mouse, this is the visual distance that the mouse pointer must travel along the surface of the display. A value of `https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInput#NO_STROKE_UNIT_LENGTH()` indicates that the relationship between stroke space and physical space is unknown or ill-defined. |
| `pressure: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html = StrokeInput.NO_PRESSURE` | Must be within 0, 1 if present. Absence of `https://developer.android.com/reference/kotlin/androidx/ink/strokes/MutableStrokeInputBatch#add(androidx.ink.brush.InputToolType,kotlin.Float,kotlin.Float,kotlin.Long,kotlin.Float,kotlin.Float,kotlin.Float,kotlin.Float)` data is represented with `https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInput#NO_PRESSURE()`. |
| `tiltRadians: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html = StrokeInput.NO_TILT` | Must be within 0, π/2 if present. The angle in radians between a stylus and the line perpendicular to the plane of the screen. 0 is perpendicular to the screen and π/2 is flat against the drawing surface. Absence of `https://developer.android.com/reference/kotlin/androidx/ink/strokes/MutableStrokeInputBatch#add(androidx.ink.brush.InputToolType,kotlin.Float,kotlin.Float,kotlin.Long,kotlin.Float,kotlin.Float,kotlin.Float,kotlin.Float)` data is represented with `https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInput#NO_TILT()`. |
| `orientationRadians: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html = StrokeInput.NO_ORIENTATION` | Must be within 0, 2π if present. Indicates the direction in which the stylus is pointing in relation to the positive x axis in radians. A value of 0 means the ray from the stylus tip to the end is along positive x and values increase towards the positive y-axis. Absence of `https://developer.android.com/reference/kotlin/androidx/ink/strokes/MutableStrokeInputBatch#add(androidx.ink.brush.InputToolType,kotlin.Float,kotlin.Float,kotlin.Long,kotlin.Float,kotlin.Float,kotlin.Float,kotlin.Float)` data is represented with `https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInput#NO_ORIENTATION()`. |

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

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | If the input is not valid. Note that this can be a common occurrence with real user input on certain devices, in particular due to duplicate or out-of-order inputs. Therefore, users should either catch and handle this exception or sanitize the input to avoid ensure validity before passing it to this function. |

### clear

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

```
fun clear(): Unit
```

### setNoiseSeed

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

```
fun setNoiseSeed(seed: Int): Unit
```

Sets the per-stroke seed value that should be used when regenerating a stroke from this input batch.

### toImmutable

Cmn

```
open fun toImmutable(): ImmutableStrokeInputBatch
```

Create `https://developer.android.com/reference/kotlin/androidx/ink/strokes/ImmutableStrokeInputBatch` with the accumulated StrokeInputs.

### toString

Cmn

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