pub struct Rect {
pub x: u32,
pub y: u32,
pub width: u32,
pub height: u32,
}Expand description
An axis-aligned rectangle in sensor-buffer coordinates.
Fields§
§x: u32Left edge (first column), in pixels.
y: u32Top edge (first row), in pixels.
width: u32Width in pixels.
height: u32Height in pixels.
Implementations§
Source§impl Rect
impl Rect
Sourcepub const fn new(x: u32, y: u32, width: u32, height: u32) -> Rect
pub const fn new(x: u32, y: u32, width: u32, height: u32) -> Rect
Rect with top-left corner (x, y) and the given size.
Sourcepub fn from_ltrb(left: u32, top: u32, right: u32, bottom: u32) -> Option<Rect>
pub fn from_ltrb(left: u32, top: u32, right: u32, bottom: u32) -> Option<Rect>
Rect from left/top/right/bottom edges (exclusive right/bottom). Returns None if inverted.
Sourcepub const fn full(width: u32, height: u32) -> Rect
pub const fn full(width: u32, height: u32) -> Rect
Rect covering a whole width x height buffer, anchored at (0, 0).
Sourcepub fn intersect(&self, o: &Rect) -> Option<Rect>
pub fn intersect(&self, o: &Rect) -> Option<Rect>
Overlap of two rects, or None if they do not overlap.
Sourcepub fn contains_rect(&self, o: &Rect) -> bool
pub fn contains_rect(&self, o: &Rect) -> bool
True if o lies entirely inside self.
Trait Implementations§
impl Copy for Rect
Source§impl<'de> Deserialize<'de> for Rect
impl<'de> Deserialize<'de> for Rect
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Rect, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Rect, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for Rect
Source§impl Serialize for Rect
impl Serialize for Rect
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
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, Ctx> BundleDefault<Ctx> for Twhere
T: Default,
impl<T, Ctx> BundleDefault<Ctx> for Twhere
T: Default,
Source§fn default_with_context(_: Ctx) -> T
fn default_with_context(_: Ctx) -> T
Creates a default value with the given context.
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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