pub struct Rect {
pub x: i64,
pub y: i64,
pub width: i64,
pub height: i64,
}
Expand description
Rect
is a struct that represents a rectangle.
It has four fields: x
, y
, width
, and height
.
x
and y
represent the coordinates of the top left corner of the rectangle.
width
and height
represent the dimensions of the rectangle.
Fields§
§x: i64
§y: i64
§width: i64
§height: i64
Implementations§
Source§impl Rect
impl Rect
Sourcepub fn local_point(&self) -> Result<(i64, i64), PebblesError>
pub fn local_point(&self) -> Result<(i64, i64), PebblesError>
Returns a random point within the rectangle using a triangular distribution.
The point is relative to the top left corner of the rectangle (i.e., local to the rectangle). The distribution is triangular with the mode at the center of the rectangle.
§Errors
Returns PebblesError::MathError
if there is an error generating the triangular distribution.
Sourcepub fn world_point(&self) -> Result<(i64, i64), PebblesError>
pub fn world_point(&self) -> Result<(i64, i64), PebblesError>
Returns a random point within the rectangle using a triangular distribution.
The point is relative to the origin of the coordinate system (i.e., global). The distribution is triangular with the mode at the center of the rectangle.
§Errors
Returns PebblesError::MathError
if there is an error generating the triangular distribution.
pub fn overlaps(&self, other: &Rect) -> bool
Sourcepub fn overlapping_rect(&self, other: &Rect) -> Option<Rect>
pub fn overlapping_rect(&self, other: &Rect) -> Option<Rect>
Returns a new Rect
that represents the overlapping area of two rectangles.
If the rectangles do not overlap, it returns None
.