#[repr(C)]pub struct Rect {
pub x: f32,
pub y: f32,
pub w: f32,
pub h: f32,
}Expand description
Axis-aligned 2D rectangle. Width and height should be nonnegative.
Fields§
§x: f32§y: f32§w: f32§h: f32Implementations§
Source§impl Rect
impl Rect
pub const ZERO: Self
pub const fn new(x: f32, y: f32, w: f32, h: f32) -> Self
pub const fn point(self) -> Vec2
pub const fn size(self) -> Vec2
pub fn center(self) -> Vec2
pub const fn left(self) -> f32
pub const fn right(self) -> f32
pub const fn top(self) -> f32
pub const fn bottom(self) -> f32
pub fn is_finite(self) -> bool
pub fn contains(self, p: Vec2) -> bool
Sourcepub fn overlaps(self, other: &Self) -> bool
pub fn overlaps(self, other: &Self) -> bool
Positive-area overlap. Touching edges are not solid penetration.
pub fn intersect(self, other: Self) -> Option<Self>
pub fn combine_with(self, other: Self) -> Self
pub fn move_to(&mut self, p: Vec2)
pub fn offset(self, delta: Vec2) -> Self
pub fn normalized(self) -> Self
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 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