pub struct Rect {
pub x: f32,
pub y: f32,
pub width: f32,
pub height: f32,
}Expand description
Axis-aligned rectangle in logical UI coordinates.
Fields§
§x: f32§y: f32§width: f32§height: f32Implementations§
Source§impl Rect
impl Rect
pub const ZERO: Self
pub const fn new(x: f32, y: f32, width: f32, height: f32) -> Self
pub fn right(self) -> f32
pub fn bottom(self) -> f32
Sourcepub fn translate(self, delta: Vec2) -> Self
pub fn translate(self, delta: Vec2) -> Self
Returns this rectangle offset by the provided delta.
pub fn is_empty(self) -> bool
Sourcepub fn is_finite(self) -> bool
pub fn is_finite(self) -> bool
Returns true when coordinates, dimensions, and derived edges are finite numbers.
pub fn inset(self, inset: Insets) -> Self
pub fn contains(self, x: f32, y: f32) -> bool
Sourcepub fn intersection(self, other: Self) -> Option<Self>
pub fn intersection(self, other: Self) -> Option<Self>
Returns the overlapping region, or None when the rectangles do not overlap.
Sourcepub fn union(self, other: Self) -> Self
pub fn union(self, other: Self) -> Self
Returns the smallest rectangle that contains both rectangles.
Sourcepub fn clamp_within(self, bounds: Self) -> Self
pub fn clamp_within(self, bounds: Self) -> Self
Returns a rectangle moved and shrunk as needed to fit inside bounds.
Trait Implementations§
impl Copy for Rect
Source§impl<'de> Deserialize<'de> for Rect
impl<'de> Deserialize<'de> for Rect
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
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