pub struct Rect {
pub position: Vec2,
pub size: Vec2,
}Expand description
Represents a rectangle/AABB with specified position and size
Fields§
§position: Vec2Position of the top-left corner of the rect.
size: Vec2Size of the rect, should not be negative.
Implementations§
Source§impl Rect
impl Rect
pub const fn new(position: Vec2, size: Vec2) -> Self
pub const fn from_position(position: Vec2) -> Self
pub const fn from_size(size: Vec2) -> Self
Sourcepub fn contains_point(&self, point: Vec2) -> bool
pub fn contains_point(&self, point: Vec2) -> bool
Check if the rect contains a point.
Sourcepub fn intersects_rect(&self, other: Rect) -> bool
pub fn intersects_rect(&self, other: Rect) -> bool
Check if the rect intersects with another rect.
Sourcepub fn width(&self) -> f32
pub fn width(&self) -> f32
Get width of the rectangle.
To get both width and height, use the size property instead.
Sourcepub fn height(&self) -> f32
pub fn height(&self) -> f32
Get height of the rectangle.
To get both width and height, use the size property instead.
Sourcepub fn x(&self) -> f32
pub fn x(&self) -> f32
Get position of the top-left corner of the rectangle on the x-axis.
To get both x and y, use the position property instead.
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