# [−][src]Struct conrod::position::rect::Rect

```pub struct Rect {
pub x: Range,
pub y: Range,
}```

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

This is a conrod-specific Rectangle in that it's designed to help with layout.

## Fields

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

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

## Methods

### `impl Rect`[src]

#### `pub fn from_xy_dim(xy: Point, dim: Dimensions) -> Self`[src]

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

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

Construct a Rect from the coordinates of two points.

#### `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`[src]

The Rect that encompass the two given sets of Rect.

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

The position in the middle of the x bounds.

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

The position in the middle of the y bounds.

#### `pub fn xy(&self) -> Point`[src]

The xy position in the middle of the bounds.

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

The centered x and y coordinates as a tuple.

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

The width of the Rect.

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

The height of the Rect.

#### `pub fn dim(&self) -> Dimensions`[src]

The total dimensions of the Rect.

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

The width and height of the Rect as a tuple.

#### `pub fn xy_dim(&self) -> (Point, Dimensions)`[src]

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

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

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

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

The length of the longest side of the rectangle.

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

The Rect's lowest y value.

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

The Rect's highest y value.

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

The Rect's lowest x value.

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

The Rect's highest x value.

#### `pub fn top_left(&self) -> Point`[src]

The top left corner Point.

#### `pub fn bottom_left(&self) -> Point`[src]

The bottom left corner Point.

#### `pub fn top_right(&self) -> Point`[src]

The top right corner Point.

#### `pub fn bottom_right(&self) -> Point`[src]

The bottom right corner Point.

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

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

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

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

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

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

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

Shift the Rect along the x axis.

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

Shift the Rect along the y axis.

#### `pub fn shift(self, xy: Point) -> Self`[src]

Shift the Rect by the given Point.

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

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

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

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

#### `pub fn relative_to(self, xy: Point) -> Self`[src]

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

#### `pub fn is_over(&self, xy: Point) -> bool`[src]

Does the given point touch the Rectangle.

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

The Rect with some padding applied to the left edge.

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

The Rect with some padding applied to the right edge.

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

The rect with some padding applied to the bottom edge.

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

The Rect with some padding applied to the top edge.

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

The Rect with some padding amount applied to each edge.

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

The Rect with some padding applied.

#### `pub fn stretch_to_point(self, point: Point) -> 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, xy: Point) -> Corner`[src]

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

## Trait Implementations

### `impl PartialEq<Rect> for Rect`[src]

#### `fn eq(&self, other: &Rect) -> bool`[src]

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

#### `fn ne(&self, other: &Rect) -> bool`[src]

This method tests for `!=`.

### `impl Clone for Rect`[src]

#### `fn clone(&self) -> Rect`[src]

Returns a copy of the value. Read more

#### `fn clone_from(&mut self, source: &Self)`1.0.0[src]

Performs copy-assignment from `source`. Read more

### `impl Debug for Rect`[src]

#### `fn fmt(&self, f: &mut Formatter) -> Result`[src]

Formats the value using the given formatter. Read more

## Blanket Implementations

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

#### `fn into(self) -> U`[src]

Performs the conversion.

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

#### `fn to_owned(&self) -> T`[src]

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

#### `fn clone_into(&self, target: &mut T)`[src]

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

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

### `impl<T> From for T`[src]

#### `fn from(t: T) -> T`[src]

Performs the conversion.

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

#### `type Error = !`

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

The type returned in the event of a conversion error.

#### `fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>`[src]

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

Performs the conversion.

### `impl<T> Borrow for T where    T: ?Sized, `[src]

#### `fn borrow(&self) -> &T`[src]

Immutably borrows from an owned value. Read more

### `impl<T> BorrowMut for T where    T: ?Sized, `[src]

#### `fn borrow_mut(&mut self) -> &mut T`[src]

Mutably borrows from an owned value. Read more

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

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

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

The type returned in the event of a conversion error.

#### `fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>`[src]

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

Performs the conversion.

### `impl<T> Any for T where    T: 'static + ?Sized, `[src]

#### `fn get_type_id(&self) -> TypeId`[src]

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

this method will likely be replaced by an associated static

Gets the `TypeId` of `self`. Read more

### `impl<T> Content for T where    T: Copy, `[src]

#### `type Owned = T`

A type that holds a sized version of the content.

#### `fn read<F, E>(size: usize, f: F) -> Result<T, E> where    F: FnOnce(&mut T) -> Result<(), E>, `[src]

Prepares an output buffer, then turns this buffer into an `Owned`.

#### `fn get_elements_size() -> usize`[src]

Returns the size of each element.

#### `fn to_void_ptr(&self) -> *const ()`[src]

Produces a pointer to the data.

#### `fn ref_from_ptr(ptr: *mut (), size: usize) -> Option<*mut T>`[src]

Builds a pointer to this type from a raw pointer.

#### `fn is_size_suitable(size: usize) -> bool`[src]

Returns true if the size is suitable to store a type like this.

### `impl<T> Downcast for T where    T: Any, `[src]

#### `fn into_any(self: Box<T>) -> Box<dyn Any + 'static>`[src]

Convert `Box<Trait>` (where `Trait: Downcast`) to `Box<Any>`. `Box<Any>` can then be further `downcast` into `Box<ConcreteType>` where `ConcreteType` implements `Trait`. Read more

#### `fn as_any(&self) -> &(dyn Any + 'static)`[src]

Convert `&Trait` (where `Trait: Downcast`) to `&Any`. This is needed since Rust cannot generate `&Any`'s vtable from `&Trait`'s. Read more

#### `fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)`[src]

Convert `&mut Trait` (where `Trait: Downcast`) to `&Any`. This is needed since Rust cannot generate `&mut Any`'s vtable from `&mut Trait`'s. Read more