pub struct Rect { /* private fields */ }Expand description
Axis-aligned rectangle represented by minimum and maximum corners.
The rectangle may be constructed with inverted coordinates. Call
Rect::normalized before using width or height when input ordering is not
trusted.
Implementations§
Source§impl Rect
impl Rect
Sourcepub fn new(min: Vec2, max: Vec2) -> Self
pub fn new(min: Vec2, max: Vec2) -> Self
Builds a rectangle from two corners in the caller’s coordinate space.
Sourcepub const fn min(self) -> Vec2
pub const fn min(self) -> Vec2
Returns the first stored corner, which is the minimum after normalization.
Sourcepub const fn max(self) -> Vec2
pub const fn max(self) -> Vec2
Returns the second stored corner, which is the maximum after normalization.
Sourcepub fn from_center_size(center: Vec2, size: Vec2) -> Self
pub fn from_center_size(center: Vec2, size: Vec2) -> Self
Builds a rectangle from its center and size.
Negative size components are allowed and can be normalized later.
Sourcepub fn from_min_size(min: Vec2, size: Vec2) -> Self
pub fn from_min_size(min: Vec2, size: Vec2) -> Self
Builds a rectangle from its minimum corner and size.
Negative size components are allowed and can be normalized later.
Sourcepub fn size(self) -> Vec2
pub fn size(self) -> Vec2
Returns width and height as a vector in the rectangle’s coordinate space.
Sourcepub fn expand(self, amount: f32) -> Self
pub fn expand(self, amount: f32) -> Self
Expands all edges outward by amount.
Negative values shrink the rectangle.
Sourcepub fn normalized(self) -> Self
pub fn normalized(self) -> Self
Returns a rectangle whose min components are not greater than max.