pub struct Rect { /* private fields */ }Expand description
A non-empty rectangle on the 2D grid.
Implementations§
Source§impl Rect
impl Rect
Sourcepub fn from_point<T>(point: T) -> Self
pub fn from_point<T>(point: T) -> Self
Creates a new Rect around a single point.
The size will be (1, 1).
Sourcepub fn from_size<U, V>(top_left: U, size: V) -> Self
pub fn from_size<U, V>(top_left: U, size: V) -> Self
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) -> Self
pub fn from_corners<U, V>(a: U, b: V) -> Self
Creates a new Rect from two corners.
It can be any two opposite corners.
Sourcepub fn expanded_to<R>(self, other: R) -> Self
pub fn expanded_to<R>(self, other: R) -> Self
Returns a new rectangle that includes both self and other.
Sourcepub fn side(self, orientation: Orientation) -> (usize, usize)
pub fn side(self, orientation: Orientation) -> (usize, usize)
Returns the start and end coordinate of one side of this rectangle.
Both start and end are inclusive.
Sourcepub fn edge(self, side: Absolute) -> usize
pub fn edge(self, side: Absolute) -> usize
Returns the coordinate of the given edge.
All edges are inclusive.
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§
Source§impl Resolvable for Rect
impl Resolvable for Rect
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.