Struct egui::Rect [−][src]
Expand description
A rectangular region of space.
Normally given in points, e.g. logical pixels.
Fields
min: Pos2
max: Pos2
Implementations
Infinite rectangle that contains everything.
The inverse of Self::EVERYTHING
: stretches from positive infinity to negative infinity.
Contains no points.
This is useful as the seed for bounding bounding boxes.
let inf = f32::INFINITY;
assert!(Rect::NOTHING.size() == Vec2::splat(-inf));
assert!(Rect::NOTHING.contains(pos2(0.0, 0.0)) == false);
Example:
let mut rect = Rect::NOTHING;
rect.extend_with(pos2(2.0, 1.0));
rect.extend_with(pos2(0.0, 3.0));
assert_eq!(rect, Rect::from_min_max(pos2(0.0, 1.0), pos2(2.0, 3.0)))
Use Rect::EVERYTHING
Use Rect::NOTHING
Use Rect::NAN
A Rect
that contains every point to the right of the given X coordinate.
A Rect
that contains every point to the left of the given X coordinate.
A Rect
that contains every point below a certain y coordinate
A Rect
that contains every point above a certain y coordinate
Expand by this much in each direction, keeping the center
Expand by this much in each direction, keeping the center
Shrink by this much in each direction, keeping the center
Shrink by this much in each direction, keeping the center
The intersection of two Rect
, i.e. the area covered by both.
keep min
Keep size
Return the given points clamped to be inside the rectangle
Panics if Self::is_negative
.
Expand to include the given x coordinate
Expand to include the given y coordinate
Width / height
aspect_ratio < 1
: portrait / highaspect_ratio = 1
: squareaspect_ratio > 1
: landscape / wide
[2, 1]
for wide screen, and [1, 2]
for portrait, etc.
At least one dimension = 1, the other >= 1
Returns the proportions required to letter-box a square view area.
Use is_negative instead
width < 0 || height < 0
Use !is_negative() instead
width > 0 && height > 0
max.y
max.y
Trait Implementations
from (min, max) or (left top, right bottom)
Auto Trait Implementations
impl RefUnwindSafe for Rect
impl UnwindSafe for Rect
Blanket Implementations
Mutably borrows from an owned value. Read more