Struct rg3d_core::math::Rect[][src]

pub struct Rect<T: Scalar> {
    pub position: Vector2<T>,
    pub size: Vector2<T>,
}

Fields

position: Vector2<T>size: Vector2<T>

Implementations

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

pub fn new(x: T, y: T, w: T, h: T) -> Self[src]

#[must_use = "this method creates new instance of rect"]pub fn inflate(&self, dw: T, dh: T) -> Self[src]

#[must_use = "this method creates new instance of rect"]pub fn deflate(&self, dw: T, dh: T) -> Self[src]

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

pub fn push(&mut self, p: Vector2<T>)[src]

Extends rect to contain given point.

Notes

To build bounding rectangle you should correctly initialize initial rectangle:


let vertices = [Vector2::new(1.0, 2.0), Vector2::new(-3.0, 5.0)];

// This is important part, it must have "invalid" state to correctly
// calculate bounding rect. Rect::default will give invalid result!
let mut bounding_rect = Rect::new(f32::MAX, f32::MAX, 0.0, 0.0);

for &v in &vertices {
    bounding_rect.push(v);
}

#[must_use = "this method creates new instance of rect"]pub fn clip_by(&self, other: Rect<T>) -> Rect<T>[src]

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

#[must_use = "this method creates new instance of rect"]pub fn translate(&self, translation: Vector2<T>) -> Self[src]

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

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

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

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

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

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

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

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

Trait Implementations

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

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

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

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

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

impl<T: Scalar> StructuralPartialEq for Rect<T>[src]

impl<T> Visit for Rect<T> where
    T: Scalar + Visit + 'static, 
[src]

Auto Trait Implementations

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

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

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> Same<T> for T

type Output = T

Should always be Self

impl<T> Scalar for T where
    T: Copy + PartialEq<T> + Debug + Any
[src]

impl<SS, SP> SupersetOf<SS> for SP where
    SS: SubsetOf<SP>, 

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<V, T> VZip<V> for T where
    V: MultiLane<T>,