I’m trying to implement a feature to detect manga bubble speech.
I’m taking a screenshot of my device and receiving the response from the API, and as soon as it returns, I draw some rectangles with canvas. But I can’t seem to align these rectangles in any way.
Since I saw that you have used it before, I think you would know what my problem is. Could you help me?
My Code:
@Composable
internal fun ScreenShotDrawSpeech(
bubbleDomain: BubbleDomain,
modifier: Modifier = Modifier,
) {
Canvas(
modifier = modifier
.fillMaxSize()
.background(background_overlay),
onDraw = {
bubbleDomain.predictions.forEach { prediction ->
val left = prediction.x
val top = prediction.y
drawRect(
color = Color.Red,
topLeft = Offset(left.toFloat(), top.toFloat()),
size = Size(prediction.width.toFloat(), prediction.height.toFloat()),
style = Stroke(width = 2f),
)
}
},
)
}
Result: