Struct speedy2d::shape::Rectangle[][src]

#[repr(C)]pub struct Rectangle<T = f32> { /* fields omitted */ }

A struct representing an axis-aligned rectangle. Two points are stored: the top left vertex, and the bottom right vertex.

Implementations

impl<T> Rectangle<T>[src]

pub const fn new(top_left: Vector2<T>, bottom_right: Vector2<T>) -> Self[src]

Constructs a new Rectangle. The top left vertex must be above and to the left of the bottom right vertex.

pub fn from_tuples(top_left: (T, T), bottom_right: (T, T)) -> Self[src]

Constructs a new Rectangle. The top left vertex must be above and to the left of the bottom right vertex.

pub const fn top_left(&self) -> &Vector2<T>[src]

Returns a reference to the top left vertex.

pub const fn bottom_right(&self) -> &Vector2<T>[src]

Returns a reference to the bottom right vertex.

impl<T: Copy> Rectangle<T>[src]

pub fn top_right(&self) -> Vector2<T>[src]

Returns a vector representing the top right vertex.

pub fn bottom_left(&self) -> Vector2<T>[src]

Returns a vector representing the bottom left vertex.

impl<T: Sub<Output = T> + Copy> Rectangle<T>[src]

pub fn width(&self) -> T[src]

Returns the width of the rectangle.

pub fn height(&self) -> T[src]

Returns the height of the rectangle.

pub fn size(&self) -> Vector2<T>[src]

Returns a Vector2 containing the width and height of the rectangle.

impl<T: PartialEq> Rectangle<T>[src]

pub fn is_zero_area(&self) -> bool[src]

Returns true if the rectangle has zero area.

impl<T: Copy> Rectangle<T> where
    Vector2<T>: Add<Output = Vector2<T>>, 
[src]

pub fn with_offset(&self, offset: Vector2<T>) -> Self[src]

Returns a new rectangle, whose vertices are offset relative to the current rectangle by the specified amount. This is equivalent to adding the specified vector to each vertex.

impl<T: AsPrimitive<f32>> Rectangle<T>[src]

#[must_use]pub fn into_f32(self) -> Rectangle<f32>[src]

Returns a new rectangle where the coordinates have been cast to f32 values, using the as operator.

Trait Implementations

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

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

impl<T: Copy> From<&'_ Rect<T>> for Rectangle<T>[src]

impl<T> From<Rect<T>> for Rectangle<T>[src]

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

impl<T> StructuralPartialEq for Rectangle<T>[src]

Auto Trait Implementations

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

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

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

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

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

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.