# 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
public interface ShapeWorkflow<ShapeSpecT extends Object, InProgressShapeT extends InProgressShape<@NonNull ShapeSpecT, @NonNull CompletedShapeT>, CompletedShapeT extends Object>
```

<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/androidx/ink/brush/StockBrushes`, or perhaps create a custom brush with `https://developer.android.com/reference/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/androidx/ink/authoring/InProgressShape` instances. A new instance will only be requested via `https://developer.android.com/reference/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/androidx/ink/authoring/InProgressShape#start(kotlin.Any,kotlin.Long)`.

| Parameters |
|---|---|
| `<ShapeSpecT extends https://developer.android.com/reference/java/lang/Object.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/androidx/ink/brush/Brush` for this. |
| `<InProgressShapeT extends https://developer.android.com/reference/androidx/ink/authoring/InProgressShape<@https://developer.android.com/reference/androidx/annotation/NonNull ShapeSpecT, @https://developer.android.com/reference/androidx/annotation/NonNull CompletedShapeT>>` | A specific type of `https://developer.android.com/reference/androidx/ink/authoring/InProgressShape` that includes the logic for how a `https://developer.android.com/reference/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/androidx/ink/strokes/InProgressStroke`. |
| `<CompletedShapeT extends https://developer.android.com/reference/java/lang/Object.html>` | A type that represents the end result of an `https://developer.android.com/reference/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/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/androidx/ink/strokes/Stroke` for this. |

## Summary

| ### Public methods |
|---|---|
| `abstract @https://developer.android.com/reference/androidx/annotation/NonNull InProgressShapeT` | `@https://developer.android.com/reference/androidx/annotation/WorkerThread https://developer.android.com/reference/androidx/ink/authoring/ShapeWorkflow#create(kotlin.Int)(int shapeType)` Called when a new `https://developer.android.com/reference/androidx/ink/authoring/InProgressShape` is needed for the given `https://developer.android.com/reference/androidx/ink/authoring/ShapeWorkflow#create(kotlin.Int)` to represent a shape. |
| `abstract @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/authoring/CompletedShapeRenderer<@https://developer.android.com/reference/androidx/annotation/NonNull CompletedShapeT>` | `@https://developer.android.com/reference/androidx/annotation/UiThread https://developer.android.com/reference/androidx/ink/authoring/ShapeWorkflow#getCompletedShapeRenderer()()` An object that is called to render a `https://developer.android.com/reference/androidx/ink/authoring/ShapeWorkflow` instance to an `https://developer.android.com/reference/android/graphics/Canvas.html`. |
| `abstract @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/ink/authoring/InProgressShapeRenderer<@https://developer.android.com/reference/androidx/annotation/NonNull InProgressShapeT>` | `@https://developer.android.com/reference/androidx/annotation/WorkerThread https://developer.android.com/reference/androidx/ink/authoring/ShapeWorkflow#getInProgressShapeRenderer()()` An object that is called to render an `https://developer.android.com/reference/androidx/ink/authoring/ShapeWorkflow` instance to an `https://developer.android.com/reference/android/graphics/Canvas.html`. |
| `abstract int` | `@https://developer.android.com/reference/androidx/annotation/WorkerThread https://developer.android.com/reference/androidx/ink/authoring/ShapeWorkflow#getShapeType(kotlin.Any)(@https://developer.android.com/reference/androidx/annotation/NonNull ShapeSpecT shapeSpec)` Return the shape type of an item being drawn with the given `https://developer.android.com/reference/androidx/ink/authoring/ShapeWorkflow` for the purposes of recycling the `https://developer.android.com/reference/androidx/ink/authoring/ShapeWorkflow` instances. |

## Public methods

### create

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

```
@WorkerThread
abstract @NonNull InProgressShapeT create(int shapeType)
```

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

The new `https://developer.android.com/reference/androidx/ink/authoring/InProgressShape` will be used to represent a particular in-progress drawn object using `https://developer.android.com/reference/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/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/androidx/ink/authoring/InProgressShape` like `https://developer.android.com/reference/androidx/ink/authoring/InProgressShape#enqueueInputs(androidx.ink.strokes.StrokeInputBatch,androidx.ink.strokes.StrokeInputBatch)` and `https://developer.android.com/reference/androidx/ink/authoring/InProgressShape#update(kotlin.Long)`.

### getCompletedShapeRenderer

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

```
@UiThread
abstract @NonNull CompletedShapeRenderer<@NonNull CompletedShapeT> getCompletedShapeRenderer()
```

An object that is called to render a `https://developer.android.com/reference/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/androidx/ink/rendering/android/canvas/CanvasStrokeRenderer`.

### getInProgressShapeRenderer

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

```
@WorkerThread
abstract @NonNull InProgressShapeRenderer<@NonNull InProgressShapeT> getInProgressShapeRenderer()
```

An object that is called to render an `https://developer.android.com/reference/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/androidx/ink/rendering/android/canvas/CanvasStrokeRenderer`.

### getShapeType

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

```
@WorkerThread
abstract int getShapeType(@NonNull ShapeSpecT shapeSpec)
```

Return the shape type of an item being drawn with the given `https://developer.android.com/reference/androidx/ink/authoring/ShapeWorkflow` for the purposes of recycling the `https://developer.android.com/reference/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.