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
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 T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
pub fn from_sample_(s: S) -> S
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
🔬 This is a nightly-only experimental API. (
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more