[][src]Struct shapes::Rect

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.

Implementations

impl Rect[src]

pub fn bottom(&self) -> Scalar[src]

Returns the position of the bottom side of the rectangle.

pub fn centered(self) -> Rect[src]

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

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

Compute whether or not the point is inside the rectangle.

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

Create a rectangle that circumscribes the given circle.

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

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

pub fn left(&self) -> Scalar[src]

Returns the position of the left side of the rectangle.

pub fn margin(self, m: Scalar) -> Rect[src]

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

pub fn relative<T: Into<Point>>(self, v: T) -> Rect[src]

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.

pub fn right(&self) -> Scalar[src]

Returns the position of the right side of the rectangle.

pub fn scaled<T: Into<Size>>(self, v: T) -> Rect[src]

Computes a scaled rectangle with the same position as self.

pub fn top(&self) -> Scalar[src]

Returns the position of the top side of the rectangle.

Trait Implementations

impl Clone for Rect[src]

impl Copy for Rect[src]

impl Debug for Rect[src]

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

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

Creates a rectangle from an array.

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

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

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

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

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

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

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

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

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

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.