RoundedPolygon
-
Cmn
class RoundedPolygon
The RoundedPolygon class allows simple construction of polygonal shapes with optional rounding at the vertices. Polygons can be constructed with either the number of vertices desired or an ordered list of vertices.
Summary
Nested types |
|---|
object RoundedPolygon.Companion |
Public functions |
||
|---|---|---|
FloatArray |
calculateBounds(bounds: FloatArray, approximate: Boolean)Calculates the axis-aligned bounds of the object. |
Cmn
|
FloatArray |
calculateMaxBounds(bounds: FloatArray)Like |
Cmn
|
open operator Boolean |
Cmn
|
|
open Int |
hashCode() |
Cmn
|
RoundedPolygon |
Creates a new RoundedPolygon, moving and resizing this one, so it's completely inside the (0, 0) -> (1, 1) square, centered if there extra space in one direction |
Cmn
|
open String |
toString() |
Cmn
|
RoundedPolygon |
Transforms (scales/translates/etc.) this |
Cmn
|
Public properties |
||
|---|---|---|
Float |
Cmn
|
|
Float |
Cmn
|
|
List<Cubic> |
A flattened version of the |
Cmn
|
List<Feature> |
Cmn
|
Extension functions |
||
|---|---|---|
Path |
@ExperimentalMaterial3ExpressiveApiReturns a |
Cmn
|
Shape |
@ExperimentalMaterial3ExpressiveApiReturns a |
Cmn
|
Path |
RoundedPolygon.toPath(path: Path)Gets a |
android
|
RoundedPolygon |
RoundedPolygon.transformed(matrix: Matrix)Transforms a |
android
|
Public functions
calculateBounds
fun calculateBounds(
bounds: FloatArray = FloatArray(4),
approximate: Boolean = true
): FloatArray
Calculates the axis-aligned bounds of the object.
| Parameters | |
|---|---|
bounds: FloatArray = FloatArray(4) |
a buffer to hold the results. If not supplied, a temporary buffer will be created. |
approximate: Boolean = true |
when true, uses a faster calculation to create the bounding box based on the min/max values of all anchor and control points that make up the shape. Default value is true. |
| Returns | |
|---|---|
FloatArray |
The axis-aligned bounding box for this object, where the rectangles left, top, right, and bottom values will be stored in entries 0, 1, 2, and 3, in that order. |
calculateMaxBounds
fun calculateMaxBounds(bounds: FloatArray = FloatArray(4)): FloatArray
Like calculateBounds, this function calculates the axis-aligned bounds of the object and returns that rectangle. But this function determines the max dimension of the shape (by calculating the distance from its center to the start and midpoint of each curve) and returns a square which can be used to hold the object in any rotation. This function can be used, for example, to calculate the max size of a UI element meant to hold this shape in any rotation.
| Parameters | |
|---|---|
bounds: FloatArray = FloatArray(4) |
a buffer to hold the results. If not supplied, a temporary buffer will be created. |
| Returns | |
|---|---|
FloatArray |
The axis-aligned max bounding box for this object, where the rectangles left, top, right, and bottom values will be stored in entries 0, 1, 2, and 3, in that order. |
normalized
fun normalized(): RoundedPolygon
Creates a new RoundedPolygon, moving and resizing this one, so it's completely inside the (0, 0) -> (1, 1) square, centered if there extra space in one direction
transformed
fun transformed(f: PointTransformer): RoundedPolygon
Transforms (scales/translates/etc.) this RoundedPolygon with the given PointTransformer and returns a new RoundedPolygon. This is a low level API and there should be more platform idiomatic ways to transform a RoundedPolygon provided by the platform specific wrapper.
| Parameters | |
|---|---|
f: PointTransformer |
The |
Extension functions
toPath
@ExperimentalMaterial3ExpressiveApi
@Composable
fun RoundedPolygon.toPath(startAngle: Int = 0): Path
Returns a Path that is remembered across compositions for this RoundedPolygon.
| Parameters | |
|---|---|
startAngle: Int = 0 |
the angle (in degrees) from which to begin drawing the generated path. By default, it is set to 0 degrees, meaning the |
toShape
@ExperimentalMaterial3ExpressiveApi
@Composable
fun RoundedPolygon.toShape(startAngle: Int = 0): Shape
Returns a Shape that is remembered across compositions for this RoundedPolygon.
| Parameters | |
|---|---|
startAngle: Int = 0 |
the angle (in degrees) from which to begin drawing the generated shape's path. By default, it is set to 0 degrees, meaning the shape's path begins drawing at the 3 o'clock position. The returned path is rotated by this angle around the |
toPath
fun RoundedPolygon.toPath(path: Path = Path()): Path
Gets a Path representation for a RoundedPolygon shape. Note that there is some rounding happening (to the nearest thousandth), to work around rendering artifacts introduced by some points being just slightly off from each other (far less than a pixel). This also allows for a more optimal path, as redundant curves (usually a single point) can be detected and not added to the resulting path.
transformed
fun RoundedPolygon.transformed(matrix: Matrix): RoundedPolygon
Transforms a RoundedPolygon by the given matrix.
| Parameters | |
|---|---|
matrix: Matrix |
The matrix by which the polygon is to be transformed |