[][src]Struct bear_lib_terminal::geometry::Rect

pub struct Rect {
    pub top_left: Point,
    pub top_right: Point,
    pub bottom_right: Point,
    pub bottom_left: Point,
    pub size: Size,
}

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 Rectangle's size.

Methods

impl Rect[src]

pub fn from_size(origin: Point, size: Size) -> Rect[src]

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));

pub fn from_points(top_left: Point, bottom_right: Point) -> Rect[src]

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));

pub fn from_values(x: i32, y: i32, width: i32, height: i32) -> Rect[src]

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)));

pub fn from_point_values(
    top_left_x: i32,
    top_left_y: i32,
    bottom_right_x: i32,
    bottom_right_y: i32
) -> Rect
[src]

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 Clone for Rect[src]

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl Copy for Rect[src]

impl Eq for Rect[src]

impl PartialEq<Rect> for Rect[src]

impl Debug for Rect[src]

impl Hash for Rect[src]

fn hash_slice<H>(data: &[Self], state: &mut H) where
    H: Hasher
1.3.0[src]

Feeds a slice of this type into the given [Hasher]. Read more

Auto Trait Implementations

impl Send for Rect

impl Sync for Rect

Blanket Implementations

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]