pub struct ShapePolygon { /* private fields */ }Expand description
A reusable normalized polygon contour backed by polymorpher.
Third-party polygon types stay inside Foundation so components and applications share one shape pipeline across Expressive presets, rounded rectangles, custom polygons, and morph transitions.
Implementations§
Source§impl ShapePolygon
impl ShapePolygon
Sourcepub fn material(shape: MaterialShape) -> ShapePolygon
pub fn material(shape: MaterialShape) -> ShapePolygon
Constructs one of the 35 Material 3 Expressive shapes matching Compose MaterialShapes.
Sourcepub fn circle(vertices: usize) -> Option<ShapePolygon>
pub fn circle(vertices: usize) -> Option<ShapePolygon>
Constructs a regular rounded circle polygon with at least three vertices.
Sourcepub fn regular(
vertices: usize,
rounding: f32,
smoothing: f32,
rotation_degrees: f32,
) -> Option<ShapePolygon>
pub fn regular( vertices: usize, rounding: f32, smoothing: f32, rotation_degrees: f32, ) -> Option<ShapePolygon>
Constructs a regular polygon with optional corner rounding, smoothing, and rotation.
Sourcepub fn star(
vertices: usize,
inner_radius: f32,
rounding: f32,
smoothing: f32,
inner_rounding: Option<(f32, f32)>,
) -> Option<ShapePolygon>
pub fn star( vertices: usize, inner_radius: f32, rounding: f32, smoothing: f32, inner_rounding: Option<(f32, f32)>, ) -> Option<ShapePolygon>
Constructs a star polygon with outer radius 1.0, inner_radius in (0, 1),
outer corner rounding, and optional inner corner rounding (radius, smoothing).
Sourcepub fn rounded_rect(
width: f32,
height: f32,
corners: CornerShape,
direction: Direction,
) -> Option<ShapePolygon>
pub fn rounded_rect( width: f32, height: f32, corners: CornerShape, direction: Direction, ) -> Option<ShapePolygon>
Constructs a rounded rectangle mapped to the full unit square [0, 1] x [0, 1]
for use with ShapeFit::Stretch against matching (width, height) bounds.
When rendered into matching bounds with ShapeFit::Stretch, this reproduces
Shape::rounded and allows morphing between CornerShape and MaterialShape.
Sourcepub fn from_vertices(
vertices: &[Point<f32>],
radius: f32,
) -> Option<ShapePolygon>
pub fn from_vertices( vertices: &[Point<f32>], radius: f32, ) -> Option<ShapePolygon>
Creates a normalized rounded polygon from perimeter vertices in either winding order.
The radius uses the same units as the vertices. Non-finite, degenerate, or
self-intersecting geometry returns None.
Sourcepub fn rotated(&self, degrees: f32) -> ShapePolygon
pub fn rotated(&self, degrees: f32) -> ShapePolygon
Returns a copy rotated clockwise by degrees around its center and re-normalized.
Sourcepub fn rotation_scale(&self) -> f32
pub fn rotation_scale(&self) -> f32
Scale factor that keeps this polygon inside its unit bounds under arbitrary rotation.
Matches Compose’s LoadingIndicator rotation-envelope calculation, comparing the
polygon’s bounds against the furthest sampled anchor or cubic midpoint from center.
Sourcepub fn to_shape(&self, bounds: Bounds<Pixels>) -> Option<Shape>
pub fn to_shape(&self, bounds: Bounds<Pixels>) -> Option<Shape>
Projects this polygon into bounds using ShapeFit::Contain.
Sourcepub fn to_shape_with(
&self,
bounds: Bounds<Pixels>,
fit: ShapeFit,
rotation_radians: f32,
) -> Option<Shape>
pub fn to_shape_with( &self, bounds: Bounds<Pixels>, fit: ShapeFit, rotation_radians: f32, ) -> Option<Shape>
Projects this polygon into bounds with explicit fit mode and clockwise rotation in radians.
Sourcepub fn cubic_count(&self) -> usize
pub fn cubic_count(&self) -> usize
Returns the number of cubic Bézier segments in this normalized contour.
Trait Implementations§
Source§impl Clone for ShapePolygon
impl Clone for ShapePolygon
Source§fn clone(&self) -> ShapePolygon
fn clone(&self) -> ShapePolygon
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ShapePolygon
impl Debug for ShapePolygon
Source§impl From<MaterialShape> for ShapePolygon
impl From<MaterialShape> for ShapePolygon
Source§fn from(shape: MaterialShape) -> ShapePolygon
fn from(shape: MaterialShape) -> ShapePolygon
Source§impl From<PolygonRole> for ShapePolygon
impl From<PolygonRole> for ShapePolygon
Source§fn from(role: PolygonRole) -> ShapePolygon
fn from(role: PolygonRole) -> ShapePolygon
Source§impl From<ShapePolygon> for LoadingIndicatorShape
impl From<ShapePolygon> for LoadingIndicatorShape
Source§fn from(polygon: ShapePolygon) -> LoadingIndicatorShape
fn from(polygon: ShapePolygon) -> LoadingIndicatorShape
Source§impl PartialEq for ShapePolygon
impl PartialEq for ShapePolygon
impl StructuralPartialEq for ShapePolygon
Auto Trait Implementations§
impl Forget for ShapePolygon
impl Freeze for ShapePolygon
impl Move for ShapePolygon
impl RefUnwindSafe for ShapePolygon
impl Send for ShapePolygon
impl Sync for ShapePolygon
impl Unpin for ShapePolygon
impl UnsafeUnpin for ShapePolygon
impl UnwindSafe for ShapePolygon
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more