Struct shapes::Rect [] [src]

pub struct Rect {
    pub pos: Point,
    pub size: Size,
}

A rectangle.

Fields

pos: Point

The position of the top left corner of the rectangle.

size: Size

The width and height of the rectangle.

Methods

impl Rect
[src]

fn bottom(&self) -> Scalar

Returns the position of the bottom side of the rectangle.

fn centered(self) -> Rect

Computes a rectangle with quadruple the surface area of self and with center (self.x, self.y).

fn contains<T: Into<Point>>(&self, point: T) -> bool

Compute whether or not the point is inside the rectangle.

fn new_circle<T: Into<Point>>(center: T, radius: Scalar) -> Rect

Create a rectangle that circumscribes the given circle.

fn new_square<T: Into<Point>>(pos: T, len: Scalar) -> Rect

Create a square rectangle with sides of length len and top left corner at pos.

fn left(&self) -> Scalar

Returns the position of the left side of the rectangle.

fn margin(self, m: Scalar) -> Rect

Computes a rectangle whose perimeter forms the inside edge of margin with size m for self.

fn relative<T: Into<Point>>(self, v: T) -> Rect

Computes a rectangle translated (slid) in the direction of the vector a distance relative to the size of the rectangle. For example, self.relative([1.0, 1.0]) returns a rectangle one rectangle to the right and down from the original.

fn right(&self) -> Scalar

Returns the position of the right side of the rectangle.

fn scaled<T: Into<Size>>(self, v: T) -> Rect

Computes a scaled rectangle with the same position as self.

fn top(&self) -> Scalar

Returns the position of the top side of the rectangle.

Trait Implementations

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

impl<P: Into<Point>, S: Into<Size>> From<(P, S)> for Rect
[src]

fn from((pos, size): (P, S)) -> Rect

Creates a rectangle from the position of its top left corner and its size.

impl From<[Scalar; 4]> for Rect
[src]

fn from(v: [Scalar; 4]) -> Rect

Creates a rectangle from an array.

impl From<(Scalar, Scalar, Scalar, Scalar)> for Rect
[src]

fn from((x, y, w, h): (Scalar, Scalar, Scalar, Scalar)) -> Rect

Performs the conversion.