pub struct Rect {
pub x: f32,
pub y: f32,
pub width: f32,
pub height: f32,
}Expand description
An axis-aligned rectangle, in logical pixels.
Fields§
§x: f32Left edge.
y: f32Top edge.
width: f32Width, extending to the right.
height: f32Height, extending downwards.
Implementations§
Source§impl Rect
impl Rect
Sourcepub const fn new(x: f32, y: f32, width: f32, height: f32) -> Self
pub const fn new(x: f32, y: f32, width: f32, height: f32) -> Self
Builds a rectangle from its position (top-left corner) and its size.
Sourcepub fn scale(self, factor: f32) -> Self
pub fn scale(self, factor: f32) -> Self
Multiplies position and size by factor (logical → physical conversion).
Sourcepub fn scale_about(self, pivot: Point, factor: f32) -> Self
pub fn scale_about(self, pivot: Point, factor: f32) -> Self
Scales the rectangle by factor about pivot, which stays fixed:
pos' = pivot + (pos - pivot) * factor, with size × factor.
Sourcepub fn scale_about_xy(self, pivot: Point, sx: f32, sy: f32) -> Self
pub fn scale_about_xy(self, pivot: Point, sx: f32, sy: f32) -> Self
Scales the rectangle per axis about pivot.
Sourcepub fn scale_xy(self, sx: f32, sy: f32) -> Self
pub fn scale_xy(self, sx: f32, sy: f32) -> Self
Multiplies position and size per axis (sx, sy).
Sourcepub fn intersect(self, other: Rect) -> Self
pub fn intersect(self, other: Rect) -> Self
The intersection of two rectangles; zero-sized when they are disjoint.
Sourcepub fn contains(self, point: Point) -> bool
pub fn contains(self, point: Point) -> bool
true when point lies inside; the left and top edges count as inside.
Sourcepub const fn from_point_size(origin: Point, size: Size) -> Self
pub const fn from_point_size(origin: Point, size: Size) -> Self
Builds a rectangle from an origin point and a size.
Trait Implementations§
impl Copy for Rect
impl StructuralPartialEq for Rect
Auto Trait Implementations§
impl Freeze 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
Mutably borrows from an owned value. Read more