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) -> Self
pub fn uniform(r: f64) -> Self
The same radius on every corner: what Shape::RoundedRect draws.
Sourcepub fn top(r: f64) -> Self
pub fn top(r: f64) -> Self
Rounded along the top edge, square along the bottom: a bar standing on its axis.
Sourcepub fn right(r: f64) -> Self
pub fn right(r: f64) -> Self
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) -> Self
pub fn fitted(self, size: Size) -> Self
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 more