Skip to main content

RRect

Struct RRect 

Source
pub struct RRect {
    pub left: f64,
    pub top: f64,
    pub right: f64,
    pub bottom: f64,
    pub tl_radius_x: f64,
    pub tl_radius_y: f64,
    pub tr_radius_x: f64,
    pub tr_radius_y: f64,
    pub br_radius_x: f64,
    pub br_radius_y: f64,
    pub bl_radius_x: f64,
    pub bl_radius_y: f64,
}
Expand description

An immutable rounded rectangle with the custom radii for all four corners.

Fields§

§left: f64

The offset of the left edge of this rectangle from the x axis.

§top: f64

The offset of the top edge of this rectangle from the y axis.

§right: f64

The offset of the right edge of this rectangle from the x axis.

§bottom: f64

The offset of the bottom edge of this rectangle from the y axis.

§tl_radius_x: f64

The top-left horizontal radius.

§tl_radius_y: f64

The top-left vertical radius.

§tr_radius_x: f64

The top-right horizontal radius.

§tr_radius_y: f64

The top-right vertical radius.

§br_radius_x: f64

The bottom-right horizontal radius.

§br_radius_y: f64

The bottom-right vertical radius.

§bl_radius_x: f64

The bottom-left horizontal radius.

§bl_radius_y: f64

The bottom-left vertical radius.

Implementations§

Source§

impl RRect

Source

pub const ZERO: RRect

All values set to zero.

Source

pub fn from_ltrbxy( left: f64, top: f64, right: f64, bottom: f64, radius_x: f64, radius_y: f64, ) -> RRect

Construct from left, top, right, bottom, and the same radii along the horizontal axis and the vertical axis.

Source

pub fn from_ltrbr( left: f64, top: f64, right: f64, bottom: f64, radius: Radius, ) -> RRect

Construct from left, top, right, bottom, and the same radius in each corner.

Source

pub fn from_rect_xy(rect: Rect, radius_x: f64, radius_y: f64) -> RRect

Construct from a bounding box and the same radii along each axis.

Source

pub fn from_rect_and_radius(rect: Rect, radius: Radius) -> RRect

Construct from a bounding box and a radius that is the same in each corner.

Source

pub fn from_ltrb_and_corners( left: f64, top: f64, right: f64, bottom: f64, top_left: Radius, top_right: Radius, bottom_right: Radius, bottom_left: Radius, ) -> RRect

Construct from left, top, right, bottom, and per-corner radii.

Source

pub fn from_rect_and_corners( rect: Rect, top_left: Radius, top_right: Radius, bottom_right: Radius, bottom_left: Radius, ) -> RRect

Construct from a bounding box and per-corner radii.

Source

pub fn tl_radius(self) -> Radius

The top-left Radius.

Source

pub fn tr_radius(self) -> Radius

The top-right Radius.

Source

pub fn br_radius(self) -> Radius

The bottom-right Radius.

Source

pub fn bl_radius(self) -> Radius

The bottom-left Radius.

Source

pub fn shift(self, offset: Offset) -> RRect

Returns a clone translated by the given offset.

Source

pub fn inflate(self, delta: f64) -> RRect

Returns a clone with edges and radii moved outwards by delta.

Source

pub fn deflate(self, delta: f64) -> RRect

Returns a clone with edges and radii moved inwards by delta.

Source

pub fn width(self) -> f64

The distance between the left and right edges.

Source

pub fn height(self) -> f64

The distance between the top and bottom edges.

Source

pub fn outer_rect(self) -> Rect

The bounding box of this rounded rectangle.

Source

pub fn safe_inner_rect(self) -> Rect

The non-rounded rectangle constrained by the smaller of the two diagonals through the middle of the curve corners.

Source

pub fn middle_rect(self) -> Rect

The rectangle formed from the inner-most centers of the corner ellipses.

Source

pub fn wide_middle_rect(self) -> Rect

The biggest rectangle entirely inside with the full width.

Source

pub fn tall_middle_rect(self) -> Rect

The biggest rectangle entirely inside with the full height.

Source

pub fn is_empty(self) -> bool

Whether this rounded rectangle encloses a non-zero area.

Source

pub fn is_finite(self) -> bool

Whether all coordinates are finite.

Source

pub fn is_rect(self) -> bool

Whether this is a simple rectangle with zero corner radii.

Source

pub fn is_stadium(self) -> bool

Whether this rounded rectangle has a side with no straight section.

Source

pub fn is_ellipse(self) -> bool

Whether this rounded rectangle has no side with a straight section.

Source

pub fn is_circle(self) -> bool

Whether this rounded rectangle would draw as a circle.

Source

pub fn shortest_side(self) -> f64

The lesser of the magnitudes of the width and the height.

Source

pub fn longest_side(self) -> f64

The greater of the magnitudes of the width and the height.

Source

pub fn has_nan(self) -> bool

Whether any of the dimensions are NaN.

Source

pub fn center(self) -> Offset

The offset halfway between the left and right and the top and bottom edges.

Source

pub fn scale_radii(self) -> RRect

Scales all radii so that on each side their sum will not exceed the width or height.

Source

pub fn lerp(a: Option<RRect>, b: Option<RRect>, t: f64) -> Option<RRect>

Linearly interpolate between two rounded rectangles.

If either is null, this function substitutes ZERO.

Source§

impl RRect

Source

pub fn contains(self, point: Offset) -> bool

Whether the point specified by the given offset (which is assumed to be relative to the origin) lies inside the rounded rectangle.

Trait Implementations§

Source§

impl Clone for RRect

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for RRect

Source§

impl Debug for RRect

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for RRect

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for RRect

Auto Trait Implementations§

§

impl Freeze for RRect

§

impl RefUnwindSafe for RRect

§

impl Send for RRect

§

impl Sync for RRect

§

impl Unpin for RRect

§

impl UnsafeUnpin for RRect

§

impl UnwindSafe for RRect

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,