pub struct Rect {
pub up_left: Point,
pub size: Size,
}
Expand description
A rectangle holding up left point and size.
Fields§
§up_left: Point
A up left point of the rectangle.
size: Size
A size of the rectangle.
Implementations§
Source§impl Rect
impl Rect
Sourcepub fn from_center(center: Point, size: Size) -> Self
pub fn from_center(center: Point, size: Size) -> Self
Constructs a rect from the center.
Sourcepub fn from_bottom_right(bottom_right: Point, size: Size) -> Self
pub fn from_bottom_right(bottom_right: Point, size: Size) -> Self
Constructs a rect from the bottom right.
Sourcepub fn from_xs_ys(xs: [i32; 2], ys: [i32; 2]) -> Self
pub fn from_xs_ys(xs: [i32; 2], ys: [i32; 2]) -> Self
Constructs a rect from x and y coordinates.
Sourcepub fn bottom_right(self) -> Point
pub fn bottom_right(self) -> Point
Returns the bottom right point of the rectangle.
Sourcepub fn bottom_left(self) -> Point
pub fn bottom_left(self) -> Point
Returns the bottom left point of the rectangle.
Sourcepub fn enclosed(
points: impl IntoIterator<Item = Point>,
clip: Option<Rect>,
) -> Option<Self>
pub fn enclosed( points: impl IntoIterator<Item = Point>, clip: Option<Rect>, ) -> Option<Self>
Returns the enclosed rectangle of the points, with the clip region.
Sourcepub fn has_intersection(self, other: Self) -> bool
pub fn has_intersection(self, other: Self) -> bool
Returns whether two rectangles intersected.
Sourcepub fn intersect(self, other: Self) -> Option<Self>
pub fn intersect(self, other: Self) -> Option<Self>
Returns the intersection rectangle of two rectangles.
Sourcepub fn with_top(self, y: i32) -> Self
pub fn with_top(self, y: i32) -> Self
Creates a new rect from the rect with overwriting the new top y position.
Sourcepub fn with_right(self, x: i32) -> Self
pub fn with_right(self, x: i32) -> Self
Creates a new rect from the rect with overwriting the new right x position.
Sourcepub fn with_bottom(self, y: i32) -> Self
pub fn with_bottom(self, y: i32) -> Self
Creates a new rect from the rect with overwriting the new bottom y position.
Sourcepub fn with_left(self, x: i32) -> Self
pub fn with_left(self, x: i32) -> Self
Creates a new rect from the rect with overwriting the new left x position.
Sourcepub fn extend_top(self, increase: u32) -> Self
pub fn extend_top(self, increase: u32) -> Self
Creates a new rect that increased the top from the rect.
Sourcepub fn extend_right(self, increase: u32) -> Self
pub fn extend_right(self, increase: u32) -> Self
Creates a new rect that increased the right from the rect.
Sourcepub fn extend_bottom(self, increase: u32) -> Self
pub fn extend_bottom(self, increase: u32) -> Self
Creates a new rect that increased the bottom from the rect.
Sourcepub fn extend_left(self, increase: u32) -> Self
pub fn extend_left(self, increase: u32) -> Self
Creates a new rect that increased the left from the rect.