withTransform

Function

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

transformBlockCallback invoked to issue transformations to be made before the drawing operations are issued
drawBlockCallback invoked to issue drawing operations after the transformations are applied