pub struct Rect {
pub x: f32,
pub y: f32,
pub width: f32,
pub height: f32,
}Expand description
An axis-aligned rectangle given by its top-left corner and its size, in logical pixels.
Fields§
§x: f32Left edge, in logical pixels.
y: f32Top edge, in logical pixels.
width: f32Width, in logical pixels.
height: f32Height, in logical pixels.
Implementations§
Source§impl Rect
impl Rect
Sourcepub const EMPTY: Rect
pub const EMPTY: Rect
The rect that holds nothing: what two clips that do not overlap resolve to, so a clip that meets nothing stays a clip instead of lifting.
Sourcepub fn from_origin_size(origin: Point, size: Size) -> Rect
pub fn from_origin_size(origin: Point, size: Size) -> Rect
Creates a rectangle with its top-left corner at origin and the given size.
Sourcepub fn from_size(size: Size) -> Rect
pub fn from_size(size: Size) -> Rect
Creates a rectangle of size with its top-left corner at the origin.
Sourcepub fn translate(&self, dx: f32, dy: f32) -> Rect
pub fn translate(&self, dx: f32, dy: f32) -> Rect
Returns the rectangle moved by dx horizontally and dy vertically.
Sourcepub fn contains(&self, x: f32, y: f32) -> bool
pub fn contains(&self, x: f32, y: f32) -> bool
Whether the point (x, y) lies inside the rectangle, edges included.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Whether the rect covers no area, so nothing clipped to it can paint.
Trait Implementations§
impl Copy for Rect
Source§impl RenderHash for Rect
impl RenderHash for Rect
Source§fn render_hash(&self) -> u64
fn render_hash(&self) -> u64
Returns a hash over exactly the values that change what is drawn. Equal values give equal
hashes.
Source§impl SpringScalar for Rect
impl SpringScalar for Rect
Source§const DIMENSIONS: usize = 4
const DIMENSIONS: usize = 4
Number of animated dimensions (1..=4).
Source§fn from_dimensions(dimensions: [f32; 4]) -> Rect
fn from_dimensions(dimensions: [f32; 4]) -> Rect
Rebuilds a value from per-dimension floats (indices beyond
Self::DIMENSIONS are ignored).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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more