# Struct emath::Rect[−][src]

```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: 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)))```

An invalid `Rect` filled with `f32::NAN`;

👎 Deprecated:

Use Rect::EVERYTHING

👎 Deprecated:

Use Rect::NOTHING

👎 Deprecated:

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 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 / 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.

👎 Deprecated:

`width < 0 || height < 0`

👎 Deprecated:

`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

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 `!=`.

## 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`)