Interface

PolygonShapeScope

Receiver scope for the PolygonShape builder lambda.

Source set: Common
public sealed interface PolygonShapeScope : Density

Receiver scope for the PolygonShape builder lambda.

Provides the resolution inputs (size, layoutDirection, and Density) and the factories that create the PolygonShapeGeometry the lambda returns. Coordinates are in pixels in the layout's coordinate space; Dp values resolve with the current density, and percent values are size-proportional.

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

polygon

Source set: Common
public fun polygon(
        numVertices: Int,
        radius: Float = size.minDimension / 2f,
        center: Offset = size.center,
        rounding: CornerRounding = CornerRounding.Unrounded,
    ): PolygonShapeGeometry

Creates a regular polygon with numVertices vertices on a circle of radius pixels around center, with the same rounding at every vertex.

Rounding resolves against the polygon itself, not the container. A percent radius is a percentage of radius, a Dp radius resolves with the current density, and a float radius is a length in pixels.

Parameters

numVertices number of vertices, at least 3
radius radius in pixels of the circle the vertices are placed on
center center of the polygon in pixels, defaults to the container center
rounding rounding applied to every vertex

Throws: IllegalArgumentException

if numVertices is less than 3

polygon

Source set: Common
public fun polygon(
        numVertices: Int,
        perVertexRounding: List<CornerRounding>,
        radius: Float = size.minDimension / 2f,
        center: Offset = size.center,
    ): PolygonShapeGeometry

Creates a regular polygon with numVertices vertices on a circle of radius pixels around center, with a separate rounding for each vertex.

Rounding resolves against the polygon itself, not the container. A percent radius is a percentage of radius, a Dp radius resolves with the current density, and a float radius is a length in pixels. Vertex i of perVertexRounding rounds the vertex at angle 2πi/numVertices on the generating circle.

Parameters

numVertices number of vertices, at least 3
perVertexRounding rounding for each vertex, matching numVertices in size
radius radius in pixels of the circle the vertices are placed on
center center of the polygon in pixels, defaults to the container center

Throws: IllegalArgumentException

if numVertices is less than 3, or if perVertexRounding differs from numVertices in size

polygon

Source set: Common
public fun polygon(
        vertices: List<Offset>,
        center: Offset = Offset.Unspecified,
        rounding: CornerRounding = CornerRounding.Unrounded,
    ): PolygonShapeGeometry

Creates polygon geometry from vertices in pixels, with the same rounding at every vertex.

Rounding resolves against the vertex bounds, not the container. A percent radius is a percentage of the bounds' smaller dimension, a Dp radius resolves with the current density, and a float radius is a length in pixels.

Parameters

vertices vertex positions in pixels, at least 3
center polygon center in pixels, computed from the geometry when unspecified. An explicit center can be specified as a custom transformation or morphing anchor.
rounding rounding applied to every vertex

Throws: IllegalArgumentException

if vertices has fewer than 3 entries

polygon

Source set: Common
public fun polygon(
        vertices: List<Offset>,
        perVertexRounding: List<CornerRounding>,
        center: Offset = Offset.Unspecified,
    ): PolygonShapeGeometry

Creates polygon geometry from vertices in pixels, with a separate rounding for each vertex.

Rounding resolves against the vertex bounds, not the container. A percent radius is a percentage of the bounds' smaller dimension, a Dp radius resolves with the current density, and a float radius is a length in pixels.

Parameters

vertices vertex positions in pixels, at least 3
perVertexRounding rounding for each vertex, matching vertices in size
center polygon center in pixels, computed from the geometry when unspecified. An explicit center can be specified as a custom transformation or morphing anchor.

Throws: IllegalArgumentException

if vertices has fewer than 3 entries, or if perVertexRounding differs from vertices in size

Content updated: