transformed
public fun PolygonShape.transformed(
rotation: Float = 0f,
translation: Offset = Offset.Zero,
contentScale: ContentScale? = null,
alignment: Alignment = Alignment.Center,
): PolygonShape
Returns a new PolygonShape with rotation and translation applied to the underlying geometry.
rotation is applied clockwise in degrees around the geometry's center, and translation 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 to adjust scaling on an existing shape.
This function returns a new PolygonShape 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
public fun PolygonShape.transformed(
matrix: Matrix,
contentScale: ContentScale? = null,
alignment: Alignment = Alignment.Center,
): PolygonShape
Returns a new PolygonShape 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 to adjust scaling on an existing shape.
This function returns a new PolygonShape 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 has perspective components