---
title: "DrawContext"
description: "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"
type: "interface"
---

<div class='type'>Interface</div>


<a id='references'></a>

<div class='sourceset sourceset-common'>Common</div>



```kotlin
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


## Properties

<div class='sourceset sourceset-common'>Common</div>


```kotlin
var size: Size
```


The current size of the drawing environment



<div class='sourceset sourceset-common'>Common</div>


```kotlin
var canvas: Canvas
```


The target canvas to issue drawing commands



<div class='sourceset sourceset-common'>Common</div>


```kotlin
val transform: DrawTransform
```


The controller for issuing transformations to the drawing environment



<div class='sourceset sourceset-common'>Common</div>


```kotlin
var layoutDirection: LayoutDirection
```


`LayoutDirection` of the layout being drawn in.



<div class='sourceset sourceset-common'>Common</div>


```kotlin
var density: Density
```


`Density` used to assist in conversions of density independent pixels to raw pixels to draw



<div class='sourceset sourceset-common'>Common</div>


```kotlin
var graphicsLayer: GraphicsLayer?
```


Current `GraphicsLayer` we are drawing into. Might be null if the `canvas` is not provided by
a `GraphicsLayer`, for example in the case of a software-accelerated drawing.




