{% setvar book_path %}/reference/androidx/_book.yaml{% endsetvar %} {% include "_shared/_reference-head-tags.html" %}

DrawContext

public interface DrawContext


Object that provides the dependencies to support a DrawScope drawing environment. Namely this provides the drawing bounds represented as a size as well as the target Canvas to issue drawing commands into. Additionally the DrawContext handles updating Canvas state during transformations and updating the size of the drawing bounds that may occur during these transformations.

This exposes necessary internal state to the implementation of the DrawScope in order to support inline scoped transformation calls without allowing consumers of DrawScope to modify state directly thus maintaining the stateless API surface

Summary

Public methods

abstract @NonNull Canvas

The target canvas to issue drawing commands

abstract @NonNull Size

The current size of the drawing environment

abstract @NonNull DrawTransform

The controller for issuing transformations to the drawing environment

abstract void

The current size of the drawing environment

Public methods

getCanvas

abstract @NonNull Canvas getCanvas()

The target canvas to issue drawing commands

getSize

abstract @NonNull Size getSize()

The current size of the drawing environment

getTransform

abstract @NonNull DrawTransform getTransform()

The controller for issuing transformations to the drawing environment

setSize

abstract void setSize(@NonNull Size size)

The current size of the drawing environment