Struct bear_lib_terminal::geometry::Rect
source · pub struct Rect {
pub top_left: Point,
pub top_right: Point,
pub bottom_right: Point,
pub bottom_left: Point,
pub size: Size,
}
Expand description
A rectangle, described by its four corners and a size.
Fields
top_left: Point
The top-left corner.
top_right: Point
The top-right corner.
bottom_right: Point
The bottom-right corner.
bottom_left: Point
The bottom-left corner.
size: Size
The Rect
angle’s size.
Implementations
sourceimpl Rect
impl Rect
sourcepub fn from_size(origin: Point, size: Size) -> Rect
pub fn from_size(origin: Point, size: Size) -> Rect
Construct a Rect
from its top-left corner and its size.
Examples
let rect = Rect::from_size(Point::new(10, 20), Size::new(30, 40));
assert_eq!(rect.top_left, Point::new(10, 20));
assert_eq!(rect.top_right, Point::new(40, 20));
assert_eq!(rect.bottom_left, Point::new(10, 60));
assert_eq!(rect.bottom_right, Point::new(40, 60));
assert_eq!(rect.size, Size::new(30, 40));
sourcepub fn from_points(top_left: Point, bottom_right: Point) -> Rect
pub fn from_points(top_left: Point, bottom_right: Point) -> Rect
Construct a Rect
from its top-left and bottom-right corners.
Examples
let rect = Rect::from_points(Point::new(10, 20), Point::new(30, 40));
assert_eq!(rect.top_left, Point::new(10, 20));
assert_eq!(rect.top_right, Point::new(30, 20));
assert_eq!(rect.bottom_left, Point::new(10, 40));
assert_eq!(rect.bottom_right, Point::new(30, 40));
assert_eq!(rect.size, Size::new(20, 20));
sourcepub fn from_values(x: i32, y: i32, width: i32, height: i32) -> Rect
pub fn from_values(x: i32, y: i32, width: i32, height: i32) -> Rect
Construct a Rect
from its top-left corner and its size, values unwrapped.
Examples
assert_eq!(Rect::from_values(10, 20, 30, 40), Rect::from_size(Point::new(10, 20), Size::new(30, 40)));
sourcepub fn from_point_values(
top_left_x: i32,
top_left_y: i32,
bottom_right_x: i32,
bottom_right_y: i32
) -> Rect
pub fn from_point_values(
top_left_x: i32,
top_left_y: i32,
bottom_right_x: i32,
bottom_right_y: i32
) -> Rect
Construct a Rect
from its top-left and bottom-right corners, values unwrapped.
Examples
assert_eq!(Rect::from_point_values(10, 20, 30, 40), Rect::from_points(Point::new(10, 20), Point::new(30, 40)));
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 Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
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