# 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)

*** ** * ** ***


```
public interface CanvasComplication
```

<br />

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

|---|---|
| `https://developer.android.com/reference/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/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/androidx/wear/watchface/Renderer` that should be set up inside `https://developer.android.com/reference/androidx/wear/watchface/CanvasComplication#onRendererCreated(androidx.wear.watchface.Renderer)`.

use Watch Face Format instead

## Summary

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

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

## Public methods

### 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)

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

> [!CAUTION]
> **This method 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/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 |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/graphics/Canvas.html canvas` | The `https://developer.android.com/reference/android/graphics/Canvas.html` to render into |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/graphics/Rect.html bounds` | A `https://developer.android.com/reference/android/graphics/Rect.html` describing the bounds of the complication |
| `int boundsType` | The `https://developer.android.com/reference/androidx/wear/watchface/ComplicationSlotBoundsTypeIntDef` of the complication Value is one of the following: - `0` - `1` - `2` <br /> |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/time/ZonedDateTime.html zonedDateTime` | The `https://developer.android.com/reference/java/time/ZonedDateTime.html` to render the highlight with |
| `@https://developer.android.com/reference/androidx/annotation/ColorInt int color` | 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
default void [drawHighlight](https://developer.android.com/reference/androidx/wear/watchface/CanvasComplication#drawHighlight(android.graphics.Canvas,android.graphics.Rect,kotlin.Int,java.time.ZonedDateTime,kotlin.Int,androidx.wear.watchface.BoundingArc))(
    @NonNull Canvas canvas,
    @NonNull Rect bounds,
    int boundsType,
    @NonNull ZonedDateTime zonedDateTime,
    @ColorInt int color,
    BoundingArc boundingArc
)
```

> [!CAUTION]
> **This method 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/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 |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/graphics/Canvas.html canvas` | The `https://developer.android.com/reference/android/graphics/Canvas.html` to render into |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/graphics/Rect.html bounds` | A `https://developer.android.com/reference/android/graphics/Rect.html` describing the bounds of the complication |
| `int boundsType` | The `https://developer.android.com/reference/androidx/wear/watchface/ComplicationSlotBoundsTypeIntDef` of the complication Value is one of the following: - `0` - `1` - `2` <br /> |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/time/ZonedDateTime.html zonedDateTime` | The `https://developer.android.com/reference/java/time/ZonedDateTime.html` to render the highlight with |
| `@https://developer.android.com/reference/androidx/annotation/ColorInt int color` | The color to render the highlight with |
| `https://developer.android.com/reference/androidx/wear/watchface/BoundingArc boundingArc` | Optional `https://developer.android.com/reference/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)

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

> [!CAUTION]
> **This method 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/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)

```
abstract void [loadData](https://developer.android.com/reference/androidx/wear/watchface/CanvasComplication#loadData(androidx.wear.watchface.complications.data.ComplicationData,kotlin.Boolean))(
    @NonNull ComplicationData complicationData,
    boolean loadDrawablesAsynchronous
)
```

> [!CAUTION]
> **This method 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/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/androidx/wear/watchface/CanvasComplication#loadData(androidx.wear.watchface.complications.data.ComplicationData,kotlin.Boolean)`. When any asynchronous loading has completed `https://developer.android.com/reference/androidx/wear/watchface/CanvasComplication.InvalidateCallback#onInvalidate()` must be called.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/watchface/complications/data/ComplicationData complicationData` | The `https://developer.android.com/reference/androidx/wear/watchface/complications/data/ComplicationData` to render with |
| `boolean loadDrawablesAsynchronous` | 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
default void [onRendererCreated](https://developer.android.com/reference/androidx/wear/watchface/CanvasComplication#onRendererCreated(androidx.wear.watchface.Renderer))(@NonNull Renderer renderer)
```

> [!CAUTION]
> **This method 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/androidx/wear/watchface/Renderer` which is useful if they need to share state. Note the `https://developer.android.com/reference/androidx/wear/watchface/Renderer` is created asynchronously which is why we can't pass it in via `https://developer.android.com/reference/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
abstract void [render](https://developer.android.com/reference/androidx/wear/watchface/CanvasComplication#render(android.graphics.Canvas,android.graphics.Rect,java.time.ZonedDateTime,androidx.wear.watchface.RenderParameters,kotlin.Int))(
    @NonNull Canvas canvas,
    @NonNull Rect bounds,
    @NonNull ZonedDateTime zonedDateTime,
    @NonNull RenderParameters renderParameters,
    int slotId
)
```

> [!CAUTION]
> **This method 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/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 |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/graphics/Canvas.html canvas` | The `https://developer.android.com/reference/android/graphics/Canvas.html` to render into |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/graphics/Rect.html bounds` | A `https://developer.android.com/reference/android/graphics/Rect.html` describing the bounds of the complication |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/time/ZonedDateTime.html zonedDateTime` | The `https://developer.android.com/reference/java/time/ZonedDateTime.html` to render with |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/watchface/RenderParameters renderParameters` | The current `https://developer.android.com/reference/androidx/wear/watchface/RenderParameters` |
| `int slotId` | The Id of the `https://developer.android.com/reference/androidx/wear/watchface/ComplicationSlot` being rendered |