scale

Function

Common
fun Canvas.scale(sx: Float, sy: Float = sx, pivotX: Float, pivotY: Float)

Add an axis-aligned scale to the current transform, scaling by the first argument in the horizontal direction and the second in the vertical direction at the given pivot coordinate. The pivot coordinate remains unchanged by the scale transformation.

If sy is unspecified, sx will be used for the scale in both directions.

Parameters

sxThe amount to scale in X
syThe amount to scale in Y
pivotXThe x-coord for the pivot point
pivotYThe y-coord for the pivot point
Common
inline fun DrawTransform.scale(scale: Float, pivot: Offset = center) = scale(scale, scale, pivot)

Add an axis-aligned scale to the current transform, scaling uniformly in both directions by the provided scale factor at the pivot coordinate. The pivot coordinate remains unchanged by the scale transformation.

Parameters

scaleThe amount to scale
pivotThe coordinate for the pivot point, defaults to the center of the coordinate space
Common
inline fun DrawScope.scale(
    scaleX: Float,
    scaleY: Float,
    pivot: Offset = center,
    block: DrawScope.() -> Unit,
) = withTransform({ scale(scaleX, scaleY, pivot) }, block)

Add an axis-aligned scale to the current transform, scaling by the first argument in the horizontal direction and the second in the vertical direction at the given pivot coordinate. The pivot coordinate remains unchanged by the scale transformation. After this method is invoked, the coordinate space is returned to the state before the scale was applied.

Parameters

scaleXThe amount to scale in X
scaleYThe amount to scale in Y
pivotThe coordinate for the pivot point, defaults to the center of the coordinate space
blocklambda used to issue drawing commands within the scaled coordinate space
Common
inline fun DrawScope.scale(scale: Float, pivot: Offset = center, block: DrawScope.() -> Unit) =
    withTransform({ scale(scale, scale, pivot) }, block)

Add an axis-aligned scale to the current transform, scaling both the horizontal direction and the vertical direction at the given pivot coordinate. The pivot coordinate remains unchanged by the scale transformation. After this method is invoked, the coordinate space is returned to the state before the scale was applied.

Parameters

scaleThe amount to scale uniformly in both directions
pivotThe coordinate for the pivot point, defaults to the center of the coordinate space
blocklambda used to issue drawing commands within the scaled coordinate space