I would like to draw a Transparent Rectangle in order to split my Box.
I have found in this post what I needed to clip/cut my Composable by drawing a Transparent Rect.
Here is my code:
Box(
modifier = Modifier
.height(35.dp)
.fillMaxWidth()
.clip(shape = RoundedCornerShape(8.dp))
.fillMaxWidth()
.drawWithLayer {
drawContent()
val rect = Rect(
offset = Offset(x = size.width / 2f, y = 0f),
size = Size(width = 10.dp.value, height = size.height),
)
rotate(
degrees = 35F,
pivot = rect.center
) {
drawRect(
blendMode = BlendMode.SrcOut,
color = Color.Transparent,
topLeft = rect.topLeft,
size = rect.size,
)
}
}
) {
Result :
This is the intended behaviour, but I don't understand why when I rotate the rectangle, it doesn't take the whole height?
EDIT:
After trying the solution by changing the height of the transparent rectangle, this is what I got.
It's almost the expected result, but the top part of the rectangle doesn't fit.