calculateRotation
Function
Common
fun PointerEvent.calculateRotation(): Float
Returns the rotation, in degrees, of the pointers between the
PointerInputChange.previousPosition
and PointerInputChange.position
states. Only the pointers
that are down in both previous and current states are considered.
Example Usage:
Code Examples
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()
)
}