Struct Rect
Represents a rectangle with position and size. Used for element bounds calculations.
public readonly record struct Rect : IEquatable<Rect>
- Implements
- Inherited Members
Constructors
Rect(double, double, double, double)
Represents a rectangle with position and size. Used for element bounds calculations.
public Rect(double X, double Y, double Width, double Height)
Parameters
XdoubleThe X coordinate of the top-left corner.
YdoubleThe Y coordinate of the top-left corner.
WidthdoubleThe width of the rectangle.
HeightdoubleThe height of the rectangle.
Properties
Bottom
Gets the bottom edge Y coordinate.
public double Bottom { get; }
Property Value
Center
Gets the center point of the rectangle.
public Point Center { get; }
Property Value
Empty
Creates an empty rectangle at the origin.
public static Rect Empty { get; }
Property Value
Height
The height of the rectangle.
public double Height { get; init; }
Property Value
Left
Gets the left edge X coordinate.
public double Left { get; }
Property Value
Right
Gets the right edge X coordinate.
public double Right { get; }
Property Value
Top
Gets the top edge Y coordinate.
public double Top { get; }
Property Value
Width
The width of the rectangle.
public double Width { get; init; }
Property Value
X
The X coordinate of the top-left corner.
public double X { get; init; }
Property Value
Y
The Y coordinate of the top-left corner.
public double Y { get; init; }
Property Value
Methods
Contains(Rect)
Determines whether this rectangle fully contains another rectangle.
public bool Contains(Rect other)
Parameters
otherRect
Returns
Contains(Point)
Determines whether this rectangle contains the specified point.
public bool Contains(Point point)
Parameters
pointPoint
Returns
Inflate(double)
Returns a new rectangle expanded by the specified amount on all sides.
public Rect Inflate(double amount)
Parameters
amountdouble
Returns
Intersects(Rect)
Determines whether this rectangle intersects with another rectangle.
public bool Intersects(Rect other)
Parameters
otherRect
Returns
Union(Rect)
Returns the union of this rectangle with another.
public Rect Union(Rect other)
Parameters
otherRect