pub struct Rectangle<T = f32> {
pub x: T,
pub y: T,
pub width: T,
pub height: T,
}
Expand description
An axis-aligned rectangle.
Fields§
§x: T
X coordinate of the top-left corner.
y: T
Y coordinate of the top-left corner.
width: T
Width of the rectangle.
height: T
Height of the rectangle.
Implementations§
Source§impl Rectangle<f32>
impl Rectangle<f32>
Sourcepub const INFINITE: Self
pub const INFINITE: Self
A rectangle starting at Point::ORIGIN
with infinite width and height.
Sourcepub fn with_radius(radius: f32) -> Self
pub fn with_radius(radius: f32) -> Self
Creates a new square Rectangle
with the center at the origin and
with the given radius.
Sourcepub fn with_vertices(
top_left: Point,
top_right: Point,
bottom_left: Point,
) -> (Rectangle, Radians)
pub fn with_vertices( top_left: Point, top_right: Point, bottom_left: Point, ) -> (Rectangle, Radians)
Sourcepub fn offset(&self, container: &Rectangle) -> Vector
pub fn offset(&self, container: &Rectangle) -> Vector
Computes the offset that must be applied to the Rectangle
to be placed
inside the given container
.
Sourcepub fn is_within(&self, container: &Rectangle) -> bool
pub fn is_within(&self, container: &Rectangle) -> bool
Returns true if the current Rectangle
is completely within the given
container
.
Sourcepub fn intersection(&self, other: &Rectangle<f32>) -> Option<Rectangle<f32>>
pub fn intersection(&self, other: &Rectangle<f32>) -> Option<Rectangle<f32>>
Computes the intersection with the given Rectangle
.
Sourcepub fn intersects(&self, other: &Self) -> bool
pub fn intersects(&self, other: &Self) -> bool
Returns whether the Rectangle
intersects with the given one.
Sourcepub fn snap(self) -> Option<Rectangle<u32>>
pub fn snap(self) -> Option<Rectangle<u32>>
Snaps the Rectangle
to unsigned integer coordinates.
Trait Implementations§
Source§impl Mul<Transformation> for Rectangle
impl Mul<Transformation> for Rectangle
impl<T: Copy> Copy for Rectangle<T>
impl<T: Eq> Eq for Rectangle<T>
impl<T> StructuralPartialEq for Rectangle<T>
Auto Trait Implementations§
impl<T> Freeze for Rectangle<T>where
T: Freeze,
impl<T> RefUnwindSafe for Rectangle<T>where
T: RefUnwindSafe,
impl<T> Send for Rectangle<T>where
T: Send,
impl<T> Sync for Rectangle<T>where
T: Sync,
impl<T> Unpin for Rectangle<T>where
T: Unpin,
impl<T> UnwindSafe for Rectangle<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,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> NoneValue for Twhere
T: Default,
impl<T> NoneValue for Twhere
T: Default,
type NoneType = T
§fn null_value() -> T
fn null_value() -> T
The none-equivalent value.