k

    Kazemihabib1996

    2 years ago
    I'm playing with Clip and Draw components can someone explain me why this doesn't produce a rounded shape rectangle?
    Container(width = 400.dp, height = 400.dp) {
    Clip(shape = RoundedCornerShape(20.dp)) {
    Draw { canvas, parentsize ->
    val outer = Rect(10f, 10f, 100f, 100f)
    canvas.drawRect(outer, paint)
    }
    }
    }
    Zach Klippenstein (he/him) [MOD]

    Zach Klippenstein (he/him) [MOD]

    2 years ago
    k

    Kazemihabib1996

    2 years ago
    Yes, you are right
    Surface(color = Color.Blue) {
            Container(width = 200.dp, height = 200.dp) {
                Clip(shape = RoundedCornerShape(10.dp)) {
                    Draw { canvas, parentsize ->
                val outer = Rect.fromCircle(Offset(200f, 200f), radius = 100f)
                        canvas.drawRect(outer, paint)
                    }
                }
            }
        }
    produces the below image
    but if I change the radius or Container size some interesting thing happens the below images: