Struct cursive_core::Rect
source · 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) -> Selfwhere
T: Into<Vec2>,
pub fn from_point<T>(point: T) -> Selfwhere
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) -> 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 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.