# CanvasComplication

Artifact: [androidx.wear.watchface:watchface](https://developer.android.com/jetpack/androidx/releases/wear-watchface) [View Source](https://cs.android.com/search?q=file:androidx/wear/watchface/ComplicationSlot.kt+class:androidx.wear.watchface.CanvasComplication) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/wear-watchface#1.0.0) Deprecated in [1.3.0-alpha07](https://developer.android.com/jetpack/androidx/releases/wear-watchface#1.3.0-alpha07)

*** ** * ** ***


```
interface CanvasComplication
```

<br />

Known direct subclasses [CanvasComplicationDrawable](https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/rendering/CanvasComplicationDrawable)

|---|---|
| `https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/rendering/CanvasComplicationDrawable` | **This class is deprecated.** AndroidX watchface libraries are deprecated, use Watch Face Format instead. |

*** ** * ** ***

> [!CAUTION]
> **This interface is deprecated.**   
> AndroidX watchface libraries are deprecated, use Watch Face Format instead. For more info see: https://developer.android.com/training/wearables/wff

Interface for rendering complicationSlots onto a `https://developer.android.com/reference/android/graphics/Canvas.html`. These should be created by `https://developer.android.com/reference/kotlin/androidx/wear/watchface/CanvasComplicationFactory#create(androidx.wear.watchface.WatchState,androidx.wear.watchface.CanvasComplication.InvalidateCallback)`. If state needs to be shared with the `https://developer.android.com/reference/kotlin/androidx/wear/watchface/Renderer` that should be set up inside `https://developer.android.com/reference/kotlin/androidx/wear/watchface/CanvasComplication#onRendererCreated(androidx.wear.watchface.Renderer)`.

use Watch Face Format instead

## Summary

| ### Nested types |
|---|
| `interface https://developer.android.com/reference/kotlin/androidx/wear/watchface/CanvasComplication.InvalidateCallback` **This interface is deprecated.** AndroidX watchface libraries are deprecated, use Watch Face Format instead. |

| ### Public functions |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `[drawHighlight](https://developer.android.com/reference/kotlin/androidx/wear/watchface/CanvasComplication#drawHighlight(android.graphics.Canvas,android.graphics.Rect,kotlin.Int,java.time.ZonedDateTime,kotlin.Int))( canvas: https://developer.android.com/reference/android/graphics/Canvas.html, bounds: https://developer.android.com/reference/android/graphics/Rect.html, boundsType: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, zonedDateTime: https://developer.android.com/reference/java/time/ZonedDateTime.html, color: @https://developer.android.com/reference/kotlin/androidx/annotation/ColorInt https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html )` **This function is deprecated.** AndroidX watchface libraries are deprecated, use Watch Face Format instead. |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/ComplicationExperimental [drawHighlight](https://developer.android.com/reference/kotlin/androidx/wear/watchface/CanvasComplication#drawHighlight(android.graphics.Canvas,android.graphics.Rect,kotlin.Int,java.time.ZonedDateTime,kotlin.Int,androidx.wear.watchface.BoundingArc))( canvas: https://developer.android.com/reference/android/graphics/Canvas.html, bounds: https://developer.android.com/reference/android/graphics/Rect.html, boundsType: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, zonedDateTime: https://developer.android.com/reference/java/time/ZonedDateTime.html, color: @https://developer.android.com/reference/kotlin/androidx/annotation/ColorInt https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, boundingArc: https://developer.android.com/reference/kotlin/androidx/wear/watchface/BoundingArc? )` **This function is deprecated.** AndroidX watchface libraries are deprecated, use Watch Face Format instead. |
| `https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/ComplicationData` | `[getData](https://developer.android.com/reference/kotlin/androidx/wear/watchface/CanvasComplication#getData())()` **This function is deprecated.** AndroidX watchface libraries are deprecated, use Watch Face Format instead. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `[loadData](https://developer.android.com/reference/kotlin/androidx/wear/watchface/CanvasComplication#loadData(androidx.wear.watchface.complications.data.ComplicationData,kotlin.Boolean))( complicationData: https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/ComplicationData, loadDrawablesAsynchronous: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html )` **This function is deprecated.** AndroidX watchface libraries are deprecated, use Watch Face Format instead. |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/WorkerThread [onRendererCreated](https://developer.android.com/reference/kotlin/androidx/wear/watchface/CanvasComplication#onRendererCreated(androidx.wear.watchface.Renderer))(renderer: https://developer.android.com/reference/kotlin/androidx/wear/watchface/Renderer)` **This function is deprecated.** AndroidX watchface libraries are deprecated, use Watch Face Format instead. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `@https://developer.android.com/reference/kotlin/androidx/annotation/UiThread [render](https://developer.android.com/reference/kotlin/androidx/wear/watchface/CanvasComplication#render(android.graphics.Canvas,android.graphics.Rect,java.time.ZonedDateTime,androidx.wear.watchface.RenderParameters,kotlin.Int))( canvas: https://developer.android.com/reference/android/graphics/Canvas.html, bounds: https://developer.android.com/reference/android/graphics/Rect.html, zonedDateTime: https://developer.android.com/reference/java/time/ZonedDateTime.html, renderParameters: https://developer.android.com/reference/kotlin/androidx/wear/watchface/RenderParameters, slotId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html )` **This function is deprecated.** AndroidX watchface libraries are deprecated, use Watch Face Format instead. |

## Public functions

### drawHighlight

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/wear-watchface#1.0.0) Deprecated in [1.3.0-alpha07](https://developer.android.com/jetpack/androidx/releases/wear-watchface#1.3.0-alpha07)

```
fun [drawHighlight](https://developer.android.com/reference/kotlin/androidx/wear/watchface/CanvasComplication#drawHighlight(android.graphics.Canvas,android.graphics.Rect,kotlin.Int,java.time.ZonedDateTime,kotlin.Int))(
    canvas: Canvas,
    bounds: Rect,
    boundsType: Int,
    zonedDateTime: ZonedDateTime,
    color: @ColorInt Int
): Unit
```

> [!CAUTION]
> **This function is deprecated.**   
> AndroidX watchface libraries are deprecated, use Watch Face Format instead. For more info see: https://developer.android.com/training/wearables/wff

Draws a highlight for a `https://developer.android.com/reference/kotlin/androidx/wear/watchface/ComplicationSlotBoundsType#ROUND_RECT()` complication. The default implementation does this by drawing a dashed line around the complication, other visual effects may be used if desired.

| Parameters |
|---|---|
| `canvas: https://developer.android.com/reference/android/graphics/Canvas.html` | The `https://developer.android.com/reference/android/graphics/Canvas.html` to render into |
| `bounds: https://developer.android.com/reference/android/graphics/Rect.html` | A `https://developer.android.com/reference/android/graphics/Rect.html` describing the bounds of the complication |
| `boundsType: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The `https://developer.android.com/reference/kotlin/androidx/wear/watchface/ComplicationSlotBoundsTypeIntDef` of the complication Value is one of the following: - `0` - `1` - `2` <br /> |
| `zonedDateTime: https://developer.android.com/reference/java/time/ZonedDateTime.html` | The `https://developer.android.com/reference/java/time/ZonedDateTime.html` to render the highlight with |
| `color: @https://developer.android.com/reference/kotlin/androidx/annotation/ColorInt https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The color to render the highlight with |

### drawHighlight

Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/wear-watchface#1.2.0) Deprecated in [1.3.0-alpha07](https://developer.android.com/jetpack/androidx/releases/wear-watchface#1.3.0-alpha07)

```
@ComplicationExperimental
open fun [drawHighlight](https://developer.android.com/reference/kotlin/androidx/wear/watchface/CanvasComplication#drawHighlight(android.graphics.Canvas,android.graphics.Rect,kotlin.Int,java.time.ZonedDateTime,kotlin.Int,androidx.wear.watchface.BoundingArc))(
    canvas: Canvas,
    bounds: Rect,
    boundsType: Int,
    zonedDateTime: ZonedDateTime,
    color: @ColorInt Int,
    boundingArc: BoundingArc?
): Unit
```

> [!CAUTION]
> **This function is deprecated.**   
> AndroidX watchface libraries are deprecated, use Watch Face Format instead. For more info see: https://developer.android.com/training/wearables/wff

Draws a highlight for a `https://developer.android.com/reference/kotlin/androidx/wear/watchface/ComplicationSlotBoundsType#ROUND_RECT()` complication. The default implementation does this by drawing a dashed line around the complication, other visual effects may be used if desired.

| Parameters |
|---|---|
| `canvas: https://developer.android.com/reference/android/graphics/Canvas.html` | The `https://developer.android.com/reference/android/graphics/Canvas.html` to render into |
| `bounds: https://developer.android.com/reference/android/graphics/Rect.html` | A `https://developer.android.com/reference/android/graphics/Rect.html` describing the bounds of the complication |
| `boundsType: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The `https://developer.android.com/reference/kotlin/androidx/wear/watchface/ComplicationSlotBoundsTypeIntDef` of the complication Value is one of the following: - `0` - `1` - `2` <br /> |
| `zonedDateTime: https://developer.android.com/reference/java/time/ZonedDateTime.html` | The `https://developer.android.com/reference/java/time/ZonedDateTime.html` to render the highlight with |
| `color: @https://developer.android.com/reference/kotlin/androidx/annotation/ColorInt https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The color to render the highlight with |
| `boundingArc: https://developer.android.com/reference/kotlin/androidx/wear/watchface/BoundingArc?` | Optional `https://developer.android.com/reference/kotlin/androidx/wear/watchface/BoundingArc` defining the geometry of an edge complication |

### getData

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/wear-watchface#1.0.0) Deprecated in [1.3.0-alpha07](https://developer.android.com/jetpack/androidx/releases/wear-watchface#1.3.0-alpha07)

```
fun [getData](https://developer.android.com/reference/kotlin/androidx/wear/watchface/CanvasComplication#getData())(): ComplicationData
```

> [!CAUTION]
> **This function is deprecated.**   
> AndroidX watchface libraries are deprecated, use Watch Face Format instead. For more info see: https://developer.android.com/training/wearables/wff

Returns the `https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/ComplicationData` to render with.

### loadData

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/wear-watchface#1.0.0) Deprecated in [1.3.0-alpha07](https://developer.android.com/jetpack/androidx/releases/wear-watchface#1.3.0-alpha07)

```
fun [loadData](https://developer.android.com/reference/kotlin/androidx/wear/watchface/CanvasComplication#loadData(androidx.wear.watchface.complications.data.ComplicationData,kotlin.Boolean))(
    complicationData: ComplicationData,
    loadDrawablesAsynchronous: Boolean
): Unit
```

> [!CAUTION]
> **This function is deprecated.**   
> AndroidX watchface libraries are deprecated, use Watch Face Format instead. For more info see: https://developer.android.com/training/wearables/wff

Sets the `https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/ComplicationData` to render with and loads any `https://developer.android.com/reference/android/graphics/drawable/Drawable.html`s contained within the ComplicationData. You can choose whether this is done synchronously or asynchronously via `https://developer.android.com/reference/kotlin/androidx/wear/watchface/CanvasComplication#loadData(androidx.wear.watchface.complications.data.ComplicationData,kotlin.Boolean)`. When any asynchronous loading has completed `https://developer.android.com/reference/kotlin/androidx/wear/watchface/CanvasComplication.InvalidateCallback#onInvalidate()` must be called.

| Parameters |
|---|---|
| `complicationData: https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/ComplicationData` | The `https://developer.android.com/reference/kotlin/androidx/wear/watchface/complications/data/ComplicationData` to render with |
| `loadDrawablesAsynchronous: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | Whether or not any drawables should be loaded asynchronously |

### onRendererCreated

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/wear-watchface#1.0.0) Deprecated in [1.3.0-alpha07](https://developer.android.com/jetpack/androidx/releases/wear-watchface#1.3.0-alpha07)

```
@WorkerThread
open fun [onRendererCreated](https://developer.android.com/reference/kotlin/androidx/wear/watchface/CanvasComplication#onRendererCreated(androidx.wear.watchface.Renderer))(renderer: Renderer): Unit
```

> [!CAUTION]
> **This function is deprecated.**   
> AndroidX watchface libraries are deprecated, use Watch Face Format instead. For more info see: https://developer.android.com/training/wearables/wff

Called once on a background thread before any subsequent UI thread rendering to inform the CanvasComplication of the `https://developer.android.com/reference/kotlin/androidx/wear/watchface/Renderer` which is useful if they need to share state. Note the `https://developer.android.com/reference/kotlin/androidx/wear/watchface/Renderer` is created asynchronously which is why we can't pass it in via `https://developer.android.com/reference/kotlin/androidx/wear/watchface/CanvasComplicationFactory#create(androidx.wear.watchface.WatchState,androidx.wear.watchface.CanvasComplication.InvalidateCallback)` as it may not be available at that time.

### render

Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/wear-watchface#1.0.0) Deprecated in [1.3.0-alpha07](https://developer.android.com/jetpack/androidx/releases/wear-watchface#1.3.0-alpha07)

```
@UiThread
fun [render](https://developer.android.com/reference/kotlin/androidx/wear/watchface/CanvasComplication#render(android.graphics.Canvas,android.graphics.Rect,java.time.ZonedDateTime,androidx.wear.watchface.RenderParameters,kotlin.Int))(
    canvas: Canvas,
    bounds: Rect,
    zonedDateTime: ZonedDateTime,
    renderParameters: RenderParameters,
    slotId: Int
): Unit
```

> [!CAUTION]
> **This function is deprecated.**   
> AndroidX watchface libraries are deprecated, use Watch Face Format instead. For more info see: https://developer.android.com/training/wearables/wff

Draws the complication defined by `https://developer.android.com/reference/kotlin/androidx/wear/watchface/CanvasComplication#getData()` into the canvas with the specified bounds. This will usually be called by user watch face drawing code, but the system may also call it for complication selection UI rendering. The width and height will be the same as that computed by computeBounds but the translation and canvas size may differ.

| Parameters |
|---|---|
| `canvas: https://developer.android.com/reference/android/graphics/Canvas.html` | The `https://developer.android.com/reference/android/graphics/Canvas.html` to render into |
| `bounds: https://developer.android.com/reference/android/graphics/Rect.html` | A `https://developer.android.com/reference/android/graphics/Rect.html` describing the bounds of the complication |
| `zonedDateTime: https://developer.android.com/reference/java/time/ZonedDateTime.html` | The `https://developer.android.com/reference/java/time/ZonedDateTime.html` to render with |
| `renderParameters: https://developer.android.com/reference/kotlin/androidx/wear/watchface/RenderParameters` | The current `https://developer.android.com/reference/kotlin/androidx/wear/watchface/RenderParameters` |
| `slotId: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The Id of the `https://developer.android.com/reference/kotlin/androidx/wear/watchface/ComplicationSlot` being rendered |