# [−][src]Struct nannou::geom::rect::Rect

```pub struct Rect<S = Default> {
pub x: Range<S>,
pub y: Range<S>,
}```

Defines a Rectangle's bounds across the x and y axes.

## Fields

`x: Range<S>`

The start and end positions of the Rectangle on the x axis.

`y: Range<S>`

The start and end positions of the Rectangle on the y axis.

## Implementations

### `impl<S> Rect<S> where    S: BaseNum, `[src]

#### `pub fn from_xy_wh(p: Point2<S>, wh: Vector2<S>) -> Self`[src]

Construct a Rect from a given `Point` and `Dimensions`.

#### `pub fn from_x_y_w_h(x: S, y: S, w: S, h: S) -> Self`[src]

Construct a Rect from the given `x` `y` coordinates and `w` `h` dimensions.

#### `pub fn from_wh(wh: Vector2<S>) -> Self`[src]

Construct a Rect at origin with the given dimensions.

#### `pub fn from_w_h(w: S, h: S) -> Self`[src]

Construct a Rect at origin with the given width and height.

#### `pub fn from_corners(a: Point2<S>, b: Point2<S>) -> Self`[src]

Construct a Rect from the coordinates of two points.

#### `pub fn absolute(self) -> Self`[src]

Converts `self` to an absolute `Rect` so that the magnitude of each range is always positive.

#### `pub fn overlap(self, other: Self) -> Option<Self>`[src]

The Rect representing the area in which two Rects overlap.

#### `pub fn max(self, other: Self) -> Self where    S: Float, `[src]

The Rect that encompass the two given sets of Rect.

#### `pub fn x(&self) -> S`[src]

The position in the middle of the x bounds.

#### `pub fn y(&self) -> S`[src]

The position in the middle of the y bounds.

#### `pub fn xy(&self) -> Point2<S>`[src]

The xy position in the middle of the bounds.

#### `pub fn x_y(&self) -> (S, S)`[src]

The centered x and y coordinates as a tuple.

#### `pub fn bottom(&self) -> S`[src]

The Rect's lowest y value.

#### `pub fn top(&self) -> S`[src]

The Rect's highest y value.

#### `pub fn left(&self) -> S`[src]

The Rect's lowest x value.

#### `pub fn right(&self) -> S`[src]

The Rect's highest x value.

#### `pub fn top_left(&self) -> Point2<S>`[src]

The top left corner Point.

#### `pub fn bottom_left(&self) -> Point2<S>`[src]

The bottom left corner Point.

#### `pub fn top_right(&self) -> Point2<S>`[src]

The top right corner Point.

#### `pub fn bottom_right(&self) -> Point2<S>`[src]

The bottom right corner Point.

#### `pub fn mid_left(&self) -> Point2<S>`[src]

The middle of the left edge.

#### `pub fn mid_top(&self) -> Point2<S>`[src]

The middle of the top edge.

#### `pub fn mid_right(&self) -> Point2<S>`[src]

The middle of the right edge.

#### `pub fn mid_bottom(&self) -> Point2<S>`[src]

The middle of the bottom edge.

#### `pub fn l_r_b_t(&self) -> (S, S, S, S)`[src]

The edges of the Rect in a tuple (left, right, bottom, top).

#### `pub fn shift_x(self, x: S) -> Self`[src]

Shift the Rect along the x axis.

#### `pub fn shift_y(self, y: S) -> Self`[src]

Shift the Rect along the y axis.

#### `pub fn shift(self, v: Vector2<S>) -> Self`[src]

Shift the Rect by the given vector.

#### `pub fn contains(&self, p: Point2<S>) -> bool`[src]

Does the given point touch the Rectangle.

#### `pub fn stretch_to_point(self, p: Point2<S>) -> Self`[src]

Stretches the closest edge(s) to the given point if the point lies outside of the Rect area.

#### `pub fn left_of(self, other: Self) -> Self`[src]

Align `self`'s right edge with the left edge of the `other` Rect.

#### `pub fn right_of(self, other: Self) -> Self`[src]

Align `self`'s left edge with the right dge of the `other` Rect.

#### `pub fn below(self, other: Self) -> Self`[src]

Align `self`'s top edge with the bottom edge of the `other` Rect.

#### `pub fn above(self, other: Self) -> Self`[src]

Align `self`'s bottom edge with the top edge of the `other` Rect.

#### `pub fn align_x_of(self, align: Align, other: Self) -> Self`[src]

Align `self` to `other` along the x axis in accordance with the given `Align` variant.

#### `pub fn align_y_of(self, align: Align, other: Self) -> Self`[src]

Align `self` to `other` along the y axis in accordance with the given `Align` variant.

#### `pub fn align_left_of(self, other: Self) -> Self`[src]

Align `self`'s left edge with the left edge of the `other` Rect.

#### `pub fn align_middle_x_of(self, other: Self) -> Self`[src]

Align the middle of `self` with the middle of the `other` Rect along the x axis.

#### `pub fn align_right_of(self, other: Self) -> Self`[src]

Align `self`'s right edge with the right edge of the `other` Rect.

#### `pub fn align_bottom_of(self, other: Self) -> Self`[src]

Align `self`'s bottom edge with the bottom edge of the `other` Rect.

#### `pub fn align_middle_y_of(self, other: Self) -> Self`[src]

Align the middle of `self` with the middle of the `other` Rect along the y axis.

#### `pub fn align_top_of(self, other: Self) -> Self`[src]

Align `self`'s top edge with the top edge of the `other` Rect.

#### `pub fn top_left_of(self, other: Self) -> Self`[src]

Place `self` along the top left edges of the `other` Rect.

