#[repr(C)]pub struct Rectangle<T = f32> { /* private fields */ }
Expand description
A struct representing an axis-aligned rectangle. Two points are stored: the top left vertex, and the bottom right vertex.
Implementations§
source§impl<T> Rectangle<T>
impl<T> Rectangle<T>
sourcepub const fn new(top_left: Vector2<T>, bottom_right: Vector2<T>) -> Self
pub const fn new(top_left: Vector2<T>, bottom_right: Vector2<T>) -> Self
Constructs a new Rectangle
. The top left vertex must be above and to
the left of the bottom right vertex.
sourcepub fn from_tuples(top_left: (T, T), bottom_right: (T, T)) -> Self
pub fn from_tuples(top_left: (T, T), bottom_right: (T, T)) -> Self
Constructs a new Rectangle
. The top left vertex must be above and to
the left of the bottom right vertex.
sourcepub const fn bottom_right(&self) -> &Vector2<T>
pub const fn bottom_right(&self) -> &Vector2<T>
Returns a reference to the bottom right vertex.
source§impl<T: PartialOrd<T> + Copy> Rectangle<T>
impl<T: PartialOrd<T> + Copy> Rectangle<T>
source§impl<T: PartialOrd + Copy> Rectangle<T>
impl<T: PartialOrd + Copy> Rectangle<T>
source§impl<T: PrimitiveZero> Rectangle<T>
impl<T: PrimitiveZero> Rectangle<T>
source§impl<T: PartialEq> Rectangle<T>
impl<T: PartialEq> Rectangle<T>
sourcepub fn is_zero_area(&self) -> bool
pub fn is_zero_area(&self) -> bool
Returns true
if the rectangle has zero area.
source§impl<T: PartialOrd> Rectangle<T>
impl<T: PartialOrd> Rectangle<T>
sourcepub fn is_positive_area(&self) -> bool
pub fn is_positive_area(&self) -> bool
Returns true
if the rectangle has an area greater than zero.
source§impl<T: Copy> Rectangle<T>where
Vector2<T>: Add<Output = Vector2<T>>,
impl<T: Copy> Rectangle<T>where
Vector2<T>: Add<Output = Vector2<T>>,
sourcepub fn with_offset(&self, offset: impl Into<Vector2<T>>) -> Self
pub fn with_offset(&self, offset: impl Into<Vector2<T>>) -> Self
Returns a new rectangle, whose vertices are offset relative to the current rectangle by the specified amount. This is equivalent to adding the specified vector to each vertex.
source§impl<T: Copy> Rectangle<T>where
Vector2<T>: Sub<Output = Vector2<T>>,
impl<T: Copy> Rectangle<T>where
Vector2<T>: Sub<Output = Vector2<T>>,
sourcepub fn with_negative_offset(&self, offset: impl Into<Vector2<T>>) -> Self
pub fn with_negative_offset(&self, offset: impl Into<Vector2<T>>) -> Self
Returns a new rectangle, whose vertices are negatively offset relative to the current rectangle by the specified amount. This is equivalent to subtracting the specified vector to each vertex.