[−][src]Struct cursive::Rect
A non-empty rectangle on the 2D grid.
Implementations
impl Rect
[src]
pub fn from_size<U, V>(top_left: U, size: V) -> Self where
U: Into<Vec2>,
V: Into<Vec2>,
[src]
U: Into<Vec2>,
V: Into<Vec2>,
Creates a new Rect
with the given position and size.
The minimum size will (1, 1)
.
pub fn from_corners<U, V>(a: U, b: V) -> Self where
U: Into<Vec2>,
V: Into<Vec2>,
[src]
U: Into<Vec2>,
V: Into<Vec2>,
Creates a new Rect
from two corners.
It can be any two opposite corners.
pub fn expand_to<R>(&mut self, other: R) where
R: Into<Rect>,
[src]
R: Into<Rect>,
Grow this rectangle if necessary to include other
.
pub fn expanded_to<R>(self, other: R) -> Self where
R: Into<Rect>,
[src]
R: Into<Rect>,
Returns a new rectangle that includes both self
and other
.
pub fn offset<V>(&mut self, offset: V) where
V: Into<Vec2>,
[src]
V: Into<Vec2>,
Adds the given offset to this rectangle.
pub fn size(self) -> Vec2
[src]
Returns the size of the rectangle.
pub fn width(self) -> usize
[src]
Returns the width of the rectangle.
pub fn height(self) -> usize
[src]
Returns the height of the rectangle.
pub fn top_left(self) -> Vec2
[src]
Returns the top-left corner.
This is inclusive.
pub fn bottom_right(self) -> Vec2
[src]
Returns the bottom-right corner.
This is inclusive.
pub fn top_right(self) -> Vec2
[src]
Returns the top-right corner.
This is inclusive.
pub fn bottom_left(self) -> Vec2
[src]
Returns the bottom-left corner.
This is inclusive.
pub fn top(self) -> usize
[src]
Returns the Y value of the top edge of the rectangle.
This is inclusive.
pub fn left(self) -> usize
[src]
Returns the X value of the left edge of the rectangle.
This is inclusive.
pub fn right(self) -> usize
[src]
Returns the X value of the right edge of the rectangle.
This is inclusive.
pub fn bottom(self) -> usize
[src]
Returns the Y value of the botton edge of the rectangle.
This is inclusive.
pub fn surface(self) -> usize
[src]
Returns the surface (number of cells) covered by the rectangle.
pub fn contains(self, point: Vec2) -> bool
[src]
Checks if a point is in self
.
Trait Implementations
impl<T> Add<T> for Rect where
T: Into<Vec2>,
[src]
T: Into<Vec2>,
type Output = Rect
The resulting type after applying the +
operator.
fn add(self, rhs: T) -> Self
[src]
impl Clone for Rect
[src]
impl Copy for Rect
[src]
impl Debug for Rect
[src]
impl Eq for Rect
[src]
impl<T> From<T> for Rect where
T: Into<Vec2>,
[src]
T: Into<Vec2>,
impl PartialEq<Rect> for Rect
[src]
impl StructuralEq for Rect
[src]
impl StructuralPartialEq for Rect
[src]
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
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Erased for T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,