Lisandro Di Meo
11/17/2022, 12:12 PMnlindberg
11/17/2022, 12:14 PMLisandro Di Meo
11/17/2022, 12:17 PMfun Background(){
val path = Path()
val paint = Paint()
path.fillType = PathFillType.EvenOdd
paint.apply {
strokeWidth = 10f
color = BlueRibbon
style = PaintingStyle.Fill
isAntiAlias = true
}
Canvas(modifier = Modifier
.fillMaxSize() , onDraw = {
val canvasWidth = size.width
val canvasHeight = size.height/4
val offsetForVertex = 300f
println("$canvasHeight $canvasWidth")
paint.shader = LinearGradientShader(from = Offset(canvasWidth, 0f), to = Offset(0f, canvasHeight), listOf(SkyBlue, BlueRibbon, Idk))
drawIntoCanvas {
path.moveTo(0f,canvasHeight)
path.cubicTo(0f, canvasHeight, canvasWidth/2, canvasHeight + offsetForVertex, canvasWidth, canvasHeight)
path.lineTo(canvasWidth, 0f)
path.lineTo(0f, 0f)
path.lineTo(0f, canvasHeight)
path.close()
it.drawPath(path, paint)
}
})
}
Lisandro Di Meo
11/17/2022, 12:18 PMLisandro Di Meo
11/17/2022, 12:27 PMLoney Chou
11/17/2022, 4:46 PMLoney Chou
11/17/2022, 4:49 PMSpacer(
modifier = Modifier
.fillMaxSize()
.drawWithCache {
val path = Path()
// ...
onDraw {
drawPath(path, ...)
}
}
)
Lisandro Di Meo
11/18/2022, 12:28 PMLoney Chou
11/18/2022, 4:22 PMLisandro Di Meo
11/18/2022, 8:48 PMLisandro Di Meo
11/18/2022, 8:49 PM