Struct fyrox_core::math::Rect
source · pub struct Rect<T>where
T: NumAssign + Scalar + PartialOrd + Copy,{
pub position: Vector2<T>,
pub size: Vector2<T>,
}
Fields§
§position: Vector2<T>
§size: Vector2<T>
Implementations§
source§impl<T> Rect<T>where
T: NumAssign + Scalar + PartialOrd + Copy,
impl<T> Rect<T>where
T: NumAssign + Scalar + PartialOrd + Copy,
pub fn new(x: T, y: T, w: T, h: T) -> Self
pub fn with_position(self, position: Vector2<T>) -> Self
pub fn with_size(self, size: Vector2<T>) -> Self
pub fn inflate(&self, dw: T, dh: T) -> Self
pub fn deflate(&self, dw: T, dh: T) -> Self
pub fn contains(&self, pt: Vector2<T>) -> bool
pub fn center(&self) -> Vector2<T>
sourcepub fn push(&mut self, p: Vector2<T>)
pub fn push(&mut self, p: Vector2<T>)
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: Vector2<T>) -> Self
pub fn intersects_circle(&self, circle: Vector2<T>, radius: T) -> bool
pub fn extend_to_contain(&mut self, other: Rect<T>)
pub fn left_top_corner(&self) -> Vector2<T>
pub fn right_top_corner(&self) -> Vector2<T>
pub fn right_bottom_corner(&self) -> Vector2<T>
pub fn left_bottom_corner(&self) -> Vector2<T>
pub fn w(&self) -> T
pub fn h(&self) -> T
pub fn x(&self) -> T
pub fn y(&self) -> T
pub fn transform(&self, matrix: &Matrix3<T>) -> Self
Trait Implementations§
source§impl<T> PartialEq<Rect<T>> for Rect<T>where
T: NumAssign + Scalar + PartialOrd + Copy + PartialEq,
impl<T> PartialEq<Rect<T>> for Rect<T>where
T: NumAssign + Scalar + PartialOrd + Copy + PartialEq,
source§impl<T> Reflect for Rect<T>where
T: NumAssign + Scalar + PartialOrd + Copy,
Self: 'static,
Vector2<T>: Reflect,
impl<T> Reflect for Rect<T>where
T: NumAssign + Scalar + PartialOrd + Copy,
Self: 'static,
Vector2<T>: Reflect,
fn type_name(&self) -> &'static str
fn fields_info(&self) -> Vec<FieldInfo<'_>>
fn into_any(self: Box<Self>) -> Box<dyn Any>
fn set(
&mut self,
value: Box<dyn Reflect>
) -> Result<Box<dyn Reflect>, Box<dyn Reflect>>
fn as_any(&self) -> &dyn Any
fn as_any_mut(&mut self) -> &mut dyn Any
fn as_reflect(&self) -> &dyn Reflect
fn as_reflect_mut(&mut self) -> &mut dyn Reflect
fn fields(&self) -> Vec<&dyn Reflect>
fn fields_mut(&mut self) -> Vec<&mut dyn Reflect>
fn field(&self, name: &str) -> Option<&dyn Reflect>
fn field_mut(&mut self, name: &str) -> Option<&mut dyn Reflect>
source§fn set_field(
&mut self,
field: &str,
value: Box<dyn Reflect>
) -> Result<Box<dyn Reflect>, Box<dyn Reflect>>
fn set_field(
&mut self,
field: &str,
value: Box<dyn Reflect>
) -> Result<Box<dyn Reflect>, Box<dyn Reflect>>
Calls user method specified with
#[reflect(setter = ..)]
or falls back to
Reflect::field_mut
fn as_array(&self) -> Option<&dyn ReflectArray>
fn as_array_mut(&mut self) -> Option<&mut dyn ReflectArray>
fn as_list(&self) -> Option<&dyn ReflectList>
fn as_list_mut(&mut self) -> Option<&mut dyn ReflectList>
fn as_inheritable_variable(&self) -> Option<&dyn ReflectInheritableVariable>
fn as_inheritable_variable_mut(
&mut self
) -> Option<&mut dyn ReflectInheritableVariable>
impl<T> Copy for Rect<T>where
T: NumAssign + Scalar + PartialOrd + Copy + Copy,
impl<T> Eq for Rect<T>where
T: NumAssign + Scalar + PartialOrd + Copy + Eq,
impl<T> StructuralEq for Rect<T>where
T: NumAssign + Scalar + PartialOrd + Copy,
impl<T> StructuralPartialEq for Rect<T>where
T: NumAssign + Scalar + PartialOrd + Copy,
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§
source§impl<T> FieldValue for Twhere
T: 'static,
impl<T> FieldValue for Twhere
T: 'static,
source§impl<T> ResolvePath for Twhere
T: Reflect,
impl<T> ResolvePath for Twhere
T: Reflect,
fn resolve_path<'r, 'p>(
&'r self,
path: &'p str
) -> Result<&'r (dyn Reflect + 'static), ReflectPathError<'p>>
fn resolve_path_mut<'r, 'p>(
&'r mut self,
path: &'p str
) -> Result<&'r mut (dyn Reflect + 'static), ReflectPathError<'p>>
fn get_resolve_path<'r, 'p, T: Reflect>(
&'r self,
path: &'p str
) -> Result<&'r T, ReflectPathError<'p>>
fn get_resolve_path_mut<'r, 'p, T: Reflect>(
&'r mut self,
path: &'p str
) -> Result<&'r mut T, ReflectPathError<'p>>
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§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 more§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).§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.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self
to the equivalent element of its superset.