Skip to main content

Rect Structure

Defines a rectangle.

Definition

Namespace: Avalonia
Assembly: Avalonia.Base (in Avalonia.Base.dll)

public readonly struct Rect : IEquatable<Rect>
View Source
InheritanceObjectValueType → Rect
ImplementsIEquatable(Rect)

Constructors

Rect(Size)Initializes a new instance of the Rect structure.
Rect(Point, Point)Initializes a new instance of the Rect structure.
Rect(Point, Size)Initializes a new instance of the Rect structure.
Rect(Double, Double, Double, Double)Initializes a new instance of the Rect structure.

Properties

BottomGets the bottom position of the rectangle.
BottomLeftGets the bottom left point of the rectangle.
BottomRightGets the bottom right point of the rectangle.
CenterGets the center point of the rectangle.
HeightGets the height.
LeftGets the left position.
PositionGets the position of the rectangle.
RightGets the right position of the rectangle.
SizeGets the size of the rectangle.
TopGets the top position.
TopLeftGets the top left point of the rectangle.
TopRightGets the top right point of the rectangle.
WidthGets the width.
XGets the X position.
YGets the Y position.

Methods

CenterRect(Rect)Centers another rectangle in this rectangle.
Contains(Point)Determines whether a point is in the bounds of the rectangle.
Contains(Rect)Determines whether the rectangle fully contains another rectangle.
ContainsExclusive(Point)Determines whether a point is in the bounds of the rectangle, exclusive of the rectangle's bottom/right edge.
Deflate(Double)Deflates the rectangle.
Deflate(Thickness)Deflates the rectangle by a Thickness.
Equals(Object)Returns a boolean indicating whether the given object is equal to this rectangle.
(Overrides ValueType.Equals(Object))
Equals(Rect)Returns a boolean indicating whether the rect is equal to the other given rect.
GetHashCode()Returns the hash code for this instance.
(Overrides ValueType.GetHashCode())
GetType()Gets the Type of the current instance.
(Inherited from Object)
Inflate(Double)Inflates the rectangle.
Inflate(Thickness)Inflates the rectangle.
Intersect(Rect)Gets the intersection of two rectangles.
Intersects(Rect)Determines whether a rectangle intersects with this rectangle.
Normalize()Normalizes the rectangle so both the Width and Height are positive, without changing the location of the rectangle
Parse(String)Parses a Rect string.
ToString()Returns the string representation of the rectangle.
(Overrides ValueType.ToString())
TransformToAABB(Matrix)Returns the axis-aligned bounding box of a transformed rectangle.
Translate(Vector)Translates the rectangle by an offset.
Union(Rect)Gets the union of two rectangles.
WithHeight(Double)Returns a new Rect with the specified height.
WithWidth(Double)Returns a new Rect with the specified width.
WithX(Double)Returns a new Rect with the specified X position.
WithY(Double)Returns a new Rect with the specified Y position.

Operators

Division(Rect, Vector)Divides a rectangle by a vector.
Equality(Rect, Rect)Checks for equality between two Rects.
Inequality(Rect, Rect)Checks for inequality between two Rects.
Multiply(Rect, Vector)Multiplies a rectangle by a scaling vector.
Multiply(Rect, Double)Multiplies a rectangle by a scale.

Extension Methods

Align(Rect, HorizontalAlignment, VerticalAlignment)Aligns a rect in a constraining rect according to horizontal and vertical alignment settings.
(Defined by LayoutExtensions)
ToSKRect()
(Defined by SkiaSharpExtensions)

See Also

Reference

Avalonia Namespace