Struct egui::Rect [−]
Expand description
A rectangular region of space.
Normally given in points, e.g. logical pixels.
Fields
min: Pos2max: Pos2Implementations
impl Rect
impl Rectpub const EVERYTHING: Rect
pub const EVERYTHING: RectInfinite 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)))
pub fn everything() -> RectUse Rect::EVERYTHING
Use Rect::NOTHING
Use Rect::NAN
pub const fn from_min_max(min: Pos2, max: Pos2) -> Rectpub fn from_min_size(min: Pos2, size: Vec2) -> Rectpub fn from_center_size(center: Pos2, size: Vec2) -> Rectpub fn from_x_y_ranges(
x_range: RangeInclusive<f32>,
y_range: RangeInclusive<f32>
) -> Rectpub fn from_two_pos(a: Pos2, b: Pos2) -> Rectpub fn everything_right_of(left_x: f32) -> Rect
pub fn everything_right_of(left_x: f32) -> RectA Rect that contains every point to the right of the given X coordinate.
pub fn everything_left_of(right_x: f32) -> Rect
pub fn everything_left_of(right_x: f32) -> RectA Rect that contains every point to the left of the given X coordinate.
pub fn everything_below(top_y: f32) -> Rect
pub fn everything_below(top_y: f32) -> RectA Rect that contains every point below a certain y coordinate
pub fn everything_above(bottom_y: f32) -> Rect
pub fn everything_above(bottom_y: f32) -> RectA Rect that contains every point above a certain y coordinate
The intersection of two Rect, i.e. the area covered by both.
pub fn intersects(self, other: Rect) -> boolpub fn set_height(&mut self, h: f32)
pub fn set_height(&mut self, h: f32)keep min
pub fn set_center(&mut self, center: Pos2)
pub fn set_center(&mut self, center: Pos2)Keep size
pub fn contains_rect(&self, other: Rect) -> boolReturn the given points clamped to be inside the rectangle
Panics if Self::is_negative.
pub fn extend_with(&mut self, p: Pos2)pub fn extend_with_x(&mut self, x: f32)
pub fn extend_with_x(&mut self, x: f32)Expand to include the given x coordinate
pub fn extend_with_y(&mut self, y: f32)
pub fn extend_with_y(&mut self, y: f32)Expand to include the given y coordinate
pub fn aspect_ratio(&self) -> f32
pub fn aspect_ratio(&self) -> f32Width / height
aspect_ratio < 1: portrait / highaspect_ratio = 1: squareaspect_ratio > 1: landscape / wide
pub fn square_proportions(&self) -> Vec2
pub fn square_proportions(&self) -> Vec2[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.
pub fn x_range(&self) -> RangeInclusive<f32>pub fn y_range(&self) -> RangeInclusive<f32>pub fn bottom_up_range(&self) -> RangeInclusive<f32>Use is_negative instead
pub fn is_negative(&self) -> bool
pub fn is_negative(&self) -> boolwidth < 0 || height < 0
pub fn is_non_negative(&self) -> boolUse !is_negative() instead
pub fn is_positive(&self) -> bool
pub fn is_positive(&self) -> boolwidth > 0 && height > 0
impl Rect
impl Rectpub fn bottom_mut(&mut self) -> &mut f32
pub fn bottom_mut(&mut self) -> &mut f32max.y
pub fn set_bottom(&mut self, y: f32)
pub fn set_bottom(&mut self, y: f32)max.y
pub fn center_top(&self) -> Pos2pub fn left_center(&self) -> Pos2pub fn right_center(&self) -> Pos2pub fn left_bottom(&self) -> Pos2pub fn center_bottom(&self) -> Pos2pub fn right_bottom(&self) -> Pos2Trait Implementations
from (min, max) or (left top, right bottom)
impl StructuralEq for Rectimpl StructuralPartialEq for RectAuto Trait Implementations
impl RefUnwindSafe for Rectimpl UnwindSafe for RectBlanket Implementations
Mutably borrows from an owned value. Read more