pub struct RoundedPolygon { /* private fields */ }Expand description
A closed outline of cubic curves built from vertices with optional
rounding. See androidx.graphics.shapes.RoundedPolygon.
Implementations§
Source§impl RoundedPolygon
impl RoundedPolygon
Sourcepub fn from_vertices(
vertices: &[(f32, f32)],
rounding: CornerRounding,
per_vertex: Option<&[CornerRounding]>,
center: Option<(f32, f32)>,
) -> Option<Self>
pub fn from_vertices( vertices: &[(f32, f32)], rounding: CornerRounding, per_vertex: Option<&[CornerRounding]>, center: Option<(f32, f32)>, ) -> Option<Self>
A polygon through vertices, each rounded by rounding or, when
given, by its entry in per_vertex. center defaults to the
vertices’ average.
None with fewer than three vertices, a non-finite coordinate, or a
per_vertex of the wrong length.
Sourcepub fn regular(
sides: usize,
radius: f32,
center: (f32, f32),
rounding: CornerRounding,
per_vertex: Option<&[CornerRounding]>,
) -> Option<Self>
pub fn regular( sides: usize, radius: f32, center: (f32, f32), rounding: CornerRounding, per_vertex: Option<&[CornerRounding]>, ) -> Option<Self>
A regular polygon of sides (at least 3) vertices on a circle of
radius, the first at three o’clock.
Sourcepub fn circle(sides: usize, radius: f32, center: (f32, f32)) -> Option<Self>
pub fn circle(sides: usize, radius: f32, center: (f32, f32)) -> Option<Self>
A circle of radius, made by fully rounding sides (at least 3)
vertices.
Sourcepub fn rectangle(
width: f32,
height: f32,
rounding: CornerRounding,
per_vertex: Option<&[CornerRounding]>,
center: (f32, f32),
) -> Option<Self>
pub fn rectangle( width: f32, height: f32, rounding: CornerRounding, per_vertex: Option<&[CornerRounding]>, center: (f32, f32), ) -> Option<Self>
A width by height rectangle. Vertices run bottom right, bottom
left, top left, top right.
Sourcepub fn star(
points: usize,
radius: f32,
inner_radius: f32,
rounding: CornerRounding,
inner_rounding: Option<CornerRounding>,
center: (f32, f32),
) -> Option<Self>
pub fn star( points: usize, radius: f32, inner_radius: f32, rounding: CornerRounding, inner_rounding: Option<CornerRounding>, center: (f32, f32), ) -> Option<Self>
A star of points (at least 2) alternating between radius and
inner_radius, which must be positive and smaller. inner_rounding
defaults to rounding.
Sourcepub fn pill(
width: f32,
height: f32,
smoothing: f32,
center: (f32, f32),
) -> Option<Self>
pub fn pill( width: f32, height: f32, smoothing: f32, center: (f32, f32), ) -> Option<Self>
A capsule: a width by height rectangle whose short ends round
fully, with smoothing on the corners.
Sourcepub fn transformed(&self, f: impl Fn(f32, f32) -> (f32, f32)) -> Self
pub fn transformed(&self, f: impl Fn(f32, f32) -> (f32, f32)) -> Self
This polygon with f applied to every point. Corners keep their
convexity.
Sourcepub fn normalized(&self) -> Self
pub fn normalized(&self) -> Self
This polygon moved and scaled so its Self::bounds are centered in
a 0-1 box, which the longer side fills.
Sourcepub fn bounds(&self, approximate: bool) -> [f32; 4]
pub fn bounds(&self, approximate: bool) -> [f32; 4]
The outline’s [left, top, right, bottom]: tight, or, when
approximate, the box of all anchors and control points.
As in the source, the result’s right and bottom start from the smallest positive float, so a polygon wholly in negative coordinates reports them just above zero.
Sourcepub fn max_bounds(&self) -> [f32; 4]
pub fn max_bounds(&self) -> [f32; 4]
The square around Self::center that holds the outline at any
rotation, as [left, top, right, bottom].
Trait Implementations§
Source§impl Clone for RoundedPolygon
impl Clone for RoundedPolygon
Source§fn clone(&self) -> RoundedPolygon
fn clone(&self) -> RoundedPolygon
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for RoundedPolygon
impl RefUnwindSafe for RoundedPolygon
impl Send for RoundedPolygon
impl Sync for RoundedPolygon
impl Unpin for RoundedPolygon
impl UnsafeUnpin for RoundedPolygon
impl UnwindSafe for RoundedPolygon
Blanket Implementations§
impl<T> AutoreleaseSafe for Twhere
T: ?Sized,
impl<T> AutoreleaseSafe for Twhere
T: ?Sized,
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> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> 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