I have an image and I want to draw dark rectangle over it with a transparent circle, so the result will be something like this:
I have ended up with this code:
Box(modifier = Modifier
.clip(RectangleShape)
.fillMaxSize()
.background(Color.Black)
.pointerInput(Unit) {
detectTransformGestures { centroid, pan, zoom, rotation ->
scale *= zoom
}
}) {
Image(
modifier = Modifier
.align(Alignment.Center)
.graphicsLayer(
scaleX = maxOf(.2f, minOf(5f, scale)),
scaleY = maxOf(.2f, minOf(5f, scale))
),
bitmap = bitmap.asImageBitmap(),
contentDescription = null
)
Canvas(modifier = Modifier.fillMaxSize(), onDraw = {
drawRect(Color.Black.copy(alpha = 0.8f))
drawCircle(
Color.Transparent,
style = Fill,
blendMode = BlendMode.Clear
)
})
}
But it seems like it just draws a dark circle on top of the image instead of clearing darken rectangle...
It would be also super handy if you would suggest how to crop image based on this circle coordinates.