I want to use BlendMode.DstAtop while doing some custom drawing with
Canvas
but this doesn't work as it should.
Here is my code:
Column {
Canvas(
modifier = Modifier
.height(90.dp)
.fillMaxWidth()
.graphicsLayer(
compositingStrategy = CompositingStrategy.Offscreen
)
) {
val canvasWidth = size.width
val canvasHeight = size.height
drawRect(
Color.Blue,
Offset(canvasWidth*0.8f/2, canvasHeight*0.8f/2),
)
drawCircle(
Color.Red,
center = Offset(canvasWidth*0.8f/2, canvasHeight/2),
blendMode = BlendMode.DstAtop
)
}
}
I expect to get this result for BlendMode.DstAtop:
But get this instead:
I've also checked BlendMode.SrcIn, BlendMode.DstIn, BlendMode.Multiply, BlendMode.SrcOut, BlendMode.SrcOut
and these blendmodes don't work as it should either, while BlendMode.DstOut, BlendMode.SrcAtop, BlendMode.SrcOver, BlendMode.DstOver
work good.
I tried these solutions:
- Jetpack compose Canvas blendmode not working as expected
- jetpack compose blendMode or PorterDuff.Mode DST_IN
but it doesn't help, at least with Jetpack Compose 1.4.1