Assume I have the following code in compose below.
A background magenta circle with a text on top with a default black color.
I would like to blend the text color to White when it is above the circle.
Canvas(
modifier = Modifier.size(256.dp),
onDraw = {
drawCircle(
color = Color.Magenta,
radius = 50f,
center = Offset(
x = size.width / 2,
y = size.height / 2),
)
val textSize = textMeasurer.measure(text = AnnotatedString("A"))
drawText(
textMeasurer = textMeasurer,
text = "A",
style = TextStyle(
color = Color.Black,
fontSize = 14.sp
),
topLeft = Offset(
x = size.width / 2 - 100f - (textSize.size.width / 2),
y = size.height / 2 - (textSize.size.height / 2)
)
)
drawText(
textMeasurer = textMeasurer,
text = "B",
style = TextStyle(
color = Color.Black,
fontSize = 14.sp
),
topLeft = Offset(
x = size.width / 2 - (textSize.size.width / 2),
y = size.height / 2 - (textSize.size.height / 2)
)
)
}
)
I have tried using BlendMode on the cirle in a lot of different configurations but I'm unable to make it work. And drawText doesn't have a blend mode that I can see.
Is there an easy way to achieve blending to make the text above the circle white?