Function

calculateRotation

Returns the rotation, in degrees, of the pointers between the [PointerInputChange.

CalculateRotation

@Composable
fun CalculateRotation() {
    var angle by remember { mutableStateOf(0f) }
    Box(
        Modifier.graphicsLayer(rotationZ = angle)
            .background(Color.Blue)
            .pointerInput(Unit) {
                awaitEachGesture {
                    awaitFirstDown()
                    do {
                        val event = awaitPointerEvent()
                        val rotation = event.calculateRotation()
                        angle += rotation
                    } while (event.changes.any { it.pressed })
                }
            }
            .fillMaxSize()
    )
}