Struct LayoutRect
- Namespace
- SharpConsoleUI.Layout
- Assembly
- SharpConsoleUI.dll
Represents a rectangle with position and size. Immutable value type for layout calculations and hit testing. Named LayoutRect to avoid conflicts with System.Drawing.Rectangle during transition.
public readonly record struct LayoutRect : IEquatable<LayoutRect>
- Implements
- Inherited Members
Constructors
LayoutRect(int, int, int, int)
Represents a rectangle with position and size. Immutable value type for layout calculations and hit testing. Named LayoutRect to avoid conflicts with System.Drawing.Rectangle during transition.
public LayoutRect(int X, int Y, int Width, int Height)
Parameters
Properties
Bottom
Gets the bottom edge Y coordinate (exclusive).
public int Bottom { get; }
Property Value
Center
Gets the center point of this rectangle.
public (int X, int Y) Center { get; }
Property Value
Empty
Gets an empty rectangle at the origin.
public static LayoutRect Empty { get; }
Property Value
Height
public int Height { get; init; }
Property Value
IsEmpty
Gets whether this rectangle has zero or negative area.
public bool IsEmpty { get; }
Property Value
Location
Gets the top-left position of this rectangle as X, Y coordinates.
public (int X, int Y) Location { get; }
Property Value
Right
Gets the right edge X coordinate (exclusive).
public int Right { get; }
Property Value
Size
Gets the size of this rectangle.
public LayoutSize Size { get; }
Property Value
Width
public int Width { get; init; }
Property Value
X
public int X { get; init; }
Property Value
Y
public int Y { get; init; }
Property Value
Methods
Contains(LayoutRect)
Determines whether this rectangle fully contains another rectangle.
public bool Contains(LayoutRect other)
Parameters
otherLayoutRect
Returns
Contains(Point)
Determines whether this rectangle contains the specified point.
public bool Contains(Point point)
Parameters
pointPoint
Returns
Contains(int, int)
Determines whether this rectangle contains the specified point.
public bool Contains(int x, int y)
Parameters
Returns
Deflate(int, int)
Returns a new rectangle deflated by the specified amounts on all sides.
public LayoutRect Deflate(int horizontal, int vertical)
Parameters
Returns
FromPositionAndSize(int, int, LayoutSize)
Creates a rectangle from position and size.
public static LayoutRect FromPositionAndSize(int x, int y, LayoutSize size)
Parameters
xintyintsizeLayoutSize
Returns
FromRectangle(Rectangle)
Creates from System.Drawing.Rectangle.
public static LayoutRect FromRectangle(Rectangle rect)
Parameters
rectRectangle
Returns
Inflate(int, int)
Returns a new rectangle inflated by the specified amounts on all sides.
public LayoutRect Inflate(int horizontal, int vertical)
Parameters
Returns
Intersect(LayoutRect)
Returns the intersection of this rectangle with another, or Empty if they don't intersect.
public LayoutRect Intersect(LayoutRect other)
Parameters
otherLayoutRect
Returns
IntersectsWith(LayoutRect)
Determines whether this rectangle intersects with another rectangle.
public bool IntersectsWith(LayoutRect other)
Parameters
otherLayoutRect
Returns
Offset(int, int)
Returns a new rectangle offset by the specified amounts.
public LayoutRect Offset(int dx, int dy)
Parameters
Returns
ToRectangle()
Converts to System.Drawing.Rectangle.
public Rectangle ToRectangle()
Returns
ToString()
Returns a string representation of this rectangle.
public override string ToString()
Returns
Union(LayoutRect)
Returns the smallest rectangle that contains both this and another rectangle.
public LayoutRect Union(LayoutRect other)
Parameters
otherLayoutRect
Returns
WithPosition(int, int)
Returns a new rectangle with the position set to the specified coordinates.
public LayoutRect WithPosition(int x, int y)
Parameters
Returns
WithSize(LayoutSize)
Returns a new rectangle with the size set to the specified size.
public LayoutRect WithSize(LayoutSize size)
Parameters
sizeLayoutSize
Returns
WithSize(int, int)
Returns a new rectangle with the size set to the specified dimensions.
public LayoutRect WithSize(int width, int height)