Expand description
A 2D rectangle, defined by its top-left corner, width and height.
Fields
x: f32
y: f32
w: f32
h: f32
Implementations
sourceimpl Rect
impl Rect
sourcepub fn new(x: f32, y: f32, w: f32, h: f32) -> Rect
pub fn new(x: f32, y: f32, w: f32, h: f32) -> Rect
Creates a new rectangle from its top-left corner, width and height.
Arguments:
x
- x-coordinate of the top-left corner.y
- y-coordinate of the top-left corner.w
- width of theRect
, going to the right.h
- height of theRect
, going down.
sourcepub fn scale(&mut self, sx: f32, sy: f32)
pub fn scale(&mut self, sx: f32, sy: f32)
Scales the Rect
by a factor of (sx, sy),
growing towards the bottom-left
sourcepub fn combine_with(self, other: Rect) -> Rect
pub fn combine_with(self, other: Rect) -> Rect
Returns a new Rect
that includes all points of these two Rect
s.
Trait Implementations
sourceimpl PartialEq<Rect> for Rect
impl PartialEq<Rect> for Rect
impl Copy for Rect
impl StructuralPartialEq for Rect
Auto Trait Implementations
impl RefUnwindSafe for Rect
impl Send for Rect
impl Sync for Rect
impl Unpin for Rect
impl UnwindSafe for Rect
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more