---
title: "transformed"
description: "Returns a new [PolygonShape] with [rotation] and [translation] applied to the underlying geometry."
type: "function"
lastmod: "2026-09-24"
---
## API Reference

### transformed

> Source set: Common

```kotlin
public fun PolygonShape.transformed(
    rotation: Float = 0f,
    translation: Offset = Offset.Zero,
    contentScale: ContentScale? = null,
    alignment: Alignment = Alignment.Center,
): PolygonShape
```

Returns a new [PolygonShape](/jetpack-compose/androidx.compose.foundation/foundation/functions/PolygonShape/api) with [rotation](/jetpack-compose/androidx.compose.foundation/foundation/functions/rotation/api) and [translation](/jetpack-compose/androidx.compose.foundation/foundation/functions/translation/api) applied to the underlying
geometry.

[rotation](/jetpack-compose/androidx.compose.foundation/foundation/functions/rotation/api) is applied clockwise in degrees around the geometry's center, and [translation](/jetpack-compose/androidx.compose.foundation/foundation/functions/translation/api) moves
the shape by the specified horizontal and vertical offsets.

When `contentScale` is non-null, the transformed geometry is scaled and aligned into the layout
container bounds to prevent rotated corners from escaping the container. Pass `contentScale =
null` (the default) to apply only the transformation without scaling, or use [scaledToFit](/jetpack-compose/androidx.compose.foundation/foundation/functions/scaledToFit/api) to
adjust scaling on an existing shape.

This function returns a new [PolygonShape](/jetpack-compose/androidx.compose.foundation/foundation/functions/PolygonShape/api) and should not be used for continuous animations. To
animate rotation or translation on every frame, apply
`androidx.compose.ui.graphics.graphicsLayer` instead to transform the rendered output without
rebuilding geometry.

Leaves the receiver untouched and derives a new shape value.

#### Parameters

| | |
| --- | --- |
| rotation | clockwise rotation in degrees, applied around the geometry center |
| translation | offset by which to move the shape |
| contentScale | optional scaling policy applied after the transformation, or null to skip scaling |
| alignment | where to place the scaled geometry within the layout bounds |

### transformed

> Source set: Common

```kotlin
public fun PolygonShape.transformed(
    matrix: Matrix,
    contentScale: ContentScale? = null,
    alignment: Alignment = Alignment.Center,
): PolygonShape
```

Returns a new [PolygonShape](/jetpack-compose/androidx.compose.foundation/foundation/functions/PolygonShape/api) with `matrix` applied to the underlying geometry.

Rotation, scale, and skew act around the resolved geometry's center, changing the shape's
orientation and size in place; translation components move the shape as written.

When `contentScale` is non-null, the transformed geometry is scaled and aligned into the layout
container bounds to prevent rotated corners from escaping the container. Pass `contentScale =
null` (the default) to apply only the matrix transformation without scaling, or use [scaledToFit](/jetpack-compose/androidx.compose.foundation/foundation/functions/scaledToFit/api)
to adjust scaling on an existing shape.

This function returns a new [PolygonShape](/jetpack-compose/androidx.compose.foundation/foundation/functions/PolygonShape/api) and should not be used for continuous animations. To
animate rotation or scale on every frame, apply `androidx.compose.ui.graphics.graphicsLayer`
instead to transform the rendered output without rebuilding geometry.

Leaves the receiver untouched and derives a new shape value holding a snapshot of `matrix`.

#### Parameters

| | |
| --- | --- |
| matrix | affine transformation to apply to the geometry |
| contentScale | optional scaling policy applied after the transformation, or null to skip scaling |
| alignment | where to place the scaled geometry within the layout bounds |

#### Throws: IllegalArgumentException

if [matrix](/jetpack-compose/androidx.compose.ui/ui-graphics/classes/Matrix) has perspective components

## Code Examples

### TransformedPolygonShapeSample

```kotlin
@Sampled
@Composable
fun TransformedPolygonShapeSample() {
    // A square polygon rotated 45 degrees around its center and scaled into the layout bounds in a
    // single pass so the rotated diamond stays inscribed without clipping.
    val diamond = remember {
        PolygonShape { polygon(numVertices = 4, rounding = CornerRounding(percent = 15)) }
            .transformed(rotation = 45f, contentScale = ContentScale.Fit)
    }
    Box(Modifier.size(96.dp).clip(diamond).background(Color(0xFFE91E63)))
}
```

### RuntimeTransformedPolygonShapeSample

```kotlin
@Sampled
@Composable
fun RuntimeTransformedPolygonShapeSample() {
    // Pre-creates the unrotated and rotated badge shape values. The runtime decision toggles
    // between shape instances without rebuilding or recomputing geometry on state flips.
    val badge = remember {
        PolygonShape.star(
            numPoints = 8,
            innerRadiusRatio = 0.75f,
            outerRounding = CornerRounding(percent = 40),
        )
    }
    val selectedBadge = remember(badge) { badge.transformed(rotation = 22.5f) }
    var selected by remember { mutableStateOf(false) }
    val shape = if (selected) selectedBadge else badge
    Box(
        Modifier.size(96.dp).clip(shape).background(Color(0xFF00695C)).clickable {
            selected = !selected
        }
    )
}
```
