[][src]Struct sfml::graphics::Rect

#[repr(C)]
pub struct Rect<T> {
    pub left: T,
    pub top: T,
    pub width: T,
    pub height: T,
}

Utility type for manipulating 2D axis-aligned rectangles.

Fields

left: T

Left coordinate of the rectangle.

top: T

Top coordinate of the rectangle.

width: T

Width of the rectangle.

height: T

Height of the rectangle.

Methods

impl<T> Rect<T>[src]

pub fn new(left: T, top: T, width: T, height: T) -> Self[src]

Construct a rectangle from its coordinates.

pub fn from_vecs(pos: Vector2<T>, size: Vector2<T>) -> Rect<T>[src]

Construct a rectangle from its position and size.

impl<T: PartialOrd + Add<Output = T> + Sub<Output = T> + Copy> Rect<T>[src]

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

Check if a point is inside the rectangle's area.

pub fn contains2(self, x: T, y: T) -> bool[src]

Check if a point is inside the rectangle's area.

pub fn intersection(self, other: &Rect<T>) -> Option<Rect<T>>[src]

Returns the intersection between two rectangles, if any.

If the rectangles intersect, returns Some filled with the intersection of the two rectangles. Otherwise, returns None.

Trait Implementations

impl<T: Clone> Clone for Rect<T>[src]

impl<T: Copy> Copy for Rect<T>[src]

impl<T: Default> Default for Rect<T>[src]

impl<T: Eq> Eq for Rect<T>[src]

impl<T: Ord> Ord for Rect<T>[src]

impl<T: PartialEq> PartialEq<Rect<T>> for Rect<T>[src]

impl<T: PartialOrd> PartialOrd<Rect<T>> for Rect<T>[src]

impl<T: Debug> Debug for Rect<T>[src]

Auto Trait Implementations

impl<T> Send for Rect<T> where
    T: Send

impl<T> Sync for Rect<T> where
    T: Sync

impl<T> Unpin for Rect<T> where
    T: Unpin

impl<T> UnwindSafe for Rect<T> where
    T: UnwindSafe

impl<T> RefUnwindSafe for Rect<T> where
    T: RefUnwindSafe

Blanket Implementations

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

impl<T> From<T> for 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> Borrow<T> for T where
    T: ?Sized
[src]

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

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