Billy Newman
08/01/2022, 6:35 PMBilly Newman
08/01/2022, 6:40 PMCanvas(modifier = Modifier.fillMaxSize()) {
drawArc(
Color.Green,
30f,
90f,
topLeft = Offset(0f, 0f),
useCenter = true,
size = Size(sizeInPx, sizeInPx)
)
}
I would like to draw text along the inside of that arc. Looks like I can use drawIntoCanvas and get ahold of the native canvas:
Canvas(modifier = Modifier.fillMaxSize()) {
drawIntoCanvas {
it.nativeCanvas.drawText(
sector.text,
0f,
0f,
Paint().apply {
setColor(android.graphics.Color.BLACK)
textSize = textSizeInPx
}
)
}
}
However that is not drawing along the arc path. From some searching looks like maybe there used to be a compose drawText method, but I don’t see that anymore.
Looks like I might be able to use nativeCanvas.drawTextOnPath(), which requires another calculation of the arc. Am I going down the correct path?Scott Peterson
08/01/2022, 6:59 PMdrawText
method. We just used one inside a Canvas()
Scott Peterson
08/01/2022, 6:59 PMdrawContext.canvas.nativeCanvas.apply { }
Billy Newman
08/01/2022, 7:01 PMScott Peterson
08/01/2022, 7:05 PMTin Tran
08/02/2022, 2:00 AMdrawText
in compose canvas has been added to compose in 1.3.0-alpha02 you can give it a try