Struct
Rect

Axis-aligned rectangle defined by X, Y, Width, and Height used in geometry, layout, and hit‑testing.

Definition

Namespace:Telerik.Documents.Primitives

Assembly:Telerik.Windows.Documents.Core.dll

Syntax:

cs-api-definition
public struct Rect

Inherited Members ValueType.ToString()

Constructors

Rect(double, double, double, double)

Initializes a new instance of the Rect structure.

Declaration

cs-api-definition
public Rect(double x, double y, double width, double height)

Parameters

x

double

The X coordinate.

y

double

The Y coordinate.

width

double

The width. Should be non-negative.

height

double

The height. Should be non-negative.

Properties

Bottom

Gets the Y + Height value. If this is an Empty Rect gets negative-infinity.

Declaration

cs-api-definition
public double Bottom { get; }

Property Value

double

BottomLeft

BottomLeft Property - This is a read-only alias for the Point which is at X, Y + Height If this is the empty rectangle, the value will be positive infinity, negative infinity.

Declaration

cs-api-definition
public Point BottomLeft { get; }

Property Value

Point

BottomRight

BottomRight Property - This is a read-only alias for the Point which is at X + Width, Y + Height If this is the empty rectangle, the value will be negative infinity, negative infinity.

Declaration

cs-api-definition
public Point BottomRight { get; }

Property Value

Point

Empty

Gets an empty Rect. It has negative-infinity Width and Height and positive-infinity X and Y.

Declaration

cs-api-definition
public static Rect Empty { get; }

Property Value

Rect

Height

Gets or sets the Height. Cannot set Height if this is an Empty Rect. Should be non-negative.

Declaration

cs-api-definition
public double Height { get; set; }

Property Value

double

IsEmpty

Returns true if this is the Empty Rect.

Declaration

cs-api-definition
public bool IsEmpty { get; }

Property Value

bool

Left

Gets the value of the X coordinate.

Declaration

cs-api-definition
public double Left { get; }

Property Value

double

Location

Gets or sets the coordinates of the upper-left corner of this Rect structure.

Declaration

cs-api-definition
public Point Location { get; set; }

Property Value

Point

Right

Gets the X + Width value. If this is an Empty Rect returns negative-infinity.

Declaration

cs-api-definition
public double Right { get; }

Property Value

double

Size

Size - The Size representing the area of the Rectangle

Declaration

cs-api-definition
public Size Size { get; set; }

Property Value

Size

Top

Gets the value of the Y coordinate.

Declaration

cs-api-definition
public double Top { get; }

Property Value

double

TopLeft

TopLeft Property - This is a read-only alias for the Point which is at X, Y If this is the empty rectangle, the value will be positive infinity, positive infinity.

Declaration

cs-api-definition
public Point TopLeft { get; }

Property Value

Point

TopRight

TopRight Property - This is a read-only alias for the Point which is at X + Width, Y If this is the empty rectangle, the value will be negative infinity, positive infinity.

Declaration

cs-api-definition
public Point TopRight { get; }

Property Value

Point

Width

Gets or sets the Width. Cannot set Width if this is an Empty Rect. Should be non-negative.

Declaration

cs-api-definition
public double Width { get; set; }

Property Value

double

X

Gets or sets the X coordinate. Cannot set X if this is an Empty Rect.

Declaration

cs-api-definition
public double X { get; set; }

Property Value

double

Y

Gets or sets the Y coordinate. Cannot set Y if this is an Empty Rect.

Declaration

cs-api-definition
public double Y { get; set; }

Property Value

double

Methods

Contains(Rect)

Contains - Returns true if the Rect non-Empty and is entirely contained within the rectangle, inclusive of the edges. Returns false otherwise

Declaration

cs-api-definition
public bool Contains(Rect rect)

Parameters

rect

Rect

Returns

bool

Contains(double, double)

Returns a value indicating whether the x, y coordinates are inside the rectangle, including the edges.

Declaration

cs-api-definition
public bool Contains(double x, double y)

Parameters

x

double

y

double

Returns

bool

Equals(object)

Determines whether the specified object is equal to the current Rect.

Declaration

cs-api-definition
public override bool Equals(object obj)

Parameters

obj

object

The object to compare with the current instance.

Returns

bool

True if the specified object is a Rect whose position and size match this instance (with Empty handled specially); otherwise, false.

Overrides ValueType.Equals(object)

GetHashCode()

Returns a hash code for the current Rect.

Declaration

cs-api-definition
public override int GetHashCode()

Returns

int

A hash code based on X, Y, Width, and Height; returns 0 for the Empty rectangle.

Overrides ValueType.GetHashCode()

Intersect(Rect)

Intersect - Update this rectangle to be the intersection of this and rect If either this or rect are Empty, the result is Empty as well.

Declaration

cs-api-definition
public void Intersect(Rect rect)

Parameters

rect

Rect

The rect to intersect with this

IntersectsWith(Rect)

IntersectsWith - Returns true if the Rect intersects with this rectangle Returns false otherwise. Note that if one edge is coincident, this is considered an intersection.

Declaration

cs-api-definition
public bool IntersectsWith(Rect rect)

Parameters

rect

Rect

Rect

Returns

bool

Returns true if the Rect intersects with this rectangle Returns false otherwise. or Height

Union(Rect)

This Rect becomes a the result of union of this and otherRect.

Declaration

cs-api-definition
public void Union(Rect otherRect)

Parameters

otherRect

Rect

Operators

operator !=(Rect, Rect)

Compares two Rect instances for exact inequality.

Declaration

cs-api-definition
public static bool operator !=(Rect firstRect, Rect secondRect)

Parameters

firstRect

Rect

The first Rect to compare.

secondRect

Rect

The second Rect to compare.

Returns

bool

True if the two Rects are exactly unequal; otherwise false.

operator ==(Rect, Rect)

Compares two Rect instances for exact equality.

Declaration

cs-api-definition
public static bool operator ==(Rect firstRect, Rect secondRect)

Parameters

firstRect

Rect

The first Rect to compare.

secondRect

Rect

The second Rect to compare.

Returns

bool

True if the two Rects are exactly equal; otherwise false.