# Rectangle struct

Namespace: [Eto.Drawing](https://eto.picoe.ca/api/namespace/eto.drawing.md) · Assembly: [Eto](https://eto.picoe.ca/api/assembly/eto.md)

```cs
[TypeConverter(RectangleConverterInternal)]
public struct Rectangle : IEquatable<Rectangle>
```

Represents a rectangle with a location (X, Y) and size (Width, Height) components.

**Remarks:** A rectangle is defined by a location (X, Y) and a size (Width, Height). The width and/or height can be negative.

## Constructors

- [Rectangle](https://eto.picoe.ca/api/type/eto.drawing.rectangle/ctor.md): (5 overloads) Initializes a new instance of the Rectangle class with the specified `x`, `y`, `width`, and `height`

## Fields

- [Empty](https://eto.picoe.ca/api/type/eto.drawing.rectangle/empty.md): (static) Gets an empty rectangle with zero X, Y, Width, and Height components

## Properties

- [Bottom](https://eto.picoe.ca/api/type/eto.drawing.rectangle/bottom.md): Gets or sets the logical bottom of this rectangle (Y + Height if Height is positive, Y + 1 if negative)
- [BottomLeft](https://eto.picoe.ca/api/type/eto.drawing.rectangle/bottomleft.md): Gets or sets the point at the [Rectangle.Bottom](https://eto.picoe.ca/api/type/eto.drawing.rectangle/bottom.md) and [Rectangle.Left](https://eto.picoe.ca/api/type/eto.drawing.rectangle/left.md) of the rectangle
- [BottomRight](https://eto.picoe.ca/api/type/eto.drawing.rectangle/bottomright.md): Gets or sets the point at the [Rectangle.Bottom](https://eto.picoe.ca/api/type/eto.drawing.rectangle/bottom.md) and [Rectangle.Right](https://eto.picoe.ca/api/type/eto.drawing.rectangle/right.md) of the rectangle
- [Center](https://eto.picoe.ca/api/type/eto.drawing.rectangle/center.md): Gets or sets the rectangle's center position
- [EndLocation](https://eto.picoe.ca/api/type/eto.drawing.rectangle/endlocation.md): Gets the ending location of this rectangle
- [Height](https://eto.picoe.ca/api/type/eto.drawing.rectangle/height.md): Gets or sets the Height of this rectangle
- [InnerBottom](https://eto.picoe.ca/api/type/eto.drawing.rectangle/innerbottom.md): Gets or sets the bottom of the rectangle that is inside the bounds
- [InnerBottomLeft](https://eto.picoe.ca/api/type/eto.drawing.rectangle/innerbottomleft.md): Gets or sets the point at the [Rectangle.InnerBottom](https://eto.picoe.ca/api/type/eto.drawing.rectangle/innerbottom.md) and [Rectangle.Left](https://eto.picoe.ca/api/type/eto.drawing.rectangle/left.md) of the rectangle
- [InnerBottomRight](https://eto.picoe.ca/api/type/eto.drawing.rectangle/innerbottomright.md): Gets or sets the point at the [Rectangle.InnerBottom](https://eto.picoe.ca/api/type/eto.drawing.rectangle/innerbottom.md) and [Rectangle.InnerRight](https://eto.picoe.ca/api/type/eto.drawing.rectangle/innerright.md) of the rectangle
- [InnerRight](https://eto.picoe.ca/api/type/eto.drawing.rectangle/innerright.md): Gets or sets the right of the rectangle that is inside the bounds
- [InnerTopRight](https://eto.picoe.ca/api/type/eto.drawing.rectangle/innertopright.md): Gets or sets the point at the [Rectangle.Top](https://eto.picoe.ca/api/type/eto.drawing.rectangle/top.md) and [Rectangle.InnerRight](https://eto.picoe.ca/api/type/eto.drawing.rectangle/innerright.md) of the rectangle
- [IsEmpty](https://eto.picoe.ca/api/type/eto.drawing.rectangle/isempty.md): Gets a value indicating that the [Rectangle.Size](https://eto.picoe.ca/api/type/eto.drawing.rectangle/size.md) of this rectangle is empty (either the width or height are zero)
- [IsZero](https://eto.picoe.ca/api/type/eto.drawing.rectangle/iszero.md): Gets a value indicating that both the `` and [Rectangle.Size](https://eto.picoe.ca/api/type/eto.drawing.rectangle/size.md) of this rectangle are zero
- [Left](https://eto.picoe.ca/api/type/eto.drawing.rectangle/left.md): Gets or sets the logical left of this rectangle (X co-ordinate if Width is positive, X + Width if negative)
- [Location](https://eto.picoe.ca/api/type/eto.drawing.rectangle/location.md): Gets the location of this rectangle
- [MiddleBottom](https://eto.picoe.ca/api/type/eto.drawing.rectangle/middlebottom.md): Gets or sets the point at the [Rectangle.MiddleX](https://eto.picoe.ca/api/type/eto.drawing.rectangle/middlex.md) and [Rectangle.Bottom](https://eto.picoe.ca/api/type/eto.drawing.rectangle/bottom.md) of the rectangle
- [MiddleLeft](https://eto.picoe.ca/api/type/eto.drawing.rectangle/middleleft.md): Gets or sets the point at the [Rectangle.Left](https://eto.picoe.ca/api/type/eto.drawing.rectangle/left.md) and [Rectangle.MiddleY](https://eto.picoe.ca/api/type/eto.drawing.rectangle/middley.md) of the rectangle
- [MiddleRight](https://eto.picoe.ca/api/type/eto.drawing.rectangle/middleright.md): Gets or sets the point at the [Rectangle.Right](https://eto.picoe.ca/api/type/eto.drawing.rectangle/right.md) and [Rectangle.MiddleY](https://eto.picoe.ca/api/type/eto.drawing.rectangle/middley.md) of the rectangle
- [MiddleTop](https://eto.picoe.ca/api/type/eto.drawing.rectangle/middletop.md): Gets or sets the point at the [Rectangle.MiddleX](https://eto.picoe.ca/api/type/eto.drawing.rectangle/middlex.md) and [Rectangle.Top](https://eto.picoe.ca/api/type/eto.drawing.rectangle/top.md) of the rectangle
- [MiddleX](https://eto.picoe.ca/api/type/eto.drawing.rectangle/middlex.md): Gets or sets the rectangle's middle horizontal position
- [MiddleY](https://eto.picoe.ca/api/type/eto.drawing.rectangle/middley.md): Gets or sets the rectangle's middle vertical position
- [Right](https://eto.picoe.ca/api/type/eto.drawing.rectangle/right.md): Gets or sets the logical right of this rectangle (X + Width if Width is positive, X + 1 if negative)
- [Size](https://eto.picoe.ca/api/type/eto.drawing.rectangle/size.md): Gets or sets the size of the rectangle
- [Top](https://eto.picoe.ca/api/type/eto.drawing.rectangle/top.md): Gets or sets the logical top of this rectangle (Y co-ordinate if Height is positive, Y + Height if negative)
- [TopLeft](https://eto.picoe.ca/api/type/eto.drawing.rectangle/topleft.md): Gets or sets the point at the [Rectangle.Top](https://eto.picoe.ca/api/type/eto.drawing.rectangle/top.md) and [Rectangle.Left](https://eto.picoe.ca/api/type/eto.drawing.rectangle/left.md) of the rectangle
- [TopRight](https://eto.picoe.ca/api/type/eto.drawing.rectangle/topright.md): Gets or sets the point at the [Rectangle.Top](https://eto.picoe.ca/api/type/eto.drawing.rectangle/top.md) and [Rectangle.Right](https://eto.picoe.ca/api/type/eto.drawing.rectangle/right.md) of the rectangle
- [Width](https://eto.picoe.ca/api/type/eto.drawing.rectangle/width.md): Gets or sets the Width of this rectangle
- [X](https://eto.picoe.ca/api/type/eto.drawing.rectangle/x.md): Gets or sets the X co-ordinate of the [Rectangle.Location](https://eto.picoe.ca/api/type/eto.drawing.rectangle/location.md) of this rectangle
- [Y](https://eto.picoe.ca/api/type/eto.drawing.rectangle/y.md): Gets or sets the Y co-ordinate of the [Rectangle.Location](https://eto.picoe.ca/api/type/eto.drawing.rectangle/location.md) of this rectangle

## Methods

- [Align](https://eto.picoe.ca/api/type/eto.drawing.rectangle/align.md): (4 overloads) Aligns the `rectangle` to a grid of the specified `gridWidth` and `gridHeight`
- [Ceiling](https://eto.picoe.ca/api/type/eto.drawing.rectangle/ceiling.md): (static) Converts a floating point `rectangle` to an integral [Rectangle](https://eto.picoe.ca/api/type/eto.drawing.rectangle.md) by getting the smallest integral value of X, Y, Width, and Height
- [Contains](https://eto.picoe.ca/api/type/eto.drawing.rectangle/contains.md): (3 overloads) Gets a value indicating that the specified `x` and `y` co-ordinates are within the bounds of this rectangle
- [Equals](https://eto.picoe.ca/api/type/eto.drawing.rectangle/equals.md): (2 overloads) Compares this rectangle to an object for equality
- [FromCenter](https://eto.picoe.ca/api/type/eto.drawing.rectangle/fromcenter.md): (static) Creates a new instance of a Rectangle with a specified `center` and `size`
- [FromSides](https://eto.picoe.ca/api/type/eto.drawing.rectangle/fromsides.md): (static) Creates a new instance of a RectangleF from the values of the `left`, `top`, `right` and `bottom` sides
- [GetHashCode](https://eto.picoe.ca/api/type/eto.drawing.rectangle/gethashcode.md): Gets the hash code for this rectangle
- [Inflate](https://eto.picoe.ca/api/type/eto.drawing.rectangle/inflate.md): (4 overloads) Inflates all dimensions of this `rectangle` by the specified `width` and `height`
- [Inset](https://eto.picoe.ca/api/type/eto.drawing.rectangle/inset.md): (2 overloads) Returns a new rectangle that is inset by the specified `padding`
- [Intersect](https://eto.picoe.ca/api/type/eto.drawing.rectangle/intersect.md): (2 overloads) Intersect the two specified rectangles
- [Intersects](https://eto.picoe.ca/api/type/eto.drawing.rectangle/intersects.md): Gets a value indicating that the specified `rectangle` overlaps this rectangle
- [Normalize](https://eto.picoe.ca/api/type/eto.drawing.rectangle/normalize.md): Normalizes the rectangle so both the [Rectangle.Width](https://eto.picoe.ca/api/type/eto.drawing.rectangle/width.md) and [Rectangle.Height](https://eto.picoe.ca/api/type/eto.drawing.rectangle/height.md) are positive, without changing the location of the rectangle
- [Offset](https://eto.picoe.ca/api/type/eto.drawing.rectangle/offset.md): (6 overloads) Offsets the location of the `rectangle` by the specified `x` and `y` values
- [Restrict](https://eto.picoe.ca/api/type/eto.drawing.rectangle/restrict.md): (5 overloads) Restricts the `rectangle` to be within the `restrict` rectangle
- [Round](https://eto.picoe.ca/api/type/eto.drawing.rectangle/round.md): (static) Converts a floating point `rectangle` to an integral [Rectangle](https://eto.picoe.ca/api/type/eto.drawing.rectangle.md) by rounding the X, Y, Width, and Height.
- [ToString](https://eto.picoe.ca/api/type/eto.drawing.rectangle/tostring.md): Converts this rectangle to a string
- [Truncate](https://eto.picoe.ca/api/type/eto.drawing.rectangle/truncate.md): (static) Converts a floating point `rectangle` to an integral [Rectangle](https://eto.picoe.ca/api/type/eto.drawing.rectangle.md) by truncating the X, Y, Width, and Height values
- [Union](https://eto.picoe.ca/api/type/eto.drawing.rectangle/union.md): (2 overloads) Combines two rectangles into one rectangle that encompasses both

## Operators

- [operator +](https://eto.picoe.ca/api/type/eto.drawing.rectangle/op-addition.md): (3 overloads, static) Returns a rectangle inset by the specified padding
- [operator /](https://eto.picoe.ca/api/type/eto.drawing.rectangle/op-division.md): (2 overloads, static) Divides all X, Y, Width, Height components of the `rectangle` by a `factor` factor
- [operator ==](https://eto.picoe.ca/api/type/eto.drawing.rectangle/op-equality.md): (static) Compares two rectangles for equality
- [operator !=](https://eto.picoe.ca/api/type/eto.drawing.rectangle/op-inequality.md): (static) Compares two rectangles for inequality
- [operator *](https://eto.picoe.ca/api/type/eto.drawing.rectangle/op-multiply.md): (2 overloads, static) Multiplies all X, Y, Width, Height components of the `rectangle` by a `factor`
- [operator -](https://eto.picoe.ca/api/type/eto.drawing.rectangle/op-subtraction.md): (3 overloads, static) Returns a rectangle expanded by the specified padding

## Convertors

- [operator explicit](https://eto.picoe.ca/api/type/eto.drawing.rectangle/op-explicit.md): (static) Implicit conversion from a [RectangleF](https://eto.picoe.ca/api/type/eto.drawing.rectanglef.md) to a [Rectangle](https://eto.picoe.ca/api/type/eto.drawing.rectangle.md)
