[−][src]Struct cursive::Rect
A non-empty rectangle on the 2D grid.
Methods
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> From<T> for Rect where
T: Into<Vec2>,
[src]
T: Into<Vec2>,
impl Eq for Rect
[src]
impl Copy for Rect
[src]
impl PartialEq<Rect> for Rect
[src]
impl Clone for Rect
[src]
fn clone(&self) -> Rect
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl Debug for Rect
[src]
impl<T> Add<T> for Rect where
T: Into<Vec2>,
[src]
T: Into<Vec2>,
Auto Trait Implementations
Blanket Implementations
impl<T> From for T
[src]
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
impl<T, U> TryFrom 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> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,