Function

PolygonShape

Creates a PolygonShape whose geometry is defined by builder at layout resolution time.

PolygonShape

Source set: Common
public fun PolygonShape(builder: PolygonShapeScope.() -> PolygonShapeGeometry): PolygonShape

Creates a PolygonShape whose geometry is defined by builder at layout resolution time.

builder runs in PolygonShapeScope on every resolution, with access to the resolved size, layout direction, and density; the PolygonShapeGeometry it returns is the shape's definition. Values the lambda reads are re-read on each resolution, and the outline rebuilds when the resulting geometry changes. Two shapes created with the same builder instance compare equal.

Use this overload when the geometry depends on the resolved size or density, such as vertices placed in pixels of the layout's coordinate space or rounding given in Dp. For a fixed geometry that scales uniformly into any container, use the PolygonShape overload taking a PolygonShapeGeometry.

Parameters

builder lambda run in PolygonShapeScope returning the shape's geometry

PolygonShape

Source set: Common
public fun PolygonShape(geometry: PolygonShapeGeometry): PolygonShape

Creates a PolygonShape from geometry defined in an author-chosen coordinate space.

The geometry is uniformly scaled and centered to fit within the layout bounds at resolution time, preserving its aspect ratio.

Use this overload for a fixed shape definition, such as unit-space vertices, that scales into whatever bounds the shape is used in. To define geometry against the resolved size, layout direction, or density instead, use the PolygonShape overload taking a PolygonShapeScope builder.

Parameters

geometry polygon geometry to scale and center into the layout bounds

Content updated: