Class

PolygonShapeGeometry

Defines a polygon's vertices, center, and corner rounding.

UnitSpacePolygonShapeSample

@Sampled
@Composable
fun UnitSpacePolygonShapeSample() {
    // A kite authored in the unit square [0..1] with per-vertex rounding as fractions of the
    // bounds, scaled and centered into the container via transform { scaleToFit() }.
    val kite = remember {
        val geometry =
            PolygonShapeGeometry(
                vertices =
                    listOf(Offset(0.5f, 0f), Offset(1f, 0.4f), Offset(0.5f, 1f), Offset(0f, 0.4f)),
                perVertexRounding =
                    listOf(
                        CornerRounding.fraction(0.1f),
                        CornerRounding.fraction(0.15f),
                        CornerRounding.fraction(0.05f),
                        CornerRounding.fraction(0.15f),
                    ),
            )
        PolygonShape { geometry }.apply { transform { scaleToFit() } }
    }

    Box(Modifier.size(width = 120.dp, height = 84.dp).clip(kite).background(Color(0xFF673AB7)))
}
Jetpack Compose beyond MaterialFree components, screens and templates for apps that don’t look like Google’s. Copy them into your app, or let your coding agent add them.Browse for free

Content updated: