Struct Rect
- Namespace
- PluginUI
- Assembly
- PluginUI.dll
Axis-aligned rectangle in DIPs.
public readonly record struct Rect : IEquatable<Rect>
- Implements
- Inherited Members
Constructors
Rect(float, float, float, float)
Axis-aligned rectangle in DIPs.
public Rect(float X, float Y, float Width, float Height)
Parameters
Properties
Bottom
Bottom edge.
public float Bottom { get; }
Property Value
Center
Center point.
public Point Center { get; }
Property Value
Empty
Empty rectangle at the origin.
public static Rect Empty { get; }
Property Value
Height
public float Height { get; init; }
Property Value
IsEmpty
true if the rectangle has no area.
public bool IsEmpty { get; }
Property Value
Left
Left edge.
public float Left { get; }
Property Value
Location
Top-left corner.
public Point Location { get; }
Property Value
Right
Right edge.
public float Right { get; }
Property Value
Size
Size of the rectangle.
public Size Size { get; }
Property Value
Top
Top edge.
public float Top { get; }
Property Value
Width
public float Width { get; init; }
Property Value
X
public float X { get; init; }
Property Value
Y
public float Y { get; init; }
Property Value
Methods
CenteredSquare()
Largest square centered in the rectangle.
public Rect CenteredSquare()
Returns
Contains(Point)
Returns true if the point lies inside the rectangle (right/bottom edges excluded).
public bool Contains(Point p)
Parameters
pPoint
Returns
Deflate(Thickness)
Removes a thickness from the rectangle (padding, border...).
public Rect Deflate(Thickness t)
Parameters
Returns
FromCenter(Point, float, float)
Creates a rectangle centered on a point.
public static Rect FromCenter(Point center, float width, float height)
Parameters
Returns
FromEdges(float, float, float, float)
Creates a rectangle from its edges.
public static Rect FromEdges(float left, float top, float right, float bottom)
Parameters
Returns
Inflate(Thickness)
Adds a thickness around the rectangle.
public Rect Inflate(Thickness t)
Parameters
Returns
Inflate(float)
Grows the rectangle uniformly.
public Rect Inflate(float d)
Parameters
dfloat
Returns
Inflate(float, float)
Grows (positive) or shrinks (negative) the rectangle on every side.
public Rect Inflate(float dx, float dy)
Parameters
Returns
Intersect(Rect)
Intersection of two rectangles (empty if they do not overlap).
public Rect Intersect(Rect other)
Parameters
otherRect
Returns
Intersects(Rect)
Returns true if the rectangles overlap.
public bool Intersects(Rect other)
Parameters
otherRect
Returns
Offset(float, float)
Moves the rectangle.
public Rect Offset(float dx, float dy)
Parameters
Returns
Snap(float)
Rounds the edges to whole pixels for a given scale (crisp 1-pixel lines).
public Rect Snap(float scale)
Parameters
scalefloat
Returns
TakeBottom(float)
Splits off a horizontal band from the bottom.
public Rect TakeBottom(float height)
Parameters
heightfloat
Returns
TakeLeft(float)
Splits off a vertical band from the left.
public Rect TakeLeft(float width)
Parameters
widthfloat
Returns
TakeRight(float)
Splits off a vertical band from the right.
public Rect TakeRight(float width)
Parameters
widthfloat
Returns
TakeTop(float)
Splits off a horizontal band from the top.
public Rect TakeTop(float height)
Parameters
heightfloat
Returns
Union(Rect)
Smallest rectangle containing both rectangles.
public Rect Union(Rect other)
Parameters
otherRect