pub struct Rect {
pub x: u32,
pub y: u32,
pub w: u32,
pub h: u32,
}Expand description
Defines a rectangle in pixels with the origin at the top-left of the texture atlas.
Fields§
§x: u32Horizontal position the rectangle begins at.
y: u32Vertical position the rectangle begins at.
w: u32Width of the rectangle.
h: u32Height of the rectangle.
Implementations§
Source§impl Rect
impl Rect
Sourcepub fn new(x: u32, y: u32, w: u32, h: u32) -> Rect
pub fn new(x: u32, y: u32, w: u32, h: u32) -> Rect
Create a new Rect based on a position and its width and height.
Sourcepub fn new_with_points(x1: u32, y1: u32, x2: u32, y2: u32) -> Rect
pub fn new_with_points(x1: u32, y1: u32, x2: u32, y2: u32) -> Rect
Create a new Rect based on two points spanning the rectangle.
Sourcepub fn intersects(&self, other: &Rect) -> bool
pub fn intersects(&self, other: &Rect) -> bool
Check if this rectangle intersects with another.
Sourcepub fn contains_point(&self, x: u32, y: u32) -> bool
pub fn contains_point(&self, x: u32, y: u32) -> bool
Check if this rectangle contains a point. Includes the edges of the rectangle.
Sourcepub fn is_outline(&self, x: u32, y: u32) -> bool
pub fn is_outline(&self, x: u32, y: u32) -> bool
Check if a point falls on the rectangle’s boundaries.
Trait Implementations§
impl Copy 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