---
title: "calculateZoom"
description: "Uses the change of the centroid size between the [PointerInputChange.previousPosition] and
[PointerInputChange.position] to determine how much zoom was intended.

Example Usage:"
type: "function"
---

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


<a id='references'></a>
<div class='sourceset sourceset-common'>Common</div>


```kotlin
fun PointerEvent.calculateZoom(): Float
```


Uses the change of the centroid size between the `PointerInputChange.previousPosition` and
`PointerInputChange.position` to determine how much zoom was intended.

Example Usage:



## Code Examples
### CalculateZoom
```kotlin
@Composable
fun CalculateZoom() {
    var zoom by remember { mutableStateOf(1f) }
    Box(
        Modifier.graphicsLayer(scaleX = zoom, scaleY = zoom)
            .background(Color.Blue)
            .pointerInput(Unit) {
                awaitEachGesture {
                    awaitFirstDown()
                    do {
                        val event = awaitPointerEvent()
                        zoom *= event.calculateZoom()
                    } while (event.changes.any { it.pressed })
                }
            }
            .fillMaxSize()
    )
}
```