#### `pub fn top_right_of(self, other: Self) -> Self`[src]

Place `self` along the top right edges of the `other` Rect.

#### `pub fn bottom_left_of(self, other: Self) -> Self`[src]

Place `self` along the bottom left edges of the `other` Rect.

#### `pub fn bottom_right_of(self, other: Self) -> Self`[src]

Place `self` along the bottom right edges of the `other` Rect.

#### `pub fn mid_top_of(self, other: Self) -> Self`[src]

Place `self` in the middle of the top edge of the `other` Rect.

#### `pub fn mid_bottom_of(self, other: Self) -> Self`[src]

Place `self` in the middle of the bottom edge of the `other` Rect.

#### `pub fn mid_left_of(self, other: Self) -> Self`[src]

Place `self` in the middle of the left edge of the `other` Rect.

#### `pub fn mid_right_of(self, other: Self) -> Self`[src]

Place `self` in the middle of the right edge of the `other` Rect.

#### `pub fn middle_of(self, other: Self) -> Self`[src]

Place `self` directly in the middle of the `other` Rect.

#### `pub fn closest_corner(&self, p: Point2<S>) -> Corner`[src]

Return the Corner of `self` that is closest to the given Point.

#### `pub fn corners(&self) -> Quad<Point2<S>>`[src]

The four corners of the `Rect`.

#### `pub fn corners_iter(&self) -> Corners<S>ⓘNotable traits for Corners<S>impl<S> Iterator for Corners<S> where    S: BaseNum,  type Item = Point2<S>;`[src]

An iterator yielding the four corners of the `Rect`.

#### `pub fn triangles(&self) -> (Tri<Point2<S>>, Tri<Point2<S>>)`[src]

Return two `Tri`s that represent the `Rect`.

#### `pub fn triangles_iter(self) -> Triangles<S>`[src]

An iterator yielding the `Rect`'s two `Tri`'s.

#### `pub fn subdivision_ranges(&self) -> SubdivisionRanges<S>`[src]

The four ranges used for the `Rect`'s four subdivisions.

#### `pub fn subdivisions(&self) -> [Self; 4]`[src]

Divide the `Rect` in half along the x and y axes and return the four subdivisions.

Subdivisions are yielded in the following order:

1. Bottom left
2. Bottom right
3. Top left
4. Top right

#### `pub fn subdivisions_iter(&self) -> Subdivisions<S>ⓘNotable traits for Subdivisions<S>impl<S> Iterator for Subdivisions<S> where    S: Copy,  type Item = Rect<S>;`[src]

The same as `subdivisions` but each subdivision is yielded via the returned `Iterator`.

#### `pub fn corner_at_index(&self, index: u8) -> Option<Point2<S>>`[src]

Produce the corner at the given index.

### `impl<S> Rect<S> where    S: BaseNum + Neg<Output = S>, `[src]

#### `pub fn w(&self) -> S`[src]

The width of the Rect.

#### `pub fn h(&self) -> S`[src]

The height of the Rect.

#### `pub fn wh(&self) -> Vector2<S>`[src]

The total dimensions of the Rect.

#### `pub fn w_h(&self) -> (S, S)`[src]

The width and height of the Rect as a tuple.

#### `pub fn xy_wh(&self) -> (Point2<S>, Vector2<S>)`[src]

Convert the Rect to a `Point` and `Dimensions`.

#### `pub fn x_y_w_h(&self) -> (S, S, S, S)`[src]

The Rect's centered coordinates and dimensions in a tuple.

#### `pub fn len(&self) -> S`[src]

The length of the longest side of the rectangle.

#### `pub fn l_t_w_h(&self) -> (S, S, S, S)`[src]

The left and top edges of the Rect along with the width and height.

#### `pub fn l_b_w_h(&self) -> (S, S, S, S)`[src]

The left and bottom edges of the Rect along with the width and height.

#### `pub fn pad_left(self, pad: S) -> Self`[src]

The Rect with some padding applied to the left edge.

#### `pub fn pad_right(self, pad: S) -> Self`[src]

The Rect with some padding applied to the right edge.

#### `pub fn pad_bottom(self, pad: S) -> Self`[src]

The rect with some padding applied to the bottom edge.

#### `pub fn pad_top(self, pad: S) -> Self`[src]

The Rect with some padding applied to the top edge.

#### `pub fn pad(self, pad: S) -> Self`[src]

The Rect with some padding amount applied to each edge.

#### `pub fn padding(self, padding: Padding<S>) -> Self`[src]

The Rect with some padding applied.

#### `pub fn relative_to_x(self, x: S) -> Self`[src]

Returns a `Rect` with a position relative to the given position on the x axis.

#### `pub fn relative_to_y(self, y: S) -> Self`[src]

Returns a `Rect` with a position relative to the given position on the y axis.

#### `pub fn relative_to(self, p: Point2<S>) -> Self`[src]

Returns a `Rect` with a position relative to the given position.

#### `pub fn invert_x(self) -> Self`[src]

Invert the x axis (aka flip around the y axis).

#### `pub fn invert_y(self) -> Self`[src]

Invert the y axis (aka flip around the x axis).

## Blanket Implementations

### `impl<T> ToOwned for T where    T: Clone, `[src]

#### `type Owned = T`

The resulting type after obtaining ownership.

### `impl<T, U> TryFrom<U> for T where    U: Into<T>, `[src]

#### `type Error = Infallible`

The type returned in the event of a conversion error.

### `impl<T, U> TryInto<U> for T where    U: TryFrom<T>, `[src]

#### `type Error = <U as TryFrom<T>>::Error`

The type returned in the event of a conversion error.