I have a Black box out of which I want to take away a specific path.
Code
@Composable
fun PathDiff() {
Canvas(
modifier = Modifier
.fillMaxSize(),
) {
val rect1 = Path().apply {
addRect(Rect(Offset.Zero, Offset(400.0F, 400.0F)))
}
val rect2 = Path().apply {
moveTo(100.0F, 100.0F)
lineTo(200.0F, 100.0F)
lineTo(200.0F, 200.0F)
}
val newPath = Path.combine(
operation = PathOperation.Difference,
path1 = rect1,
path2 = rect2,
)
drawPath(
path = newPath,
color = Black,
alpha = 1F,
)
}
}
Current result
I want it to be a vertical and a horizontal line with given stroke width and rounded cap, not as a triangle.
How do I achieve that?
Note: I have not used close()
but it gets added automatically.