pub struct Rect {
pub x: f64,
pub y: f64,
pub width: f64,
pub height: f64,
}Expand description
An axis-aligned rectangle.
Fields§
§x: f64§y: f64§width: f64§height: f64Implementations§
Source§impl Rect
impl Rect
pub const ZERO: Rect
pub const fn new(x: f64, y: f64, width: f64, height: f64) -> Self
pub fn from_points(origin: Point, size: Size) -> Self
Sourcepub fn between(a: Point, b: Point) -> Self
pub fn between(a: Point, b: Point) -> Self
The rectangle two corners describe, in any order — a marquee, a selection bounds, a drag rectangle.
pub fn origin(&self) -> Point
pub fn size(&self) -> Size
pub fn center(&self) -> Point
pub fn max_x(&self) -> f64
pub fn max_y(&self) -> f64
pub fn union(&self, other: &Rect) -> Rect
pub fn contains(&self, p: Point) -> bool
Sourcepub fn intersects(&self, other: Rect) -> bool
pub fn intersects(&self, other: Rect) -> bool
Whether the rectangles touch or overlap (touching counts).
Sourcepub fn expanded(&self, by: f64) -> Rect
pub fn expanded(&self, by: f64) -> Rect
The same rectangle with by of room added on every side.
Sourcepub fn distance_to_edge(&self, point: Point) -> f64
pub fn distance_to_edge(&self, point: Point) -> f64
How far a point is from this rectangle’s outline: negative inside, positive outside, zero exactly on it.
A band around the outline is then one comparison rather than four, and it can straddle the line — which is what a border a person can grab has to do, because the line they are aiming at has no thickness.
Sourcepub fn bounds(rects: impl IntoIterator<Item = Self>) -> Option<Self>
pub fn bounds(rects: impl IntoIterator<Item = Self>) -> Option<Self>
The rectangle covering all of rects, or None when there are none.
Trait Implementations§
impl Copy for Rect
impl StructuralPartialEq for Rect
Auto Trait Implementations§
impl Freeze for Rect
impl RefUnwindSafe for Rect
impl Send for Rect
impl Sync for Rect
impl Unpin for Rect
impl UnsafeUnpin for Rect
impl UnwindSafe for Rect
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DependencyElement for T
Source§impl<T> InitializeFromFunction<T> for T
impl<T> InitializeFromFunction<T> for T
Source§fn initialize_from_function(f: fn() -> T) -> T
fn initialize_from_function(f: fn() -> T) -> T
Create an instance of this type from an initialization function
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<Ret> SpawnIfAsync<(), Ret> for Ret
impl<Ret> SpawnIfAsync<(), Ret> for Ret
Source§impl<T, O> SuperFrom<T> for Owhere
O: From<T>,
impl<T, O> SuperFrom<T> for Owhere
O: From<T>,
Source§fn super_from(input: T) -> O
fn super_from(input: T) -> O
Convert from a type to another type.
Source§impl<T, O, M> SuperInto<O, M> for Twhere
O: SuperFrom<T, M>,
impl<T, O, M> SuperInto<O, M> for Twhere
O: SuperFrom<T, M>,
Source§fn super_into(self) -> O
fn super_into(self) -> O
Convert from a type to another type.