Show / Hide Table of Contents

Struct RECT

Rectangle coordinates left top right bottom.

public record struct RECT : IEquatable<RECT>
Remarks

This type can be used with Windows API functions. The .NET Rectangle etc can't, because their fields are different. Has conversions from/to Rectangle.


Namespace: Au.Types
Assembly: Au.dll

Constructors

Name Description
RECT(int, int, int, int)

Sets all fields.

Fields

Name Description
bottom
left
right
top

Properties

Name Description
CenterX

Gets horizontal center.

CenterY

Gets vertical center.

Height

Gets or sets height.

Is0

Returns true if all fields == 0.

NoArea

Returns true if the rectangle area is empty or invalid: right<=left || bottom<=top;

Size

Returns new SIZE(Width, Height).

Width

Gets or sets width.

XY

Returns new POINT(left, top).

Methods

Name Description
Contains(POINT)

Returns true if this rectangle contains the specified point.

Contains(RECT)

Returns true if this rectangle contains entire specified rectangle.

Contains(int, int)

Returns true if this rectangle contains the specified point.

EnsureInScreen(screen, bool)

Adjusts this rectangle to ensure that whole rectangle is in screen. Initial and final rectangle coordinates are relative to the primary screen.

From(RectangleF, bool)
From(Rect, bool)
FromLTRB(int, int, int, int)

Creates RECT with specified left, top, right and bottom.

Inflate(int, int)

Makes this rectangle bigger or smaller: left-=dx; right+=dx; top-=dy; bottom+=dy; Use negative dx/dy to make the rectangle smaller. Note: too big negative dx/dy can make it invalid (right<left or bottom<top).

Intersect(RECT)

Replaces this rectangle with the intersection of itself and the specified rectangle. If the rectangles don't intersect, makes this variable empty.

Intersect(RECT, RECT)

Returns the intersection rectangle of two rectangles. If they don't intersect, returns empty rectangle.

IntersectsWith(RECT)

Returns true if this rectangle and another rectangle intersect.

Move(int, int)

Moves this rectangle so that left=x and right=y. Does not change Width and Height.

MoveInRect(RECT, Coord, Coord, bool)

Moves this rectangle to the specified coordinates in another rectangle r.

MoveInScreen(Coord, Coord, screen, bool, bool)

Moves this rectangle to the specified coordinates in the specified screen, and ensures that whole rectangle is in screen. Final rectangle coordinates are relative to the primary screen.

Normalize(bool)

If width or height are negative, modifies this rectangle so that they would not be negative.

Offset(int, int)

Moves this rectangle by the specified offsets: left+=dx; right+=dx; top+=dy; bottom+=dy; Negative dx moves to the left. Negative dy moves up.

ToString()

Converts to string "{L=left T=top W=width H=height}".

ToStringFormat(string)

Formats string from RECT main fields and properties.

ToStringSimple()

Converts to string "left top width height".

TryParse(string, out RECT)

Converts string to RECT.

Union(RECT)

Replaces this rectangle with the union of itself and the specified rectangle. Union is the smallest rectangle that contains two full rectangles. If either rectangle is empty (Width or Height is <=0), the result is another rectangle. If both empty - empty rectangle.

Union(RECT, RECT)

Returns the union of two rectangles. Union is the smallest rectangle that contains two full rectangles. If either rectangle is empty (Width or Height is <=0), the result is another rectangle. If both empty - empty rectangle.

Operators

Name Description
implicit operator Rectangle(RECT)
implicit operator RectangleF(RECT)
implicit operator Rect(RECT)
implicit operator RECT(Rectangle)
implicit operator RECT((int L, int T, int W, int H))

Converts from tuple (left, top, width, height).