pub struct Rect {
pub origin: Point,
pub size: Size,
}Expand description
Rectangle defined by position and size
Fields§
§origin: PointThe origin point of the rectangle.
size: SizeThe size of the rectangle.
Implementations§
Source§impl Rect
impl Rect
Sourcepub fn from_xywh(x: f64, y: f64, width: f64, height: f64) -> Self
pub fn from_xywh(x: f64, y: f64, width: f64, height: f64) -> Self
Creates a new Rect from x, y, width, and height.
Sourcepub fn from_points(p1: Point, p2: Point) -> Self
pub fn from_points(p1: Point, p2: Point) -> Self
Creates a new Rect from two points.
Sourcepub fn bottom_left(&self) -> Point
pub fn bottom_left(&self) -> Point
Gets the bottom-left point.
Sourcepub fn bottom_right(&self) -> Point
pub fn bottom_right(&self) -> Point
Gets the bottom-right point.
Sourcepub fn contains_point(&self, point: Point) -> bool
pub fn contains_point(&self, point: Point) -> bool
Checks if a point is inside the rectangle.
Sourcepub fn intersects(&self, other: &Rect) -> bool
pub fn intersects(&self, other: &Rect) -> bool
Checks if this rectangle intersects with another.
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
impl Copy for Rect
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