public sealed interface PolygonShapeTransformScope : Density
Transforms a PolygonShape's geometry inside PolygonShape.transform.
Exposes the layout resolution inputs (size, layoutDirection, and Density). Operations (rotate, translate, scale, transform, and scaleToFit) concatenate onto the transformation matrix in the exact order they are called (for example, scale followed by translate differs from translate followed by scale).
Properties
size
public val size: Size
Size of the shape's layout container in pixels.
layoutDirection
public val layoutDirection: LayoutDirection
Layout direction of the shape.
Functions
rotate
public fun rotate(degrees: Float, pivot: Offset = Offset.Unspecified)
Rotates the polygon clockwise by degrees around pivot.
Parameters
| degrees | clockwise rotation in degrees |
| pivot | rotation center in pixels, or Offset.Unspecified for the polygon's center |
translate
public fun translate(x: Float = 0f, y: Float = 0f)
Translates the polygon by (x, y) pixels.
Parameters
| x | horizontal offset in pixels |
| y | vertical offset in pixels |
scale
public fun scale(
scaleX: Float,
scaleY: Float = scaleX,
pivot: Offset = Offset.Unspecified,
)
Scales the polygon by scaleX horizontally and scaleY vertically around pivot.
Parameters
| scaleX | horizontal scale factor |
| scaleY | vertical scale factor, defaults to scaleX for uniform scaling |
| pivot | scale center in pixels, or Offset.Unspecified for the polygon's center |
transform
public fun transform(matrix: Matrix)
Multiplies the current transformation by the affine matrix around the polygon's center.
Linear components (rotation, scale, skew) pivot around the polygon's center, while translation components offset the polygon directly.
Parameters
| matrix | affine transformation matrix to multiply |
Throws: IllegalArgumentException
if matrix contains perspective components
scaleToFit
public fun scaleToFit(
contentScale: ContentScale = ContentScale.Fit,
alignment: Alignment = Alignment.Center,
)
Scales and aligns the polygon's bounding box into size in call order.
- Call before
rotate, scale, ortranslateto fit the unrotated polygon first, then - Call after
rotateortransformto fit the transformed bounding box into size. ContentScale.Fit(default) scales uniformly to fit within bounds, preserving aspect ratioContentScale.FillBoundsstretches each axis independently to fill the boundsContentScale.Cropfills the bounds, preserving aspect ratio and clipping overflowContentScale.Noneapplies no scaling
transform it around its fitted center.
Parameters
| contentScale | policy for scaling the polygon's bounding box into the layout bounds |
| alignment | placement of the scaled polygon within the layout bounds |