pub struct CornerRadii {
pub top_left: f64,
pub top_right: f64,
pub bottom_right: f64,
pub bottom_left: f64,
}Expand description
A radius for each corner of a rectangle, clockwise from the top left (docs/canvas.md “Rounded corners”). The shape a bar in a chart wants (rounded at its value end, square against its axis), a tab (rounded on top), or a card joined to its neighbor.
Radii are in points and never negative. CornerRadii::fitted shrinks them the way CSS
does when two radii on one side would overlap, which is what a caller animating a radius or
drawing a short bar needs to not think about.
Fields§
§top_left: f64§top_right: f64§bottom_right: f64§bottom_left: f64Implementations§
Source§impl CornerRadii
impl CornerRadii
Sourcepub fn uniform(r: f64) -> CornerRadii
pub fn uniform(r: f64) -> CornerRadii
The same radius on every corner: what Shape::RoundedRect draws.
Sourcepub fn top(r: f64) -> CornerRadii
pub fn top(r: f64) -> CornerRadii
Rounded along the top edge, square along the bottom: a bar standing on its axis.
Sourcepub fn bottom(r: f64) -> CornerRadii
pub fn bottom(r: f64) -> CornerRadii
Rounded along the bottom edge: a bar hanging below its axis.
Sourcepub fn left(r: f64) -> CornerRadii
pub fn left(r: f64) -> CornerRadii
Rounded along the left edge: a bar growing leftward from its axis.
Sourcepub fn right(r: f64) -> CornerRadii
pub fn right(r: f64) -> CornerRadii
Rounded along the right edge: a bar growing rightward from its axis.
Sourcepub fn is_uniform(self) -> bool
pub fn is_uniform(self) -> bool
Whether every corner has the same radius, so the rectangle is a Shape::RoundedRect.
Sourcepub fn fitted(self, size: Size) -> CornerRadii
pub fn fitted(self, size: Size) -> CornerRadii
These radii made to fit a size rectangle, the rule CSS uses for border-radius: a
negative or non-finite radius is square, and when the two radii along any side add up to
more than that side, every radius is scaled down by the same factor until none overlap.
Scaling all four together keeps the corners in proportion, where clamping each one alone
would turn a pill into a lopsided shape.
Trait Implementations§
Source§impl Clone for CornerRadii
impl Clone for CornerRadii
Source§fn clone(&self) -> CornerRadii
fn clone(&self) -> CornerRadii
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for CornerRadii
Source§impl Debug for CornerRadii
impl Debug for CornerRadii
Source§impl Default for CornerRadii
impl Default for CornerRadii
Source§fn default() -> CornerRadii
fn default() -> CornerRadii
Source§impl PartialEq for CornerRadii
impl PartialEq for CornerRadii
impl StructuralPartialEq for CornerRadii
Auto Trait Implementations§
impl Freeze for CornerRadii
impl RefUnwindSafe for CornerRadii
impl Send for CornerRadii
impl Sync for CornerRadii
impl Unpin for CornerRadii
impl UnsafeUnpin for CornerRadii
impl UnwindSafe for CornerRadii
Blanket Implementations§
§impl<T> AnyEq for T
impl<T> AnyEq for T
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
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> 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