Struct Rect
Stores a set of four integers that represent the location and size of a rectangle
Inherited Members
System.Object.Equals(System.Object, System.Object)
System.Object.GetType()
System.Object.ReferenceEquals(System.Object, System.Object)
Namespace: Terminal.Gui
Assembly: Terminal.Gui.dll
Syntax
public struct Rect
Constructors
Rect(Int32, Int32, Int32, Int32)
Rectangle Constructor
Declaration
public Rect(int x, int y, int width, int height)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | x | |
| System.Int32 | y | |
| System.Int32 | width | |
| System.Int32 | height |
Remarks
Creates a Rectangle from a specified x,y location and
width and height values.
Rect(Point, Size)
Rectangle Constructor
Declaration
public Rect(Point location, Size size)
Parameters
| Type | Name | Description |
|---|---|---|
| Point | location | |
| Size | size |
Remarks
Creates a Rectangle from Point and Size values.
Fields
Empty
Empty Shared Field
Declaration
public static readonly Rect Empty
Field Value
| Type | Description |
|---|---|
| Rect |
Remarks
An uninitialized Rectangle Structure.
X
Gets or sets the x-coordinate of the upper-left corner of this Rectangle structure.
Declaration
public int X
Field Value
| Type | Description |
|---|---|
| System.Int32 |
Y
Gets or sets the y-coordinate of the upper-left corner of this Rectangle structure.
Declaration
public int Y
Field Value
| Type | Description |
|---|---|
| System.Int32 |
Properties
Bottom
Bottom Property
Declaration
public readonly int Bottom { get; }
Property Value
| Type | Description |
|---|---|
| System.Int32 |
Remarks
The Y coordinate of the bottom edge of the Rectangle.
Read only.
Height
Gets or sets the height of this Rectangle structure.
Declaration
public int Height { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Int32 |
IsEmpty
IsEmpty Property
Declaration
public readonly bool IsEmpty { get; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
Remarks
Indicates if the width or height are zero. Read only.
Left
Left Property
Declaration
public readonly int Left { get; }
Property Value
| Type | Description |
|---|---|
| System.Int32 |
Remarks
The X coordinate of the left edge of the Rectangle.
Read only.
Location
Location Property
Declaration
public Point Location { get; set; }
Property Value
| Type | Description |
|---|---|
| Point |
Remarks
The Location of the top-left corner of the Rectangle.
Right
Right Property
Declaration
public readonly int Right { get; }
Property Value
| Type | Description |
|---|---|
| System.Int32 |
Remarks
The X coordinate of the right edge of the Rectangle.
Read only.
Size
Size Property
Declaration
public Size Size { get; set; }
Property Value
| Type | Description |
|---|---|
| Size |
Remarks
The Size of the Rectangle.
Top
Top Property
Declaration
public readonly int Top { get; }
Property Value
| Type | Description |
|---|---|
| System.Int32 |
Remarks
The Y coordinate of the top edge of the Rectangle.
Read only.
Width
Gets or sets the width of this Rect structure.
Declaration
public int Width { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Int32 |
Methods
Contains(Int32, Int32)
Contains Method
Declaration
public bool Contains(int x, int y)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | x | |
| System.Int32 | y |
Returns
| Type | Description |
|---|---|
| System.Boolean |
Remarks
Checks if an x,y coordinate lies within this Rectangle.
Contains(Point)
Contains Method
Declaration
public bool Contains(Point pt)
Parameters
| Type | Name | Description |
|---|---|---|
| Point | pt |
Returns
| Type | Description |
|---|---|
| System.Boolean |
Remarks
Checks if a Point lies within this Rectangle.
Contains(Rect)
Contains Method
Declaration
public bool Contains(Rect rect)
Parameters
| Type | Name | Description |
|---|---|---|
| Rect | rect |
Returns
| Type | Description |
|---|---|
| System.Boolean |
Remarks
Checks if a Rectangle lies entirely within this
Rectangle.
Equals(Object)
Equals Method
Declaration
public override bool Equals(object obj)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Object | obj |
Returns
| Type | Description |
|---|---|
| System.Boolean |
Overrides
System.ValueType.Equals(System.Object)
Remarks
Checks equivalence of this Rectangle and another object.
FromLTRB(Int32, Int32, Int32, Int32)
FromLTRB Shared Method
Declaration
public static Rect FromLTRB(int left, int top, int right, int bottom)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | left | |
| System.Int32 | top | |
| System.Int32 | right | |
| System.Int32 | bottom |
Returns
| Type | Description |
|---|---|
| Rect |
Remarks
Produces a Rectangle structure from left, top, right
and bottom coordinates.
GetHashCode()
GetHashCode Method
Declaration
public override int GetHashCode()
Returns
| Type | Description |
|---|---|
| System.Int32 |
Overrides
System.ValueType.GetHashCode()
Remarks
Calculates a hashing value.
Inflate(Int32, Int32)
Inflate Method
Declaration
public void Inflate(int width, int height)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | width | |
| System.Int32 | height |
Remarks
Inflates the Rectangle by a specified width and height.
Inflate(Rect, Int32, Int32)
Inflate Shared Method
Declaration
public static Rect Inflate(Rect rect, int x, int y)
Parameters
| Type | Name | Description |
|---|---|---|
| Rect | rect | |
| System.Int32 | x | |
| System.Int32 | y |
Returns
| Type | Description |
|---|---|
| Rect |
Remarks
Produces a new Rectangle by inflating an existing
Rectangle by the specified coordinate values.
Inflate(Size)
Inflate Method
Declaration
public void Inflate(Size size)
Parameters
| Type | Name | Description |
|---|---|---|
| Size | size |
Remarks
Inflates the Rectangle by a specified Size.
Intersect(Rect)
Intersect Method
Declaration
public void Intersect(Rect rect)
Parameters
| Type | Name | Description |
|---|---|---|
| Rect | rect |
Remarks
Replaces the Rectangle with the intersection of itself
and another Rectangle.
Intersect(Rect, Rect)
Intersect Shared Method
Declaration
public static Rect Intersect(Rect a, Rect b)
Parameters
| Type | Name | Description |
|---|---|---|
| Rect | a | |
| Rect | b |
Returns
| Type | Description |
|---|---|
| Rect |
Remarks
Produces a new Rectangle by intersecting 2 existing
Rectangles. Returns null if there is no intersection.
IntersectsWith(Rect)
IntersectsWith Method
Declaration
public bool IntersectsWith(Rect rect)
Parameters
| Type | Name | Description |
|---|---|---|
| Rect | rect |
Returns
| Type | Description |
|---|---|
| System.Boolean |
Remarks
Checks if a Rectangle intersects with this one.
Offset(Int32, Int32)
Offset Method
Declaration
public void Offset(int x, int y)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Int32 | x | |
| System.Int32 | y |
Remarks
Moves the Rectangle a specified distance.
Offset(Point)
Offset Method
Declaration
public void Offset(Point pos)
Parameters
| Type | Name | Description |
|---|---|---|
| Point | pos |
Remarks
Moves the Rectangle a specified distance.
ToString()
ToString Method
Declaration
public override string ToString()
Returns
| Type | Description |
|---|---|
| System.String |
Overrides
System.ValueType.ToString()
Remarks
Formats the Rectangle as a string in (x,y,w,h) notation.
Union(Rect, Rect)
Union Shared Method
Declaration
public static Rect Union(Rect a, Rect b)
Parameters
| Type | Name | Description |
|---|---|---|
| Rect | a | |
| Rect | b |
Returns
| Type | Description |
|---|---|
| Rect |
Remarks
Produces a new Rectangle from the union of 2 existing
Rectangles.
Operators
Equality(Rect, Rect)
Equality Operator
Declaration
public static bool operator ==(Rect left, Rect right)
Parameters
| Type | Name | Description |
|---|---|---|
| Rect | left | |
| Rect | right |
Returns
| Type | Description |
|---|---|
| System.Boolean |
Remarks
Compares two Rectangle objects. The return value is
based on the equivalence of the Location and Size
properties of the two Rectangles.
Inequality(Rect, Rect)
Inequality Operator
Declaration
public static bool operator !=(Rect left, Rect right)
Parameters
| Type | Name | Description |
|---|---|---|
| Rect | left | |
| Rect | right |
Returns
| Type | Description |
|---|---|
| System.Boolean |
Remarks
Compares two Rectangle objects. The return value is
based on the equivalence of the Location and Size
properties of the two Rectangles.