# ShapeWorkflow

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

*** ** * ** ***


```
@ExperimentalInkCustomShapeWorkflowApi
interface ShapeWorkflow<ShapeSpecT : Any, InProgressShapeT : InProgressShape<ShapeSpecT, CompletedShapeT>, CompletedShapeT : Any>
```

<br />

*** ** * ** ***

An interface that can be implemented to provide custom inking functionality which replaces or augments the standard Jetpack Ink behavior. Providing an implementation of this is an advanced feature that isn't recommended for most apps - most use cases should prefer to use `https://developer.android.com/reference/kotlin/androidx/ink/brush/StockBrushes`, or perhaps create a custom brush with `https://developer.android.com/reference/kotlin/androidx/ink/storage/BrushFamilySerialization#decode(java.io.InputStream,androidx.ink.brush.Version,androidx.ink.storage.OnDecodeTexturePngBytes)`. But if those don't satisfy the need for fully custom programmatic geometry of stroke-like objects based on pointer input data, this interface can be implemented to control that, but in a way that can still take advantage of Ink's low latency drawing capabilities without needing to implement that from scratch.

The primary purpose of this object is to manage the recycling lifecycle of `https://developer.android.com/reference/kotlin/androidx/ink/authoring/InProgressShape` instances. A new instance will only be requested via `https://developer.android.com/reference/kotlin/androidx/ink/authoring/ShapeWorkflow#create(kotlin.Int)` when the internal recycling logic determines it's necessary, and most of the time it will reuse existing recycled instances via `https://developer.android.com/reference/kotlin/androidx/ink/authoring/InProgressShape#start(kotlin.Any,kotlin.Long)`.

| Parameters |
|---|---|
| `<ShapeSpecT : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html>` | A styling specification type, typically pure declarative data, that indicates how pointer inputs are turned into geometry and rendered pixels. A standard, pure Ink implementation would use `https://developer.android.com/reference/kotlin/androidx/ink/brush/Brush` for this. |
| `<InProgressShapeT : https://developer.android.com/reference/kotlin/androidx/ink/authoring/InProgressShape<ShapeSpecT, CompletedShapeT>>` | A specific type of `https://developer.android.com/reference/kotlin/androidx/ink/authoring/InProgressShape` that includes the logic for how a `https://developer.android.com/reference/kotlin/androidx/ink/authoring/ShapeWorkflow` and incrementally added pointer events are turned into geometry and rendered pixels. A standard, pure Ink implementation would be based on `https://developer.android.com/reference/kotlin/androidx/ink/strokes/InProgressStroke`. |
| `<CompletedShapeT : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html>` | A type that represents the end result of an `https://developer.android.com/reference/kotlin/androidx/ink/authoring/ShapeWorkflow`, after all inputs have been delivered to it and it has been fully processed. This is often different from an `https://developer.android.com/reference/kotlin/androidx/ink/authoring/ShapeWorkflow` as it can be immutable, and may therefore represent its underlying data in a more optimized form. A standard, pure Ink implementation would use `https://developer.android.com/reference/kotlin/androidx/ink/strokes/Stroke` for this. |

## Summary

| ### Public functions |
|---|---|
| `InProgressShapeT` | `@https://developer.android.com/reference/kotlin/androidx/annotation/WorkerThread https://developer.android.com/reference/kotlin/androidx/ink/authoring/ShapeWorkflow#create(kotlin.Int)(shapeType: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Called when a new `https://developer.android.com/reference/kotlin/androidx/ink/authoring/InProgressShape` is needed for the given `https://developer.android.com/reference/kotlin/androidx/ink/authoring/ShapeWorkflow#create(kotlin.Int)` to represent a shape. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/WorkerThread https://developer.android.com/reference/kotlin/androidx/ink/authoring/ShapeWorkflow#getShapeType(kotlin.Any)(shapeSpec: ShapeSpecT)` Return the shape type of an item being drawn with the given `https://developer.android.com/reference/kotlin/androidx/ink/authoring/ShapeWorkflow` for the purposes of recycling the `https://developer.android.com/reference/kotlin/androidx/ink/authoring/ShapeWorkflow` instances. |

