Interface

PolygonShapeTransformScope

Transforms a PolygonShape's geometry inside PolygonShape.transform.

Source set: Common
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

Source set: Common
public val size: Size

Size of the shape's layout container in pixels.

layoutDirection

Source set: Common
public val layoutDirection: LayoutDirection

Layout direction of the shape.

Functions

rotate

Source set: Common
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

Source set: Common
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

Source set: Common
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

Source set: Common
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

Source set: Common
public fun scaleToFit(
        contentScale: ContentScale = ContentScale.Fit,
        alignment: Alignment = Alignment.Center,
    )

Scales and aligns the polygon's bounding box into size in call order.

    transform it around its fitted center.

  • Call before rotate, scale, or translate to fit the unrotated polygon first, then
  • Call after rotate or transform to fit the transformed bounding box into size.
  • ContentScale.Fit (default) scales uniformly to fit within bounds, preserving aspect ratio
  • ContentScale.FillBounds stretches each axis independently to fill the bounds
  • ContentScale.Crop fills the bounds, preserving aspect ratio and clipping overflow
  • ContentScale.None applies no scaling

Parameters

contentScale policy for scaling the polygon's bounding box into the layout bounds
alignment placement of the scaled polygon within the layout bounds

Content updated: