public sealed interface PolygonShapeScope : Density
Builds PolygonShapeGeometry for a PolygonShape at layout resolution.
Exposes size, layoutDirection, and Density along with polygon factories. Coordinates are in layout pixels.
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
polygon
public fun polygon(
@IntRange(from = 3) numVertices: Int,
@FloatRange(from = 0.0, fromInclusive = false) 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.
CornerRounding.fraction sets the corner radius as a fraction of radius.
Parameters
| numVertices | number of vertices, at least 3 |
| radius | circle radius in pixels |
| center | polygon center in pixels, defaults to Size.center |
| rounding | corner rounding applied to every vertex |
Throws: IllegalArgumentException
if numVertices is less than 3
polygon
public fun polygon(
@IntRange(from = 3) numVertices: Int,
perVertexRounding: List<CornerRounding>,
@FloatRange(from = 0.0, fromInclusive = false) radius: Float = size.minDimension / 2f,
center: Offset = size.center,
): PolygonShapeGeometry
Creates a regular polygon with numVertices vertices and per-vertex perVertexRounding.
perVertexRounding applies to vertices in clockwise order starting from the right (0 degrees). CornerRounding.fraction sets the corner radius as a fraction of radius.
Parameters
| numVertices | number of vertices, at least 3 |
| perVertexRounding | rounding for each vertex, matching numVertices in size |
| radius | circle radius in pixels |
| center | polygon center in pixels, defaults to Size.center |
Throws: IllegalArgumentException
if numVertices is less than 3 or perVertexRounding differs from numVertices in size
polygon
public fun polygon(
vertices: List<Offset>,
center: Offset = Offset.Unspecified,
rounding: CornerRounding = CornerRounding.Unrounded,
): PolygonShapeGeometry
Creates polygon geometry from vertices with uniform rounding.
Coordinates are in layout pixels ((0f, 0f) to (size.width, size.height)). You can also define vertices in a custom coordinate space (such as a `0f, 1f unit square) and scale them to the layout bounds using PolygonShapeTransformScope.scaleToFit. Because custom vertices do not have a circle radius, CornerRounding.fraction sets the corner radius as a fraction of the polygon's smaller dimension (min(width, height)`).
Parameters
| vertices | vertex positions in pixels (or custom coordinates scaled with PolygonShapeTransformScope.scaleToFit), at least 3 |
| center | polygon center in pixels, or Offset.Unspecified to compute from vertices |
| rounding | corner rounding applied to every vertex |
Throws: IllegalArgumentException
if vertices has fewer than 3 entries
polygon
public fun polygon(
vertices: List<Offset>,
perVertexRounding: List<CornerRounding>,
center: Offset = Offset.Unspecified,
): PolygonShapeGeometry
Creates polygon geometry from vertices with per-vertex perVertexRounding.
Coordinates are in layout pixels ((0f, 0f) to (size.width, size.height)). You can also define vertices in a custom coordinate space (such as a `0f, 1f unit square) and scale them to the layout bounds using PolygonShapeTransformScope.scaleToFit. Because custom vertices do not have a circle radius, CornerRounding.fraction sets the corner radius as a fraction of the polygon's smaller dimension (min(width, height)`).
Parameters
| vertices | vertex positions in pixels (or custom coordinates scaled with PolygonShapeTransformScope.scaleToFit), at least 3 |
| perVertexRounding | rounding for each vertex, matching vertices in size |
| center | polygon center in pixels, or Offset.Unspecified to compute from vertices |
Throws: IllegalArgumentException
if vertices has fewer than 3 entries or perVertexRounding differs from vertices in size