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


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


<h2 id="withtransform-transformblock-drawblock">withTransform</h2>

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


```kotlin
inline fun DrawScope.withTransform(
    transformBlock: DrawTransform.() -> Unit,
    drawBlock: DrawScope.() -> Unit,
) =
    with(drawContext) {
        val previousSize = size
        canvas.save()
        try {
            transformBlock(transform)
            drawBlock()
        } finally {
            canvas.restore()
            size = previousSize
        }
    }
```


Perform 1 or more transformations and execute drawing commands with the specified transformations
applied. After this call is complete, the transformation before this call was made is restored

#### Parameters

| | |
| --- | --- |
| transformBlock | Callback invoked to issue transformations to be made before the drawing operations are issued |
| drawBlock | Callback invoked to issue drawing operations after the transformations are applied |