# androidx.ink.strokes

*** ** * ** ***

Common/All

## Interfaces

|---|---|---|
| `https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokePaintAnimationClock` | Controls animated paint textures for rendered strokes. | Cmn |

## Classes

|---|---|---|
| `https://developer.android.com/reference/kotlin/androidx/ink/strokes/ImmutableStrokeInputBatch` | An immutable implementation of `https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInputBatch`. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/ink/strokes/InProgressStroke` | Use an `https://developer.android.com/reference/kotlin/androidx/ink/strokes/InProgressStroke` to efficiently build a stroke over multiple rendering frames with incremental inputs. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/ink/strokes/MutableStrokeInputBatch` | A mutable implementation of `https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInputBatch`. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/ink/strokes/Stroke` | An immutable object comprised of a `https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInputBatch` that represents a user-drawn (or sometimes synthetic) path, a `https://developer.android.com/reference/kotlin/androidx/ink/brush/Brush` that contains information on how that path should be converted into a geometric shape and rendered on screen, and a `https://developer.android.com/reference/kotlin/androidx/ink/geometry/PartitionedMesh` which is the geometric shape calculated from the combination of the `https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInputBatch` and the `https://developer.android.com/reference/kotlin/androidx/ink/brush/Brush`. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/ink/strokes/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()`). | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInputBatch` | A read-only view of an object that stores multiple `https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInput` values together in a more memory-efficient manner than just `List<StrokeInput>`. | Cmn |

## Objects

|---|---|---|
| `https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInputBatch.Companion` |   | Cmn |

## Extension functions summary

|---|---|---|
| `https://developer.android.com/reference/kotlin/androidx/ink/geometry/PartitionedMesh` | `https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInputBatch.https://developer.android.com/reference/kotlin/androidx/ink/strokes/package-summary#(androidx.ink.strokes.StrokeInputBatch).createClosedShape()()` Creates a `https://developer.android.com/reference/kotlin/androidx/ink/geometry/PartitionedMesh` of the shape enclosed by the given `https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInputBatch` input points. | Cmn |

## Extension functions

### StrokeInputBatch.createClosedShape

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

```
fun StrokeInputBatch.createClosedShape(): PartitionedMesh
```

Creates a `https://developer.android.com/reference/kotlin/androidx/ink/geometry/PartitionedMesh` of the shape enclosed by the given `https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInputBatch` input points. A typical use case is selecting a region of the scene and performing hit testing with the resulting `https://developer.android.com/reference/kotlin/androidx/ink/geometry/PartitionedMesh`.

For a given stroke this algorithm aims to:

1. Identify and create any connections that the user may have intended to make but did not fully connect.

2. Trim any extra end points that the user did not intend to be part of the selected area.

Example usage:

```kotlin
fun onStrokeFinished(stroke: Stroke) {
   val selectionRegion = stroke.inputs.createClosedShape()
   for (stroke in myScene.strokes) {
       if (stroke.shape.intersects(selectionRegion)) {
           myScene.setSelected(stroke, true)
       }
   }
}
```

| Parameters |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInputBatch` | The `https://developer.android.com/reference/kotlin/androidx/ink/strokes/StrokeInputBatch` to create a closed shape from. |

| Returns |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/ink/geometry/PartitionedMesh` | The `https://developer.android.com/reference/kotlin/androidx/ink/geometry/PartitionedMesh` of the closed shape. If there are fewer than 3 input points, or if there are fewer than 3 points remaining after removing points with the same (x,y) coordinates as the previous point, this function will return a `https://developer.android.com/reference/kotlin/androidx/ink/geometry/PartitionedMesh` that is point-like (1 point remaining) or segment-like (2 points remaining). The resulting mesh will have an area of 0 but can still be used for hit testing via intersection. |