Function

withTransform

Perform 1 or more transformations and execute drawing commands with the specified transformations applied.

withTransform

Common
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