Struct egui::Rect[]

#[repr(C)]
pub struct Rect { pub min: Pos2, pub max: Pos2, }
Expand description

A rectangular region of space.

Normally given in points, e.g. logical pixels.

Fields

min: Pos2max: 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)))

An invalid Rect filled with f32::NAN;

Bounding-box around the points

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

Rotate the bounds (will expand the Rect)

keep min

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

The union of two bounding rectangle, i.e. the minimum Rect that contains both input rectangles.

The intersection of two Rect, i.e. the area covered by both.

Width / height

  • aspect_ratio < 1: portrait / high
  • aspect_ratio = 1: square
  • aspect_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.

width < 0 || height < 0

width > 0 && height > 0

True if all members are also finite.

True if any member is NaN.

min.x

min.x

min.x

max.x

max.x

max.x

min.y

min.y

min.y

max.y

max.y

max.y

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Deserialize this value from the given Serde deserializer. Read more

from (min, max) or (left top, right bottom)

Performs the conversion.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.