Struct cursive_core::Rect
source · [−]pub struct Rect { /* private fields */ }
Expand description
A non-empty rectangle on the 2D grid.
Implementations
sourceimpl Rect
impl Rect
sourcepub fn from_point<T>(point: T) -> Self where
T: Into<Vec2>,
pub fn from_point<T>(point: T) -> Self where
T: Into<Vec2>,
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 where
U: Into<Vec2>,
V: Into<Vec2>,
pub fn from_size<U, V>(top_left: U, size: V) -> Self where
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) -> Self where
U: Into<Vec2>,
V: Into<Vec2>,
pub fn from_corners<U, V>(a: U, b: V) -> Self where
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) -> Self where
R: Into<Rect>,
pub fn expanded_to<R>(self, other: R) -> Self where
R: Into<Rect>,
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 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 T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
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
sourceimpl<T> CallHasher for T where
T: Hash + ?Sized,
impl<T> CallHasher for T where
T: Hash + ?Sized,
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more