Table of Contents

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

X float
Y float
Width float
Height float

Properties

Bottom

Bottom edge.

public float Bottom { get; }

Property Value

float

Center

Center point.

public Point Center { get; }

Property Value

Point

Empty

Empty rectangle at the origin.

public static Rect Empty { get; }

Property Value

Rect

Height

public float Height { get; init; }

Property Value

float

IsEmpty

true if the rectangle has no area.

public bool IsEmpty { get; }

Property Value

bool

Left

Left edge.

public float Left { get; }

Property Value

float

Location

Top-left corner.

public Point Location { get; }

Property Value

Point

Right

Right edge.

public float Right { get; }

Property Value

float

Size

Size of the rectangle.

public Size Size { get; }

Property Value

Size

Top

Top edge.

public float Top { get; }

Property Value

float

Width

public float Width { get; init; }

Property Value

float

X

public float X { get; init; }

Property Value

float

Y

public float Y { get; init; }

Property Value

float

Methods

CenteredSquare()

Largest square centered in the rectangle.

public Rect CenteredSquare()

Returns

Rect

Contains(Point)

Returns true if the point lies inside the rectangle (right/bottom edges excluded).

public bool Contains(Point p)

Parameters

p Point

Returns

bool

Deflate(Thickness)

Removes a thickness from the rectangle (padding, border...).

public Rect Deflate(Thickness t)

Parameters

t Thickness

Returns

Rect

FromCenter(Point, float, float)

Creates a rectangle centered on a point.

public static Rect FromCenter(Point center, float width, float height)

Parameters

center Point
width float
height float

Returns

Rect

FromEdges(float, float, float, float)

Creates a rectangle from its edges.

public static Rect FromEdges(float left, float top, float right, float bottom)

Parameters

left float
top float
right float
bottom float

Returns

Rect

Inflate(Thickness)

Adds a thickness around the rectangle.

public Rect Inflate(Thickness t)

Parameters

t Thickness

Returns

Rect

Inflate(float)

Grows the rectangle uniformly.

public Rect Inflate(float d)

Parameters

d float

Returns

Rect

Inflate(float, float)

Grows (positive) or shrinks (negative) the rectangle on every side.

public Rect Inflate(float dx, float dy)

Parameters

dx float
dy float

Returns

Rect

Intersect(Rect)

Intersection of two rectangles (empty if they do not overlap).

public Rect Intersect(Rect other)

Parameters

other Rect

Returns

Rect

Intersects(Rect)

Returns true if the rectangles overlap.

public bool Intersects(Rect other)

Parameters

other Rect

Returns

bool

Offset(float, float)

Moves the rectangle.

public Rect Offset(float dx, float dy)

Parameters

dx float
dy float

Returns

Rect

Snap(float)

Rounds the edges to whole pixels for a given scale (crisp 1-pixel lines).

public Rect Snap(float scale)

Parameters

scale float

Returns

Rect

TakeBottom(float)

Splits off a horizontal band from the bottom.

public Rect TakeBottom(float height)

Parameters

height float

Returns

Rect

TakeLeft(float)

Splits off a vertical band from the left.

public Rect TakeLeft(float width)

Parameters

width float

Returns

Rect

TakeRight(float)

Splits off a vertical band from the right.

public Rect TakeRight(float width)

Parameters

width float

Returns

Rect

TakeTop(float)

Splits off a horizontal band from the top.

public Rect TakeTop(float height)

Parameters

height float

Returns

Rect

Union(Rect)

Smallest rectangle containing both rectangles.

public Rect Union(Rect other)

Parameters

other Rect

Returns

Rect