pub struct Rect { /* private fields */ }
Expand description
A non-empty rectangle on the 2D grid.
Implementations
sourceimpl Rect
impl Rect
sourcepub fn from_size<U, V>(top_left: U, size: V) -> Selfwhere
U: Into<Vec2>,
V: Into<Vec2>,
pub fn from_size<U, V>(top_left: U, size: V) -> Selfwhere
U: Into<Vec2>,
V: Into<Vec2>,
Creates a new Rect
with the given position and size.
The minimum size will (1, 1)
.
sourcepub fn from_corners<U, V>(a: U, b: V) -> Selfwhere
U: Into<Vec2>,
V: Into<Vec2>,
pub fn from_corners<U, V>(a: U, b: V) -> Selfwhere
U: Into<Vec2>,
V: Into<Vec2>,
Creates a new Rect
from two corners.
It can be any two opposite corners.
sourcepub fn expand_to<R>(&mut self, other: R)where
R: Into<Rect>,
pub fn expand_to<R>(&mut self, other: R)where
R: Into<Rect>,
Grow this rectangle if necessary to include other
.
sourcepub fn expanded_to<R>(self, other: R) -> Selfwhere
R: Into<Rect>,
pub fn expanded_to<R>(self, other: R) -> Selfwhere
R: Into<Rect>,
Returns a new rectangle that includes both self
and other
.
sourcepub fn offset<V>(&mut self, offset: V)where
V: Into<Vec2>,
pub fn offset<V>(&mut self, offset: V)where
V: Into<Vec2>,
Adds the given offset to this rectangle.
sourcepub fn bottom_right(self) -> Vec2
pub fn bottom_right(self) -> Vec2
Returns the bottom-right corner.
This is inclusive.
sourcepub fn bottom_left(self) -> Vec2
pub fn bottom_left(self) -> Vec2
Returns the bottom-left corner.
This is inclusive.
sourcepub fn top(self) -> usize
pub fn top(self) -> usize
Returns the Y value of the top edge of the rectangle.
This is inclusive.
sourcepub fn left(self) -> usize
pub fn left(self) -> usize
Returns the X value of the left edge of the rectangle.
This is inclusive.
sourcepub fn right(self) -> usize
pub fn right(self) -> usize
Returns the X value of the right edge of the rectangle.
This is inclusive.
Trait Implementations
impl Copy for Rect
impl Eq for Rect
impl StructuralEq for Rect
impl StructuralPartialEq for Rect
Auto Trait Implementations
impl RefUnwindSafe for Rect
impl Send for Rect
impl Sync for Rect
impl Unpin for Rect
impl UnwindSafe for Rect
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more