pub struct Rect {
pub origin: Point,
pub size: Size,
}Expand description
Rectangle defined by position and size
Fields§
§origin: Point§size: SizeImplementations§
Source§impl Rect
impl Rect
pub fn new(origin: Point, size: Size) -> Self
pub fn from_xywh(x: f64, y: f64, width: f64, height: f64) -> Self
pub fn from_points(p1: Point, p2: Point) -> Self
pub fn x(&self) -> f64
pub fn y(&self) -> f64
pub fn width(&self) -> f64
pub fn height(&self) -> f64
pub fn min_x(&self) -> f64
pub fn min_y(&self) -> f64
pub fn max_x(&self) -> f64
pub fn max_y(&self) -> f64
pub fn center(&self) -> Point
pub fn top_left(&self) -> Point
pub fn top_right(&self) -> Point
pub fn bottom_left(&self) -> Point
pub fn bottom_right(&self) -> Point
pub fn contains_point(&self, point: Point) -> bool
pub fn intersects(&self, other: &Rect) -> bool
pub fn union(&self, other: &Rect) -> Rect
pub fn translate(&self, dx: f64, dy: f64) -> Rect
pub fn scale(&self, factor: f64) -> Rect
pub fn expand(&self, margin: f64) -> 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
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 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