🤔 the case is, I only want it to draw once
fun 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)
}
})
}