Function

scaledToFit

Returns a new PolygonShape scaled and aligned into the layout bounds.

ScaledToFitPolygonShapeSample

@Sampled
@Composable
fun ScaledToFitPolygonShapeSample() {
    // Inside a wide container the star keeps its aspect ratio and is centered; passing
    // ContentScale.FillBounds instead would stretch it to fill the container.
    val star = remember {
        PolygonShape.star(
                numPoints = 5,
                innerRadiusRatio = 0.5f,
                outerRounding = CornerRounding(percent = 30),
            )
            .scaledToFit(contentScale = ContentScale.Fit)
    }
    Box(Modifier.size(width = 160.dp, height = 64.dp).clip(star).background(Color(0xFF9C27B0)))
}

Content updated: