# StrokeInput

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

*** ** * ** ***

Common/All
- Cmn

  ```
  class StrokeInput
  ```

*** ** * ** ***

A single input specifying position, time since the start of the stream, and optionally `https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInput#pressure()`, `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()`).

This data type is used as an input to `https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInputBatch` and `https://developer.android.com/reference/kotlin/androidx/ink/strokes/InProgressStroke`. If these are to be created as part of real-time input, it is recommended to use some sort of object pool so that new usages can make use of existing objects that have been recycled, rather than allocating new ones which could introduce unpredictable garbage collection related delays to the time-sensitive input path. This class has the `https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInput#update(kotlin.Float,kotlin.Float,kotlin.Long,androidx.ink.brush.InputToolType,kotlin.Float,kotlin.Float,kotlin.Float,kotlin.Float)` method for that purpose, rather than being immutable.

## Summary

| ### Constants |
|---|---|---|
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | `https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInput#NO_ORIENTATION()` | Cmn |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | `https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInput#NO_PRESSURE()` | Cmn |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | `https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInput#NO_STROKE_UNIT_LENGTH() = 0.0f` | Cmn |
| `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | `https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInput#NO_TILT()` | Cmn |

| ### Public companion functions |
|---|---|---|
| `https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInput` | `@https://developer.android.com/reference/kotlin/androidx/annotation/VisibleForTesting https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInput#create(kotlin.Float,kotlin.Float,kotlin.Long,androidx.ink.brush.InputToolType,kotlin.Float,kotlin.Float,kotlin.Float,kotlin.Float)( 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://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, toolType: https://developer.android.com/reference/kotlin/androidx/ink/brush/InputToolType, 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 )` Allocate and return a new `https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInput`. | Cmn |

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

| ### Public functions |
|---|---|---|
| `open operator https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInput#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/strokes/StrokeInput#hashCode()()` | Cmn |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInput#toString()()` | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInput#update(kotlin.Float,kotlin.Float,kotlin.Long,androidx.ink.brush.InputToolType,kotlin.Float,kotlin.Float,kotlin.Float,kotlin.Float)( 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://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html, toolType: https://developer.android.com/reference/kotlin/androidx/ink/brush/InputToolType, 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 )` Set new values on this instance, clearing values corresponding to optional parameters that are not specified. | Cmn |

| ### Public properties |
|---|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | `https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInput#elapsedTimeMillis()` Time elapsed since the start of the stroke. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInput#hasOrientation()` Whether the `https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInput#orientationRadians()` field contains a valid orientation value. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInput#hasPressure()` Whether the `https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInput#pressure()` field contains a valid pressure value. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInput#hasTilt()` Whether the `https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInput#tiltRadians()` field contains a valid tilt value. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | `https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInput#orientationRadians()` The angle that indicates the direction in which the stylus is pointing in relation to the positive x axis. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | `https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInput#pressure()` Pressure value in the normalized, unitless range of 0, 1 indicating the force exerted during input. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | `https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInput#strokeUnitLengthCm()` The physical distance in centimeters that the pointer must travel in order to produce an input motion of one stroke unit. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | `https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInput#tiltRadians()` The angle between a stylus and the line perpendicular to the plane of the screen. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/ink/brush/InputToolType` | `https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInput#toolType()` The input device used to generate this stroke input. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | `https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInput#x()` The x-coordinate of the input position in stroke space. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | `https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInput#y()` The y-coordinate of the input position in stroke space. | Cmn |

## Constants

### NO_ORIENTATION

Cmn

```
const val NO_ORIENTATION: Float
```

### NO_PRESSURE

Cmn

```
const val NO_PRESSURE: Float
```

### NO_STROKE_UNIT_LENGTH

Cmn

```
const val NO_STROKE_UNIT_LENGTH = 0.0f: Float
```

### NO_TILT

Cmn

```
const val NO_TILT: Float
```

## Public companion functions

### create

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

```
@VisibleForTesting
fun create(
    x: Float,
    y: Float,
    elapsedTimeMillis: @IntRange(from = 0) Long,
    toolType: InputToolType = InputToolType.UNKNOWN,
    strokeUnitLengthCm: Float = NO_STROKE_UNIT_LENGTH,
    pressure: Float = NO_PRESSURE,
    tiltRadians: Float = NO_TILT,
    orientationRadians: Float = NO_ORIENTATION
): StrokeInput
```

