pub struct Rect {
pub pos: Point,
pub size: Point,
}
Expand description
A rectangular area, represented by a position and a size
Fields§
§pos: Point
The position of the rectangle
size: Point
The size of the rectangle
Implementations§
source§impl Rect
impl Rect
sourcepub fn new(pos: Point, size: Point) -> Rect
pub fn new(pos: Point, size: Point) -> Rect
Construct a new Rect
with the specified position and size.
sourcepub fn is_inside(&self, pos: Point) -> bool
pub fn is_inside(&self, pos: Point) -> bool
Returns true if the specified point is inside (or on the edge of) this rectangle; false otherwise
sourcepub fn min(self, other: Rect) -> Rect
pub fn min(self, other: Rect) -> Rect
Returns a new Rect
this is the minimum extent on a component-by-component
basis between this and other
. The returned Rect
will barely fit inside
both this and other
(if possible - if not it will have size 0)
sourcepub fn max(self, other: Rect) -> Rect
pub fn max(self, other: Rect) -> Rect
Returns a new Rect
that is the maximum extent on a component-by-component
basis between this and other
. The returned Rect
will barely contain
both this and other
.
sourcepub fn contains_rect(&self, other: Rect) -> bool
pub fn contains_rect(&self, other: Rect) -> bool
Returns true if the specified other
Rect
is entirely contained inside this Rect.
Trait Implementations§
source§impl<'de> Deserialize<'de> for Rect
impl<'de> Deserialize<'de> for Rect
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
source§impl 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§
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> Content for Twhere
T: Copy,
impl<T> Content for Twhere T: Copy,
source§unsafe fn read<F, E>(size: usize, f: F) -> Result<T, E>where
F: FnOnce(&mut T) -> Result<(), E>,
unsafe fn read<F, E>(size: usize, f: F) -> Result<T, E>where F: FnOnce(&mut T) -> Result<(), E>,
Prepares an output buffer, then turns this buffer into an
Owned
.
User-provided closure F
must only write to and not read from &mut Self
.source§fn get_elements_size() -> usize
fn get_elements_size() -> usize
Returns the size of each element.
source§fn to_void_ptr(&self) -> *const ()
fn to_void_ptr(&self) -> *const ()
Produces a pointer to the data.
source§fn ref_from_ptr<'a>(ptr: *mut (), size: usize) -> Option<*mut T>
fn ref_from_ptr<'a>(ptr: *mut (), size: usize) -> Option<*mut T>
Builds a pointer to this type from a raw pointer.
source§fn is_size_suitable(size: usize) -> bool
fn is_size_suitable(size: usize) -> bool
Returns true if the size is suitable to store a type like this.