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,

source

pub const POSITION: &'static str = _

source

pub const SIZE: &'static str = _

source§

impl<T> Rect<T>where T: NumAssign + Scalar + PartialOrd + Copy,

source

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

source

pub fn with_position(self, position: Vector2<T>) -> Self

source

pub fn with_size(self, size: Vector2<T>) -> Self

source

pub fn inflate(&self, dw: T, dh: T) -> Self

source

pub fn deflate(&self, dw: T, dh: T) -> Self

source

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

source

pub fn center(&self) -> Vector2<T>

source

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);
}
source

pub fn clip_by(&self, other: Rect<T>) -> Rect<T>

source

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

source

pub fn translate(&self, translation: Vector2<T>) -> Self

source

pub fn intersects_circle(&self, circle: Vector2<T>, radius: T) -> bool

source

pub fn extend_to_contain(&mut self, other: Rect<T>)

source

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

source

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

source

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

source

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

source

pub fn w(&self) -> T

source

pub fn h(&self) -> T

source

pub fn x(&self) -> T

source

pub fn y(&self) -> T

source

pub fn transform(&self, matrix: &Matrix3<T>) -> Self

Trait Implementations§

source§

impl<T> Clone for Rect<T>where T: NumAssign + Scalar + PartialOrd + Copy + Clone,

source§

fn clone(&self) -> Rect<T>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<T> Debug for Rect<T>where T: NumAssign + Scalar + PartialOrd + Copy + Debug,

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<T> Default for Rect<T>where T: NumAssign + Scalar + PartialOrd + Copy,

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl<T> PartialEq<Rect<T>> for Rect<T>where T: NumAssign + Scalar + PartialOrd + Copy + PartialEq,

source§

fn eq(&self, other: &Rect<T>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<T> Reflect for Rect<T>where T: NumAssign + Scalar + PartialOrd + Copy, Self: 'static, Vector2<T>: Reflect,

source§

fn type_name(&self) -> &'static str

source§

fn doc(&self) -> &'static str

source§

fn fields_info(&self, func: &mut dyn FnMut(Vec<FieldInfo<'_>>))

source§

fn into_any(self: Box<Self>) -> Box<dyn Any>

source§

fn set( &mut self, value: Box<dyn Reflect> ) -> Result<Box<dyn Reflect>, Box<dyn Reflect>>

source§

fn as_any(&self, func: &mut dyn FnMut(&dyn Any))

source§

fn as_any_mut(&mut self, func: &mut dyn FnMut(&mut dyn Any))

source§

fn as_reflect(&self, func: &mut dyn FnMut(&dyn Reflect))

source§

fn as_reflect_mut(&mut self, func: &mut dyn FnMut(&mut dyn Reflect))

source§

fn fields(&self, func: &mut dyn FnMut(Vec<&dyn Reflect>))

source§

fn fields_mut(&mut self, func: &mut dyn FnMut(Vec<&mut dyn Reflect>))

source§

fn field(&self, name: &str, func: &mut dyn FnMut(Option<&dyn Reflect>))

source§

fn field_mut( &mut self, name: &str, func: &mut dyn FnMut(Option<&mut dyn Reflect>) )

source§

fn set_field( &mut self, field: &str, value: Box<dyn Reflect>, func: &mut dyn FnMut(Result<Box<dyn Reflect>, Box<dyn Reflect>>) )

Calls user method specified with #[reflect(setter = ..)] or falls back to Reflect::field_mut
source§

fn as_array(&self, func: &mut dyn FnMut(Option<&dyn ReflectArray>))

source§

fn as_array_mut(&mut self, func: &mut dyn FnMut(Option<&mut dyn ReflectArray>))

source§

fn as_list(&self, func: &mut dyn FnMut(Option<&dyn ReflectList>))

source§

fn as_list_mut(&mut self, func: &mut dyn FnMut(Option<&mut dyn ReflectList>))

source§

fn as_inheritable_variable( &self, func: &mut dyn FnMut(Option<&dyn ReflectInheritableVariable>) )

source§

fn as_inheritable_variable_mut( &mut self, func: &mut dyn FnMut(Option<&mut dyn ReflectInheritableVariable>) )

source§

fn as_hash_map(&self, func: &mut dyn FnMut(Option<&dyn ReflectHashMap>))

source§

fn as_hash_map_mut( &mut self, func: &mut dyn FnMut(Option<&mut dyn ReflectHashMap>) )

source§

impl<T> Visit for Rect<T>where T: NumAssign + Scalar + Visit + PartialOrd + Copy + 'static,

source§

fn visit(&mut self, name: &str, visitor: &mut Visitor) -> VisitResult

source§

impl<T> Copy for Rect<T>where T: NumAssign + Scalar + PartialOrd + Copy + Copy,

source§

impl<T> Eq for Rect<T>where T: NumAssign + Scalar + PartialOrd + Copy + Eq,

source§

impl<T> StructuralEq for Rect<T>where T: NumAssign + Scalar + PartialOrd + Copy,

source§

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> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> FieldValue for Twhere T: 'static,

source§

fn as_any(&self) -> &(dyn Any + 'static)

Casts self to a &dyn Any
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<R> GetField for Rwhere R: Reflect,

source§

fn get_field<T>(&self, name: &str, func: &mut dyn FnMut(Option<&T>))where T: 'static,

source§

fn get_field_mut<T>(&mut self, name: &str, func: &mut dyn FnMut(Option<&mut T>))where T: 'static,

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ResolvePath for Twhere T: Reflect,

source§

fn resolve_path<'p>( &self, path: &'p str, func: &mut dyn FnMut(Result<&(dyn Reflect + 'static), ReflectPathError<'p>>) )

source§

fn resolve_path_mut<'p>( &mut self, path: &'p str, func: &mut dyn FnMut(Result<&mut (dyn Reflect + 'static), ReflectPathError<'p>>) )

source§

fn get_resolve_path<'p, T: Reflect>( &self, path: &'p str, func: &mut dyn FnMut(Result<&T, ReflectPathError<'p>>) )

source§

fn get_resolve_path_mut<'p, T: Reflect>( &mut self, path: &'p str, func: &mut dyn FnMut(Result<&mut T, ReflectPathError<'p>>) )

source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
§

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

§

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

Checks if self is actually part of its subset T (and can be converted to it).
§

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

The inclusion map: converts self to the equivalent element of its superset.
source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V

source§

impl<T> Scalar for Twhere T: 'static + Clone + PartialEq<T> + Debug,