#[repr(C)]pub struct Rect {
pub x0: f32,
pub y0: f32,
pub x1: f32,
pub y1: f32,
}Expand description
An axis-aligned rectangle in pixels, y down, stored as its four edges.
Edges, not origin plus size, so rectangles built from shared edges tile exactly: with
half-open contains, a point on a shared edge belongs to exactly one of
them, even after both are translated by the same amount. (Origin plus
size recomputes x + width, which can miss the original edge by a rounding step.)
A rectangle whose right edge is not past its left (or bottom past top), or with a NaN edge, is empty and contains no point.
Fields§
§x0: f32Left edge.
y0: f32Top edge.
x1: f32Right edge.
y1: f32Bottom edge.
Implementations§
Source§impl Rect
impl Rect
Sourcepub const EVERYTHING: Self
pub const EVERYTHING: Self
Every point: what a clip that clips nothing is.
Sourcepub fn new(x: f32, y: f32, width: f32, height: f32) -> Self
pub fn new(x: f32, y: f32, width: f32, height: f32) -> Self
The rectangle with top-left corner (x, y) and size width x height.
Sourcepub fn from_edges(left: f32, top: f32, right: f32, bottom: f32) -> Self
pub fn from_edges(left: f32, top: f32, right: f32, bottom: f32) -> Self
The rectangle spanning the given edges, in either order. NaN edges are kept, giving an empty rectangle rather than a silently different one.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Whether the rectangle covers no area (also true with a NaN edge).