Struct Rectangle
- Namespace
- HelixToolkit.Maths
- Assembly
- HelixToolkit.Maths.dll
Define a Rectangle. This structure is slightly different from System.Drawing.Rectangle as it is internally storing Left,Top,Right,Bottom instead of Left,Top,Width,Height.
public struct Rectangle : IEquatable<Rectangle>
- Implements
- Inherited Members
- Extension Methods
Constructors
Rectangle(int, int, int, int)
Initializes a new instance of the Rectangle struct.
public Rectangle(int x, int y, int width, int height)
Parameters
Fields
Bottom
The bottom.
public int Bottom
Field Value
Empty
An empty rectangle.
public static readonly Rectangle Empty
Field Value
Left
The left.
public int Left
Field Value
Right
The right.
public int Right
Field Value
Top
The top.
public int Top
Field Value
Properties
Height
Gets or sets the height.
public int Height { readonly get; set; }
Property Value
- int
The height.
IsEmpty
Gets a value that indicates whether the rectangle is empty.
public readonly bool IsEmpty { get; }
Property Value
- bool
trueif [is empty]; otherwise,false.
Width
Gets or sets the width.
public int Width { readonly get; set; }
Property Value
- int
The width.
X
Gets or sets the X position.
public int X { readonly get; set; }
Property Value
- int
The X position.
Y
Gets or sets the Y position.
public int Y { readonly get; set; }
Property Value
- int
The Y position.
Methods
Contains(Rectangle)
Determines whether this rectangle entirely contains a specified rectangle.
public readonly bool Contains(Rectangle value)
Parameters
valueRectangleThe rectangle to evaluate.
Returns
Contains(ref Rectangle, out bool)
Determines whether this rectangle entirely contains a specified rectangle.
public readonly void Contains(ref Rectangle value, out bool result)
Parameters
valueRectangleThe rectangle to evaluate.
resultbool[OutAttribute] On exit, is true if this rectangle entirely contains the specified rectangle, or false if not.
Contains(int, int)
Determines whether this rectangle contains a specified point represented by its x- and y-coordinates.
public readonly bool Contains(int x, int y)
Parameters
Returns
Contains(float, float)
Checks, if specified point is inside Rectangle.
public readonly bool Contains(float x, float y)
Parameters
Returns
Equals(Rectangle)
Determines whether the specified Rectangle is equal to this instance.
public readonly bool Equals(Rectangle other)
Parameters
Returns
Equals(ref Rectangle)
Determines whether the specified Rectangle is equal to this instance.
public readonly bool Equals(ref Rectangle other)
Parameters
Returns
Equals(object?)
Determines whether the specified object is equal to this instance.
public override readonly bool Equals(object? obj)
Parameters
Returns
GetHashCode()
Returns a hash code for this instance.
public override readonly int GetHashCode()
Returns
- int
A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.
Inflate(int, int)
Pushes the edges of the rectangle out by the horizontal and vertical values specified.
public void Inflate(int horizontalAmount, int verticalAmount)
Parameters
horizontalAmountintValue to push the sides out by.
verticalAmountintValue to push the top and bottom out by.
Intersect(Rectangle, Rectangle)
Creates a rectangle defining the area where one rectangle overlaps with another rectangle.
public static Rectangle Intersect(Rectangle value1, Rectangle value2)
Parameters
Returns
- Rectangle
The intersection rectangle.
Intersect(ref Rectangle, ref Rectangle, out Rectangle)
Creates a rectangle defining the area where one rectangle overlaps with another rectangle.
public static void Intersect(ref Rectangle value1, ref Rectangle value2, out Rectangle result)
Parameters
value1RectangleThe first rectangle to compare.
value2RectangleThe second rectangle to compare.
resultRectangle[OutAttribute] The area where the two first parameters overlap.
Intersects(Rectangle)
Determines whether a specified rectangle intersects with this rectangle.
public readonly bool Intersects(Rectangle value)
Parameters
valueRectangleThe rectangle to evaluate.
Returns
Intersects(ref Rectangle, out bool)
Determines whether a specified rectangle intersects with this rectangle.
public readonly void Intersects(ref Rectangle value, out bool result)
Parameters
valueRectangleThe rectangle to evaluate
resultbool[OutAttribute] true if the specified rectangle intersects with this one; false otherwise.
Offset(int, int)
Changes the position of the rectangle.
public void Offset(int offsetX, int offsetY)
Parameters
ToString()
Returns the fully qualified type name of this instance.
public override readonly string ToString()
Returns
- string
The fully qualified type name.
Union(Rectangle, Rectangle)
Creates a new rectangle that exactly contains two other rectangles.
public static Rectangle Union(Rectangle value1, Rectangle value2)
Parameters
Returns
- Rectangle
The union rectangle.
Union(ref Rectangle, ref Rectangle, out Rectangle)
Creates a new rectangle that exactly contains two other rectangles.
public static void Union(ref Rectangle value1, ref Rectangle value2, out Rectangle result)
Parameters
value1RectangleThe first rectangle to contain.
value2RectangleThe second rectangle to contain.
resultRectangle[OutAttribute] The rectangle that must be the union of the first two rectangles.
Operators
operator ==(Rectangle, Rectangle)
Implements the operator ==.
public static bool operator ==(Rectangle left, Rectangle right)
Parameters
Returns
- bool
The result of the operator.
operator !=(Rectangle, Rectangle)
Implements the operator !=.
public static bool operator !=(Rectangle left, Rectangle right)
Parameters
Returns
- bool
The result of the operator.