Allocate and return a new `https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInput`. Only intended for test code - real code should use a recycling pattern to avoid allocating during latency-sensitive real-time input, using `https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInput#update(kotlin.Float,kotlin.Float,kotlin.Long,androidx.ink.brush.InputToolType,kotlin.Float,kotlin.Float,kotlin.Float,kotlin.Float)` on an instance allocated with the zero-argument constructor.

## Public constructors

### StrokeInput

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

```
StrokeInput()
```

## Public functions

### equals

Cmn

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

### hashCode

Cmn

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

### toString

Cmn

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

### update

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

```
fun update(
    x: Float,
    y: Float,
    elapsedTimeMillis: @IntRange(from = 0) Long,
    toolType: InputToolType = InputToolType.UNKNOWN,
    strokeUnitLengthCm: Float = NO_STROKE_UNIT_LENGTH,
    pressure: Float = NO_PRESSURE,
    tiltRadians: Float = NO_TILT,
    orientationRadians: Float = NO_ORIENTATION
): Unit
```

Set new values on this instance, clearing values corresponding to optional parameters that are not specified.

| Parameters |
|---|---|
| `x: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | The `x` position coordinate of the input in the stroke's coordinate space. |
| `y: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | The `y` position coordinate of the input in the stroke's coordinate space. |
| `elapsedTimeMillis: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0) 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. |
| `toolType: https://developer.android.com/reference/kotlin/androidx/ink/brush/InputToolType = InputToolType.UNKNOWN` | The type of tool used to create this input data. |
| `strokeUnitLengthCm: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html = 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 = NO_PRESSURE` | Must be within 0, 1, though that's not enforced until added to a `https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInputBatch` object. Absence of `https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInput#update(kotlin.Float,kotlin.Float,kotlin.Long,androidx.ink.brush.InputToolType,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 = NO_TILT` | Must be within 0, π/2, though that's not enforced until added to a `https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInputBatch` object. 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/StrokeInput#update(kotlin.Float,kotlin.Float,kotlin.Long,androidx.ink.brush.InputToolType,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 = NO_ORIENTATION` | Must be within 0, 2π, though that's not enforced until added to a `https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInputBatch` object. 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/StrokeInput#update(kotlin.Float,kotlin.Float,kotlin.Long,androidx.ink.brush.InputToolType,kotlin.Float,kotlin.Float,kotlin.Float,kotlin.Float)` data is represented with `https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInput#NO_ORIENTATION()`. |

## Public properties

### elapsedTimeMillis

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

```
val elapsedTimeMillis: Long
```

Time elapsed since the start of the stroke.

### hasOrientation

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

```
val hasOrientation: Boolean
```

Whether the `https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInput#orientationRadians()` field contains a valid orientation value.

### hasPressure

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

```
val hasPressure: Boolean
```

Whether the `https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInput#pressure()` field contains a valid pressure value.

### hasTilt

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

```
val hasTilt: Boolean
```

Whether the `https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInput#tiltRadians()` field contains a valid tilt value.

### orientationRadians

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

```
val orientationRadians: Float
```

The angle that indicates the direction in which the stylus is pointing in relation to the positive x axis. The value should be normalized to fall between 0 and 2π in radians, where 0 means the ray from the stylus tip to the end is along positive x and values increase towards the positive y-axis.

When `https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInput#tiltRadians()` is equal to π/2, the value for `https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInput#orientationRadians()` is indeterminant.

`https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInput#NO_ORIENTATION()` indicates that orientation is not reported, which can be checked with `https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInput#hasOrientation()`. Note, that this is a separate condition from the orientation being indeterminant when `https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInput#tiltRadians()` is 0.

### pressure

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

```
val pressure: Float
```

Pressure value in the normalized, unitless range of 0, 1 indicating the force exerted during input.

A value of `https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInput#NO_PRESSURE()` indicates that pressure is not reported, which can be checked with `https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInput#hasPressure()`.

### strokeUnitLengthCm

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

```
val strokeUnitLengthCm: Float
```

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.

### tiltRadians

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

```
val tiltRadians: Float
```

The angle between a stylus and the line perpendicular to the plane of the screen. The value should be normalized to fall between 0 and π/2 in radians, where 0 is perpendicular to the screen and π/2 is flat against the drawing surface.

`https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInput#NO_TILT()` indicates that tilt is not reported, which can be checked with `https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInput#hasTilt()`.

### toolType

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

```
val toolType: InputToolType
```

The input device used to generate this stroke input.

### x

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

```
val x: Float
```

The x-coordinate of the input position in stroke space.

### y

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

```
val y: Float
```

The y-coordinate of the input position in stroke space.