Akram Bensalem
08/03/2021, 12:55 PMCicero
08/03/2021, 2:46 PMAkram Bensalem
08/10/2021, 12:07 PMBox(modifier = Modifier.fillMaxSize()) {
var offsetX by remember { mutableStateOf(0f) }
var offsetY by remember { mutableStateOf(0f) }
var scale by remember { mutableStateOf(1f) }
var rotation by remember { mutableStateOf(0f) }
Box(
Modifier
.scale(scale)
.rotate(rotation)
.offset { IntOffset(offsetX.roundToInt(), offsetY.roundToInt()) }
.height(50.dp)
.width(200.dp)
.pointerInput(Unit) {
detectTransformGestures { centroid, pan, zoom, rot ->
offsetX += pan.x
offsetY += pan.y
scale *= zoom
rotation += rot
}
}
.background(Color.Blue)
)
}
The problem is It's not rotate correctly
And if switch the order like this:
The dragging not working properly !!!
Any help or explination please
Modifier
.offset { IntOffset(offsetX.roundToInt(), offsetY.roundToInt()) }
.height(50.dp)
.width(200.dp)
.scale(scale)
.rotate(rotation)