Is there any way to apply antialiasing (or just cl...
# compose
c
Is there any way to apply antialiasing (or just clean up the lines) when using
GenericShape
? For example, I’ve drawn a simple Triangle, but if I zoom slightly you can see how messy the lines are
Copy code
val TriangleShape = GenericShape { size, _ ->
    moveTo(size.width / 2, 0f)
    lineTo(size.width, size.height)
    lineTo(0f, size.height)
    close()
}

Surface(
    shape = TriangleShape, 
    color = Color.Black, 
    modifier = Modifier
        .size(64.dp)
        .align(Alignment.CenterHorizontally)
) {}
a
clipping by Path is only antialised on latest versions of Android. but in your case instead of clipping by Path you can just draw the path, this will be antialised. Use Canvas composable and drawPath() function in its scope