Struct rich_sdl2_rust::geo::Rect
source · 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.
Trait Implementations§
source§impl Ord for Rect
impl Ord for Rect
source§impl PartialEq<Rect> for Rect
impl PartialEq<Rect> for Rect
source§impl PartialOrd<Rect> for Rect
impl PartialOrd<Rect> for Rect
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read more