[−][src]Struct shapes::Rect
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]
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]
fn clone(&self) -> Rect
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
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
[src]
Creates a rectangle from the position of its top left corner and its size.
impl From<Rect> for [Scalar; 4]
[src]
impl From<[f64; 4]> for Rect
[src]
impl From<(f64, f64, f64, f64)> for Rect
[src]
impl Copy for Rect
[src]
impl Debug for Rect
[src]
Auto Trait Implementations
impl Sync for Rect
impl Send for Rect
impl Unpin for Rect
impl RefUnwindSafe for Rect
impl UnwindSafe for Rect
Blanket Implementations
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,