pub struct Rect {
pub min: Vec2,
pub max: Vec2,
}Expand description
An axis aligned rectangle in points, from its top left corner min to
its bottom right corner max.
Fields§
§min: Vec2Top left corner.
max: Vec2Bottom right corner.
Implementations§
Source§impl Rect
impl Rect
Sourcepub const EVERYTHING: Rect
pub const EVERYTHING: Rect
A rectangle larger than any window. Use it as a clip that clips nothing.
Sourcepub const NOTHING: Rect
pub const NOTHING: Rect
An inverted rectangle, the starting point for Rect::union.
Sourcepub fn from_min_size(min: Vec2, size: Vec2) -> Self
pub fn from_min_size(min: Vec2, size: Vec2) -> Self
Creates a rectangle from its top left corner and its size.
Sourcepub fn from_center_size(center: Vec2, size: Vec2) -> Self
pub fn from_center_size(center: Vec2, size: Vec2) -> Self
Creates a rectangle from its center and its size.
Sourcepub fn contains(&self, point: Vec2) -> bool
pub fn contains(&self, point: Vec2) -> bool
Returns true if point is inside. The right and bottom edges are
outside.
Sourcepub fn intersects(&self, other: &Rect) -> bool
pub fn intersects(&self, other: &Rect) -> bool
Returns true if the two rectangles overlap.
Sourcepub fn intersect(&self, other: Rect) -> Rect
pub fn intersect(&self, other: Rect) -> Rect
Returns the overlap of the two rectangles. It is empty, see
Rect::is_positive, when they do not overlap.
Sourcepub fn is_positive(&self) -> bool
pub fn is_positive(&self) -> bool
Returns true if the width and height are larger than zero.
Sourcepub fn expand2(&self, amount: Vec2) -> Rect
pub fn expand2(&self, amount: Vec2) -> Rect
Grows the left and right sides by amount.x, the top and bottom by
amount.y.
Sourcepub fn shrink2(&self, amount: Vec2) -> Rect
pub fn shrink2(&self, amount: Vec2) -> Rect
Shrinks the left and right sides by amount.x, the top and bottom by
amount.y.
Sourcepub fn scale_from_center(&self, scale_x: f32, scale_y: f32) -> Rect
pub fn scale_from_center(&self, scale_x: f32, scale_y: f32) -> Rect
Scales width and height around the center.
Sourcepub fn lerp(&self, other: &Rect, t: f32) -> Rect
pub fn lerp(&self, other: &Rect, t: f32) -> Rect
Mixes towards other: t = 0 gives self, 1 gives other.
Sourcepub fn clamp_inside(&self, outer: Rect) -> Rect
pub fn clamp_inside(&self, outer: Rect) -> Rect
Moves the rectangle, without resizing it, so it lies inside outer.
When it is larger than outer, its top left corner stays inside.
Trait Implementations§
impl Copy for Rect
impl StructuralPartialEq for Rect
Auto Trait Implementations§
impl Forget for Rect
impl Freeze for Rect
impl Move for Rect
impl RefUnwindSafe for Rect
impl Send for Rect
impl Sync for Rect
impl Unpin for Rect
impl UnsafeUnpin for Rect
impl UnwindSafe for Rect
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.