Expand description
A rectangle.
Fields§
§pos: Point
The position of the top left corner of the rectangle.
size: Size
The width and height of the rectangle.
Implementations§
source§impl Rect
impl Rect
sourcepub fn centered(self) -> Rect
pub fn centered(self) -> Rect
Computes a rectangle with quadruple the surface area of self and with center (self.x, self.y).
sourcepub fn contains<T: Into<Point>>(&self, point: T) -> bool
pub fn contains<T: Into<Point>>(&self, point: T) -> bool
Compute whether or not the point is inside the rectangle.
sourcepub fn new_circle<T: Into<Point>>(center: T, radius: Scalar) -> Rect
pub fn new_circle<T: Into<Point>>(center: T, radius: Scalar) -> Rect
Create a rectangle that circumscribes the given circle.
sourcepub fn new_square<T: Into<Point>>(pos: T, len: Scalar) -> Rect
pub fn new_square<T: Into<Point>>(pos: T, len: Scalar) -> Rect
Create a square rectangle with sides of length len and top left corner at pos.
sourcepub fn margin(self, m: Scalar) -> Rect
pub fn margin(self, m: Scalar) -> Rect
Computes a rectangle whose perimeter forms the inside edge of margin with size m for self.
sourcepub fn relative<T: Into<Point>>(self, v: T) -> Rect
pub fn relative<T: Into<Point>>(self, v: T) -> Rect
Computes a rectangle translated (slid) in the direction of the vector a distance relative to the size of the rectangle. For example, self.relative([1.0, 1.0]) returns a rectangle one rectangle to the right and down from the original.