Struct Rect
Rect - The primitive which represents a rectangle. Rects are stored as X, Y (Location) and Width and Height (Size). As a result, Rects cannot have negative Width or Height.
Inherited Members
Namespace:ImGui
Assembly:ImGui.dll
Syntax
[Serializable]
public struct Rect : IFormattable
Constructors
| Improve this DocRect(Point, Point)
Constructor which sets the initial values to bound the two points provided.
Declaration
public Rect(Point point1, Point point2)
Parameters
| Type | Name | Description |
|---|---|---|
| Point | point1 | |
| Point | point2 |
Rect(Point, Size)
Declaration
public Rect(Point center, Size size)
Parameters
| Type | Name | Description |
|---|---|---|
| Point | center | |
| Size | size |
Rect(Point, Vector)
Constructor which sets the initial values to bound the point provided and the point which results from point + vector.
Declaration
public Rect(Point point, Vector vector)
Parameters
| Type | Name | Description |
|---|---|---|
| Point | point | |
| Vector | vector |
Rect(Size)
Constructor which sets the initial values to bound the (0,0) point and the point that results from (0,0) + size.
Declaration
public Rect(Size size)
Parameters
| Type | Name | Description |
|---|---|---|
| Size | size |
Rect(Double, Double)
Construct a rect by its width and height (top-left is at (0,0))
Declaration
public Rect(double width, double height)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Double | width | rect width |
| System.Double | height | rect height |
Rect(Double, Double, Size)
Construct a rect by its top-left coordinate and its size(width, height)
Declaration
public Rect(double x, double y, Size size)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Double | x | top |
| System.Double | y | left |
| Size | size | size of the rect |
Rect(Double, Double, Double, Double)
Constructor which sets the initial values to the values of the parameters. Width and Height must be non-negative
Declaration
public Rect(double x, double y, double width, double height)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Double | x | |
| System.Double | y | |
| System.Double | width | |
| System.Double | height |
Properties
| Improve this DocBig
Big - a static property which provides a Big rectangle. X and Y are zero and Width and Height are 9999.
Declaration
public static Rect Big { get; }
Property Value
| Type | Description |
|---|---|
| Rect |
Bottom
Bottom Property - This is a read-only alias for Y + Height If this is the empty rectangle, the value will be negative infinity.
Declaration
public double Bottom { get; }
Property Value
| Type | Description |
|---|---|
| System.Double |
BottomLeft
BottomLeft Property - This is a read-only alias for the Point which is at X, Y + Height If this is the empty rectangle, the value will be positive infinity, negative infinity.
Declaration
public Point BottomLeft { get; }
Property Value
| Type | Description |
|---|---|
| Point |
BottomRight
BottomRight Property - This is a read-only alias for the Point which is at X + Width, Y + Height If this is the empty rectangle, the value will be negative infinity, negative infinity.
Declaration
public Point BottomRight { get; }
Property Value
| Type | Description |
|---|---|
| Point |
Center
Declaration
public Point Center { get; }
Property Value
| Type | Description |
|---|---|
| Point |
Empty
Empty - a static property which provides an Empty rectangle. X and Y are positive-infinity and Width and Height are negative infinity. This is the only situation where Width or Height can be negative.
Declaration
public static Rect Empty { get; }
Property Value
| Type | Description |
|---|---|
| Rect |
Height
Height - The Height component of the Size. This cannot be set to negative, and will only be negative if this is the empty rectangle, in which case it will be negative infinity. If this rect is Empty, setting this property is illegal.
Declaration
public double Height { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Double |
IsBig
IsBig - this returns true if this rect is the Big rectangle.
Declaration
public bool IsBig { get; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
IsEmpty
IsEmpty - this returns true if this rect is the Empty rectangle. Note: If width or height are 0 this Rectangle still contains a 0 or 1 dimensional set of points, so this method should not be used to check for 0 area.
Declaration
public bool IsEmpty { get; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
Left
Left Property - This is a read-only alias for X If this is the empty rectangle, the value will be positive infinity.
Declaration
public double Left { get; }
Property Value
| Type | Description |
|---|---|
| System.Double |
Location
Location - The Point representing the origin of the Rectangle
Declaration
public Point Location { get; set; }
Property Value
| Type | Description |
|---|---|
| Point |
Right
Right Property - This is a read-only alias for X + Width If this is the empty rectangle, the value will be negative infinity.
Declaration
public double Right { get; }
Property Value
| Type | Description |
|---|---|
| System.Double |
Size
Size - The Size representing the area of the Rectangle
Declaration
public Size Size { get; set; }
Property Value
| Type | Description |
|---|---|
| Size |
Top
Top Property - This is a read-only alias for Y If this is the empty rectangle, the value will be positive infinity.
Declaration
public double Top { get; }
Property Value
| Type | Description |
|---|---|
| System.Double |
TopLeft
TopLeft Property - This is a read-only alias for the Point which is at X, Y If this is the empty rectangle, the value will be positive infinity, positive infinity.
Declaration
public Point TopLeft { get; }
Property Value
| Type | Description |
|---|---|
| Point |
TopRight
TopRight Property - This is a read-only alias for the Point which is at X + Width, Y If this is the empty rectangle, the value will be negative infinity, positive infinity.
Declaration
public Point TopRight { get; }
Property Value
| Type | Description |
|---|---|
| Point |
Width
Width - The Width component of the Size. This cannot be set to negative, and will only be negative if this is the empty rectangle, in which case it will be negative infinity. If this rect is Empty, setting this property is illegal.
Declaration
public double Width { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Double |
X
X - The X coordinate of the Location. If this is the empty rectangle, the value will be positive infinity. If this rect is Empty, setting this property is illegal.
Declaration
public double X { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Double |
Y
Y - The Y coordinate of the Location If this is the empty rectangle, the value will be positive infinity. If this rect is Empty, setting this property is illegal.
Declaration
public double Y { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Double |
Zero
Declaration
public static Rect Zero { get; }
Property Value
| Type | Description |
|---|---|
| Rect |
Methods
| Improve this DocContains(Point)
Contains - Returns true if the Point is within the rectangle, inclusive of the edges. Returns false otherwise.
Declaration
public bool Contains(Point point)
Parameters
| Type | Name | Description |
|---|---|---|
| Point | point | The point which is being tested |
Returns
| Type | Description |
|---|---|
| System.Boolean | Returns true if the Point is within the rectangle. Returns false otherwise |
Contains(Rect)
Contains - Returns true if the Rect non-Empty and is entirely contained within the rectangle, inclusive of the edges. Returns false otherwise
Declaration
public bool Contains(Rect rect)
Parameters
| Type | Name | Description |
|---|---|---|
| Rect | rect |
Returns
| Type | Description |
|---|---|
| System.Boolean |
Contains(Double, Double)
Contains - Returns true if the Point represented by x,y is within the rectangle inclusive of the edges. Returns false otherwise.
Declaration
public bool Contains(double x, double y)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Double | x | X coordinate of the point which is being tested |
| System.Double | y | Y coordinate of the point which is being tested |
Returns
| Type | Description |
|---|---|
| System.Boolean | Returns true if the Point represented by x,y is within the rectangle. Returns false otherwise. |
Equals(Rect)
Equals - compares this Rect with the passed in object. In this equality double.NaN is equal to itself, unlike in numeric equality. Note that double values can acquire error when operated upon, such that an exact comparison between two values which are logically equal may fail.
Declaration
public bool Equals(Rect value)
Parameters
| Type | Name | Description |
|---|---|---|
| Rect | value | The Rect to compare to "this" |
Returns
| Type | Description |
|---|---|
| System.Boolean | bool - true if "value" is equal to "this". |
Equals(Rect, Rect)
Compares two Rect instances for object equality. In this equality double.NaN is equal to itself, unlike in numeric equality. Note that double values can acquire error when operated upon, such that an exact comparison between two values which are logically equal may fail.
Declaration
public static bool Equals(Rect rect1, Rect rect2)
Parameters
| Type | Name | Description |
|---|---|---|
| Rect | rect1 | The first Rect to compare |
| Rect | rect2 | The second Rect to compare |
Returns
| Type | Description |
|---|---|
| System.Boolean | bool - true if the two Rect instances are exactly equal, false otherwise |
Equals(Object)
Equals - compares this Rect with the passed in object. In this equality double.NaN is equal to itself, unlike in numeric equality. Note that double values can acquire error when operated upon, such that an exact comparison between two values which are logically equal may fail.
Declaration
public override bool Equals(object o)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Object | o | The object to compare to "this" |
Returns
| Type | Description |
|---|---|
| System.Boolean | bool - true if the object is an instance of Rect and if it's equal to "this". |
Overrides
GetHashCode()
Returns the HashCode for this Rect
Declaration
public override int GetHashCode()
Returns
| Type | Description |
|---|---|
| System.Int32 | int - the HashCode for this Rect |
Overrides
Inflate(Rect, Size)
Inflate - return the result of inflating rect by the size provided, in all directions If this is Empty, this method is illegal.
Declaration
public static Rect Inflate(Rect rect, Size size)
Parameters
| Type | Name | Description |
|---|---|---|
| Rect | rect | |
| Size | size |
Returns
| Type | Description |
|---|---|
| Rect |
Inflate(Rect, Double, Double)
Inflate - return the result of inflating rect by the size provided, in all directions If this is Empty, this method is illegal.
Declaration
public static Rect Inflate(Rect rect, double width, double height)
Parameters
| Type | Name | Description |
|---|---|---|
| Rect | rect | |
| System.Double | width | |
| System.Double | height |
Returns
| Type | Description |
|---|---|
| Rect |
Inflate(Rect, Double, Double, Double, Double)
Inflate - return the result of inflating rect by the size provided, in all four directions If any paramer is negative, this method is illegal. If this is Empty, this method is illegal.
Declaration
public static Rect Inflate(Rect rect, double top, double right, double bottom, double left)
Parameters
| Type | Name | Description |
|---|---|---|
| Rect | rect | |
| System.Double | top | |
| System.Double | right | |
| System.Double | bottom | |
| System.Double | left |
Returns
| Type | Description |
|---|---|
| Rect |
Inflate(Size)
Inflate - inflate the bounds by the size provided, in all directions If this is Empty, this method is illegal.
Declaration
public void Inflate(Size size)
Parameters
| Type | Name | Description |
|---|---|---|
| Size | size |
Inflate(Double, Double)
Inflate - inflate the bounds by the size provided, in all directions. If -width is > Width / 2 or -height is > Height / 2, this Rect becomes Empty If this is Empty, this method is illegal.
Declaration
public void Inflate(double width, double height)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Double | width | |
| System.Double | height |
Inflate(Double, Double, Double, Double)
Inflate - inflate the bounds by the value provided, in all four directions. If any paramer is negative, this method is illegal. If this is Empty, this method is illegal.
Declaration
public void Inflate(double top, double right, double bottom, double left)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Double | top | |
| System.Double | right | |
| System.Double | bottom | |
| System.Double | left |
Intersect(Rect)
Intersect - Update this rectangle to be the intersection of this and rect If either this or rect are Empty, the result is Empty as well.
Declaration
public void Intersect(Rect rect)
Parameters
| Type | Name | Description |
|---|---|---|
| Rect | rect | The rect to intersect with this |
Intersect(Rect, Rect)
Intersect - Return the result of the intersection of rect1 and rect2. If either this or rect are Empty, the result is Empty as well.
Declaration
public static Rect Intersect(Rect rect1, Rect rect2)
Parameters
| Type | Name | Description |
|---|---|---|
| Rect | rect1 | |
| Rect | rect2 |
Returns
| Type | Description |
|---|---|
| Rect |
IntersectsWith(Rect)
IntersectsWith - Returns true if the Rect intersects with this rectangle Returns false otherwise. Note that if one edge is coincident, this is considered an intersection.
Declaration
public bool IntersectsWith(Rect rect)
Parameters
| Type | Name | Description |
|---|---|---|
| Rect | rect | Rect |
Returns
| Type | Description |
|---|---|
| System.Boolean | Returns true if the Rect intersects with this rectangle Returns false otherwise. or Height |
Offset(Rect, Vector)
Offset - return the result of offsetting rect by the offset provided If this is Empty, this method is illegal.
Declaration
public static Rect Offset(Rect rect, Vector offsetVector)
Parameters
| Type | Name | Description |
|---|---|---|
| Rect | rect | |
| Vector | offsetVector |
Returns
| Type | Description |
|---|---|
| Rect |
Offset(Rect, Double, Double)
Offset - return the result of offsetting rect by the offset provided If this is Empty, this method is illegal.
Declaration
public static Rect Offset(Rect rect, double offsetX, double offsetY)
Parameters
| Type | Name | Description |
|---|---|---|
| Rect | rect | |
| System.Double | offsetX | |
| System.Double | offsetY |
Returns
| Type | Description |
|---|---|
| Rect |
Offset(Vector)
Offset - translate the Location by the offset provided. If this is Empty, this method is illegal.
Declaration
public void Offset(Vector offsetVector)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector | offsetVector |
Offset(Double, Double)
Offset - translate the Location by the offset provided If this is Empty, this method is illegal.
Declaration
public void Offset(double offsetX, double offsetY)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Double | offsetX | |
| System.Double | offsetY |
Parse(String)
Parse - returns an instance converted from the provided string using the culture "en-US"
string with Rect dataDeclaration
public static Rect Parse(string source)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | source |
Returns
| Type | Description |
|---|---|
| Rect |
Scale(Double, Double)
Scale the rectangle in the X and Y directions
Declaration
public void Scale(double scaleX, double scaleY)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Double | scaleX | The scale in X |
| System.Double | scaleY | The scale in Y |
ToString()
Creates a string representation of this object based on the current culture.
Declaration
public override string ToString()
Returns
| Type | Description |
|---|---|
| System.String | A string representation of this object. |
Overrides
ToString(IFormatProvider)
Creates a string representation of this object based on the IFormatProvider passed in. If the provider is null, the CurrentCulture is used.
Declaration
public string ToString(IFormatProvider provider)
Parameters
| Type | Name | Description |
|---|---|---|
| System.IFormatProvider | provider |
Returns
| Type | Description |
|---|---|
| System.String | A string representation of this object. |
Union(Point)
Union - Update this rectangle to be the union of this and point.
Declaration
public void Union(Point point)
Parameters
| Type | Name | Description |
|---|---|---|
| Point | point |
Union(Rect)
Union - Update this rectangle to be the union of this and rect.
Declaration
public void Union(Rect rect)
Parameters
| Type | Name | Description |
|---|---|---|
| Rect | rect |
Union(Rect, Point)
Union - Return the result of the union of rect and point.
Declaration
public static Rect Union(Rect rect, Point point)
Parameters
| Type | Name | Description |
|---|---|---|
| Rect | rect | |
| Point | point |
Returns
| Type | Description |
|---|---|
| Rect |
Union(Rect, Rect)
Union - Return the result of the union of rect1 and rect2.
Declaration
public static Rect Union(Rect rect1, Rect rect2)
Parameters
| Type | Name | Description |
|---|---|---|
| Rect | rect1 | |
| Rect | rect2 |
Returns
| Type | Description |
|---|---|
| Rect |
Operators
| Improve this DocEquality(Rect, Rect)
Compares two Rect instances for exact equality. Note that double values can acquire error when operated upon, such that an exact comparison between two values which are logically equal may fail. Furthermore, using this equality operator, double.NaN is not equal to itself.
Declaration
public static bool operator ==(Rect rect1, Rect rect2)
Parameters
| Type | Name | Description |
|---|---|---|
| Rect | rect1 | The first Rect to compare |
| Rect | rect2 | The second Rect to compare |
Returns
| Type | Description |
|---|---|
| System.Boolean | bool - true if the two Rect instances are exactly equal, false otherwise |
Inequality(Rect, Rect)
Compares two Rect instances for exact inequality. Note that double values can acquire error when operated upon, such that an exact comparison between two values which are logically equal may fail. Furthermore, using this equality operator, double.NaN is not equal to itself.
Declaration
public static bool operator !=(Rect rect1, Rect rect2)
Parameters
| Type | Name | Description |
|---|---|---|
| Rect | rect1 | The first Rect to compare |
| Rect | rect2 | The second Rect to compare |
Returns
| Type | Description |
|---|---|
| System.Boolean | bool - true if the two Rect instances are exactly unequal, false otherwise |
Explicit Interface Implementations
| Improve this DocIFormattable.ToString(String, IFormatProvider)
Creates a string representation of this object based on the format string and IFormatProvider passed in. If the provider is null, the CurrentCulture is used. See the documentation for IFormattable for more information.
Declaration
string IFormattable.ToString(string format, IFormatProvider provider)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | format | |
| System.IFormatProvider | provider |
Returns
| Type | Description |
|---|---|
| System.String | A string representation of this object. |