| ### Public properties |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/ink/authoring/CompletedShapeRenderer<CompletedShapeT>` | `https://developer.android.com/reference/kotlin/androidx/ink/authoring/ShapeWorkflow#completedShapeRenderer()` An object that is called to render a `https://developer.android.com/reference/kotlin/androidx/ink/authoring/ShapeWorkflow` instance to an `https://developer.android.com/reference/android/graphics/Canvas.html`. |
| `https://developer.android.com/reference/kotlin/androidx/ink/authoring/InProgressShapeRenderer<InProgressShapeT>` | `https://developer.android.com/reference/kotlin/androidx/ink/authoring/ShapeWorkflow#inProgressShapeRenderer()` An object that is called to render an `https://developer.android.com/reference/kotlin/androidx/ink/authoring/ShapeWorkflow` instance to an `https://developer.android.com/reference/android/graphics/Canvas.html`. |

## Public functions

### create

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

```
@WorkerThread
fun create(shapeType: Int): InProgressShapeT
```

Called when a new `https://developer.android.com/reference/kotlin/androidx/ink/authoring/InProgressShape` is needed for the given `https://developer.android.com/reference/kotlin/androidx/ink/authoring/ShapeWorkflow#create(kotlin.Int)` to represent a shape.

The new `https://developer.android.com/reference/kotlin/androidx/ink/authoring/InProgressShape` will be used to represent a particular in-progress drawn object using `https://developer.android.com/reference/kotlin/androidx/ink/authoring/InProgressShape#start(kotlin.Any,kotlin.Long)`. Since this object will be reused more than once, it is a good idea to do more expensive initialization once in this function at creation time to avoid unnecessary work in `https://developer.android.com/reference/kotlin/androidx/ink/authoring/InProgressShape#start(kotlin.Any,kotlin.Long)` and the functions that are called at a high frequency in `https://developer.android.com/reference/kotlin/androidx/ink/authoring/InProgressShape` like `https://developer.android.com/reference/kotlin/androidx/ink/authoring/InProgressShape#enqueueInputs(androidx.ink.strokes.StrokeInputBatch,androidx.ink.strokes.StrokeInputBatch)` and `https://developer.android.com/reference/kotlin/androidx/ink/authoring/InProgressShape#update(kotlin.Long)`.

### getShapeType

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

```
@WorkerThread
fun getShapeType(shapeSpec: ShapeSpecT): Int
```

Return the shape type of an item being drawn with the given `https://developer.android.com/reference/kotlin/androidx/ink/authoring/ShapeWorkflow` for the purposes of recycling the `https://developer.android.com/reference/kotlin/androidx/ink/authoring/ShapeWorkflow` instances. The simplest implementation of this can use a single shape type, but multiple shape types are supported. The returned integer value serves as a unique identifier - there are no limits on its value, and the numeric value of one type compared to another is meaningless beyond the fact that they are distinct.

## Public properties

### completedShapeRenderer

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

```
val completedShapeRenderer: CompletedShapeRenderer<CompletedShapeT>
```

An object that is called to render a `https://developer.android.com/reference/kotlin/androidx/ink/authoring/ShapeWorkflow` instance to an `https://developer.android.com/reference/android/graphics/Canvas.html`. A standard, pure Ink implementation would be based on `https://developer.android.com/reference/kotlin/androidx/ink/rendering/android/canvas/CanvasStrokeRenderer`.

### inProgressShapeRenderer

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

```
val inProgressShapeRenderer: InProgressShapeRenderer<InProgressShapeT>
```

An object that is called to render an `https://developer.android.com/reference/kotlin/androidx/ink/authoring/ShapeWorkflow` instance to an `https://developer.android.com/reference/android/graphics/Canvas.html`. A standard, pure Ink implementation would be based on `https://developer.android.com/reference/kotlin/androidx/ink/rendering/android/canvas/CanvasStrokeRenderer`.