pub struct Rect {
pub x: u16,
pub y: u16,
pub width: u16,
pub height: u16,
}Expand description
An area that a layout element takes up.
Represents a rectangular region on the screen, defined by its top-left corner (x, y) and its dimensions (width, height).
Fields§
§x: u16The X-coordinate of the top-left corner.
y: u16The Y-coordinate of the top-left corner.
width: u16The width of the rectangle.
height: u16The height of the rectangle.
Implementations§
Source§impl Rect
impl Rect
Sourcepub fn new(x: u16, y: u16, width: u16, height: u16) -> Self
pub fn new(x: u16, y: u16, width: u16, height: u16) -> Self
Creates a new Rect with the specified position and dimensions.
Sourcepub fn bottom_right(&self) -> Vec2
pub fn bottom_right(&self) -> Vec2
Returns the bottom-right corner as a Vec2.
Sourcepub fn from_corners(top_left: Vec2, bottom_right: Vec2) -> Self
pub fn from_corners(top_left: Vec2, bottom_right: Vec2) -> Self
Creates a Rect from two Vec2 points.
Sourcepub fn from_pos_size(pos: Vec2, size: Vec2) -> Self
pub fn from_pos_size(pos: Vec2, size: Vec2) -> Self
Creates a Rect from a position and size.
Sourcepub fn with_padding(&self, padding: u16) -> Self
pub fn with_padding(&self, padding: u16) -> Self
Creates a new Rect with padding applied inward.
Trait Implementations§
impl Copy for Rect
impl Eq 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