RoundedCornerShapeToPolygonShapeSample
@Sampled
@Composable
fun RoundedCornerShapeToPolygonShapeSample() {
// Converting a corner-based shape to a PolygonShape lets it morph with any other polygon
// shape; here a rounded rectangle relaxes into a circle.
var expanded by remember { mutableStateOf(false) }
val progress by animateFloatAsState(if (expanded) 1f else 0f)
val shape = remember {
MorphPolygonShape(
start = RoundedCornerShape(12.dp).toPolygonShape(),
end = PolygonShape.circle(),
progress = { progress },
)
}
Box(
Modifier.size(96.dp).clip(shape).background(Color(0xFF03A9F4)).clickable {
expanded = !expanded
}
)
}