pub struct Rect {
pub x: f32,
pub y: f32,
pub width: f32,
pub height: f32,
}Expand description
Rect is an axis-aligned rectangle in Valo’s y-down coordinate system.
Fields§
§x: f32x is the left edge.
y: f32y is the top edge.
width: f32width is the horizontal extent.
height: f32height is the vertical extent.
Implementations§
Source§impl Rect
impl Rect
Sourcepub const EVERYTHING: Rect
pub const EVERYTHING: Rect
EVERYTHING is the conservative bound used when content cannot be bounded.
Sourcepub const fn new(x: f32, y: f32, width: f32, height: f32) -> Self
pub const fn new(x: f32, y: f32, width: f32, height: f32) -> Self
new creates a rectangle from its top-left origin and size.
Sourcepub fn from_ltrb(l: f32, t: f32, r: f32, b: f32) -> Self
pub fn from_ltrb(l: f32, t: f32, r: f32, b: f32) -> Self
from_ltrb creates a rectangle from its left, top, right, and bottom edges.
Sourcepub fn from_origin_size(origin: Point, size: Size) -> Self
pub fn from_origin_size(origin: Point, size: Size) -> Self
from_origin_size creates a rectangle from an origin and size.
Sourcepub fn union(&self, other: &Rect) -> Rect
pub fn union(&self, other: &Rect) -> Rect
union returns the smallest rectangle containing both rectangles.
Empty rectangles act as the identity.
Sourcepub fn intersect(&self, other: &Rect) -> Option<Rect>
pub fn intersect(&self, other: &Rect) -> Option<Rect>
intersect returns the overlapping area or None when there is none.
Sourcepub fn intersects(&self, other: &Rect) -> bool
pub fn intersects(&self, other: &Rect) -> bool
intersects reports whether the rectangles overlap with positive area.
Sourcepub fn contains(&self, p: Point) -> bool
pub fn contains(&self, p: Point) -> bool
contains reports whether a point lies within the half-open rectangle.
Left and top edges are included; right and bottom edges are excluded.
Sourcepub fn contains_inclusive(&self, p: Point) -> bool
pub fn contains_inclusive(&self, p: Point) -> bool
contains_inclusive reports whether a point lies within or on every edge.