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

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]

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

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

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

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

fn eq(&self, __arg_0: &Rect) -> bool

This method tests for self and other values to be equal, and is used by ==. Read more

fn ne(&self, __arg_0: &Rect) -> bool

This method tests for !=.

impl Hash for Rect
[src]

fn hash<__H: Hasher>(&self, __arg_0: &mut __H)

Feeds this value into the state given, updating the hasher as necessary.

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

Feeds a slice of this type into the state provided.

impl Eq for Rect
[src]

impl Debug for Rect
[src]

fn fmt(&self, __arg_0: &mut Formatter) -> Result

Formats the value using the given formatter.

impl Copy for Rect
[src]

impl Clone for Rect
[src]

fn clone(&self) -> Rect

Returns a copy of the value. Read more

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

Performs copy-assignment from source. Read more