RoundedPolygonKt
public final class RoundedPolygonKt
Summary
Public methods |
|
|---|---|
static final @NonNull RoundedPolygon |
RoundedPolygon(@NonNull RoundedPolygon source)Creates a copy of the given |
static final @NonNull RoundedPolygon |
RoundedPolygon(This constructor takes a list of |
static final @NonNull RoundedPolygon |
RoundedPolygon(This function takes the vertices (either supplied or calculated, depending on the constructor called), plus |
static final @NonNull RoundedPolygon |
RoundedPolygon(This constructor takes the number of vertices in the resulting polygon. |
Public methods
RoundedPolygon
public static final @NonNull RoundedPolygon RoundedPolygon(@NonNull RoundedPolygon source)
Creates a copy of the given RoundedPolygon
RoundedPolygon
public static final @NonNull RoundedPolygon RoundedPolygon(
@NonNull List<@NonNull Feature> features,
float centerX,
float centerY
)
This constructor takes a list of Feature objects that define the polygon's shape and curves. By specifying the features directly, the summarization of Cubic objects to curves can be precisely controlled. This affects Morph's default mapping, as curves with the same type (convex or concave) are mapped with each other. For example, if you have a convex curve in your start polygon, Morph will map it to another convex curve in the end polygon.
The centerX and centerY parameters are optional. If not supplied, they will be estimated by calculating the average of all cubic anchor points.
| Parameters | |
|---|---|
@NonNull List<@NonNull Feature> features |
The |
float centerX |
The X coordinate of the center of the polygon, around which all vertices will be placed. If none provided, the center will be averaged. |
float centerY |
The Y coordinate of the center of the polygon, around which all vertices will be placed. If none provided, the center will be averaged. |
| Throws | |
|---|---|
IllegalArgumentException |
|
RoundedPolygon
public static final @NonNull RoundedPolygon RoundedPolygon(
@NonNull float[] vertices,
@NonNull CornerRounding rounding,
List<@NonNull CornerRounding> perVertexRounding,
float centerX,
float centerY
)
This function takes the vertices (either supplied or calculated, depending on the constructor called), plus CornerRounding parameters, and creates the actual RoundedPolygon shape, rounding around the vertices (or not) as specified. The result is a list of Cubic curves which represent the geometry of the final shape.
| Parameters | |
|---|---|
@NonNull float[] vertices |
The list of vertices in this polygon specified as pairs of x/y coordinates in this FloatArray. This should be an ordered list (with the outline of the shape going from each vertex to the next in order of this list), otherwise the results will be undefined. |
@NonNull CornerRounding rounding |
The |
List<@NonNull CornerRounding> perVertexRounding |
The |
float centerX |
The X coordinate of the center of the polygon, around which all vertices will be placed. The default center is at (0,0). |
float centerY |
The Y coordinate of the center of the polygon, around which all vertices will be placed. The default center is at (0,0). |
| Throws | |
|---|---|
IllegalArgumentException |
if the number of vertices is less than 3 (the |
RoundedPolygon
public static final @NonNull RoundedPolygon RoundedPolygon(
@IntRange(from = 3) int numVertices,
float radius,
float centerX,
float centerY,
@NonNull CornerRounding rounding,
List<@NonNull CornerRounding> perVertexRounding
)
This constructor takes the number of vertices in the resulting polygon. These vertices are positioned on a virtual circle around a given center with each vertex positioned radius distance from that center, equally spaced (with equal angles between them). If no radius is supplied, the shape will be created with a default radius of 1, resulting in a shape whose vertices lie on a unit circle, with width/height of 2. That default polygon will probably need to be rescaled using transformed into the appropriate size for the UI in which it will be drawn.
The rounding and perVertexRounding parameters are optional. If not supplied, the result will be a regular polygon with straight edges and unrounded corners.
| Parameters | |
|---|---|
@IntRange(from = 3) int numVertices |
The number of vertices in this polygon. |
float radius |
The radius of the polygon, in pixels. This radius determines the initial size of the object, but it can be transformed later by using the |
float centerX |
The X coordinate of the center of the polygon, around which all vertices will be placed. The default center is at (0,0). |
float centerY |
The Y coordinate of the center of the polygon, around which all vertices will be placed. The default center is at (0,0). |
@NonNull CornerRounding rounding |
The |
List<@NonNull CornerRounding> perVertexRounding |
The |
| Throws | |
|---|---|
IllegalArgumentException |
If |
IllegalArgumentException |
|