pub struct Rect<T>{
pub position: Matrix<T, Const<nalgebra::::base::dimension::U2::{constant#0}>, Const<1>, ArrayStorage<T, 2, 1>>,
pub size: Matrix<T, Const<nalgebra::::base::dimension::U2::{constant#0}>, Const<1>, ArrayStorage<T, 2, 1>>,
}Fields§
§position: Matrix<T, Const<nalgebra::::base::dimension::U2::{constant#0}>, Const<1>, ArrayStorage<T, 2, 1>>§size: Matrix<T, Const<nalgebra::::base::dimension::U2::{constant#0}>, Const<1>, ArrayStorage<T, 2, 1>>Implementations§
Source§impl<T> Rect<T>
impl<T> Rect<T>
pub fn new(x: T, y: T, w: T, h: T) -> Rect<T>
pub fn inflate(&self, dw: T, dh: T) -> Rect<T>
pub fn deflate(&self, dw: T, dh: T) -> Rect<T>
pub fn contains( &self, pt: Matrix<T, Const<nalgebra::::base::dimension::U2::{constant#0}>, Const<1>, ArrayStorage<T, 2, 1>>, ) -> bool
Sourcepub fn push(
&mut self,
p: Matrix<T, Const<nalgebra::::base::dimension::U2::{constant#0}>, Const<1>, ArrayStorage<T, 2, 1>>,
)
pub fn push( &mut self, p: Matrix<T, Const<nalgebra::::base::dimension::U2::{constant#0}>, Const<1>, ArrayStorage<T, 2, 1>>, )
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);
}pub fn clip_by(&self, other: Rect<T>) -> Rect<T>
pub fn intersects(&self, other: Rect<T>) -> bool
pub fn translate( &self, translation: Matrix<T, Const<nalgebra::::base::dimension::U2::{constant#0}>, Const<1>, ArrayStorage<T, 2, 1>>, ) -> Rect<T>
pub fn intersects_circle( &self, circle: Matrix<T, Const<nalgebra::::base::dimension::U2::{constant#0}>, Const<1>, ArrayStorage<T, 2, 1>>, radius: T, ) -> bool
pub fn extend_to_contain(&mut self, other: Rect<T>)
pub fn left_top_corner( &self, ) -> Matrix<T, Const<nalgebra::::base::dimension::U2::{constant#0}>, Const<1>, ArrayStorage<T, 2, 1>>
pub fn right_top_corner( &self, ) -> Matrix<T, Const<nalgebra::::base::dimension::U2::{constant#0}>, Const<1>, ArrayStorage<T, 2, 1>>
pub fn right_bottom_corner( &self, ) -> Matrix<T, Const<nalgebra::::base::dimension::U2::{constant#0}>, Const<1>, ArrayStorage<T, 2, 1>>
pub fn left_bottom_corner( &self, ) -> Matrix<T, Const<nalgebra::::base::dimension::U2::{constant#0}>, Const<1>, ArrayStorage<T, 2, 1>>
pub fn w(&self) -> T
pub fn h(&self) -> T
pub fn x(&self) -> T
pub fn y(&self) -> T
Trait Implementations§
impl<T> Copy for Rect<T>
impl<T> StructuralPartialEq for Rect<T>
Auto Trait Implementations§
impl<T> Freeze for Rect<T>where
T: Freeze,
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> UnsafeUnpin for Rect<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for Rect<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> PropertyValue for Twhere
T: Debug + 'static,
impl<T> PropertyValue for Twhere
T: Debug + 'static,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.