Rect Struct
Definition
Defines a rectangle.
public struct Rect
Constructors
| Name | Description |
|---|---|
| Rect (4 overloads) | Initializes a new instance of the Avalonia.Rect structure. |
Rect overloads
Rect Constructor
Initializes a new instance of the Avalonia.Rect structure.
public Rect(Avalonia.Point topLeft, Avalonia.Point bottomRight)
Parameters
topLeft Avalonia.Point
The top left position of the rectangle.
bottomRight Avalonia.Point
The bottom right position of the rectangle.
Rect Constructor
Initializes a new instance of the Avalonia.Rect structure.
public Rect(Avalonia.Point position, Avalonia.Size size)
Parameters
position Avalonia.Point
The position of the rectangle.
size Avalonia.Size
The size of the rectangle.
Rect Constructor
Initializes a new instance of the Avalonia.Rect structure.
public Rect(Avalonia.Size size)
Parameters
size Avalonia.Size
The size of the rectangle.
Rect Constructor
Initializes a new instance of the Avalonia.Rect structure.
public Rect(double x, double y, double width, double height)
Parameters
x double
The X position.
y double
The Y position.
width double
The width.
height double
The height.
Methods
| Name | Description |
|---|---|
| CenterRect | Centers another rectangle in this rectangle. |
| Contains (2 overloads) | Determines whether a point is in the bounds of the rectangle. |
| ContainsExclusive | Determines whether a point is in the bounds of the rectangle, exclusive of the rectangle's bottom/right edge. |
| Deflate (2 overloads) | Deflates the rectangle by a Avalonia.Thickness. |
| Equals (2 overloads) | Returns a boolean indicating whether the rect is equal to the other given rect. |
| GetHashCode | Returns the hash code for this instance. |
| Inflate (2 overloads) | Inflates the rectangle. |
| Intersect | Gets the intersection of two rectangles. |
| Intersects | Determines whether a rectangle intersects with this rectangle. |
| Normalize | Normalizes the rectangle so both the Avalonia.Rect.Width and Avalonia.Rect.Height are positive, without changing the location of the rectangle |
| Parse | Parses a Avalonia.Rect string. |
| ToString | Returns the string representation of the rectangle. |
| TransformToAABB | Returns the axis-aligned bounding box of a transformed rectangle. |
| Translate | Translates the rectangle by an offset. |
| Union | Gets the union of two rectangles. |
| WithHeight | Returns a new Avalonia.Rect with the specified height. |
| WithWidth | Returns a new Avalonia.Rect with the specified width. |
| WithX | Returns a new Avalonia.Rect with the specified X position. |
| WithY | Returns a new Avalonia.Rect with the specified Y position. |
CenterRect Method
Centers another rectangle in this rectangle.
public Avalonia.Rect CenterRect(Avalonia.Rect rect)
Parameters
rect Avalonia.Rect
The rectangle to center.
Returns
The centered rectangle.
Contains overloads
Contains Method
Determines whether a point is in the bounds of the rectangle.
public bool Contains(Avalonia.Point p)
Parameters
The point.
Returns
bool
true if the point is in the bounds of the rectangle; otherwise false.
Contains Method
Determines whether the rectangle fully contains another rectangle.
public bool Contains(Avalonia.Rect r)
Parameters
The rectangle.
Returns
bool
true if the rectangle is fully contained; otherwise false.
ContainsExclusive Method
Determines whether a point is in the bounds of the rectangle, exclusive of the rectangle's bottom/right edge.
public bool ContainsExclusive(Avalonia.Point p)
Parameters
The point.
Returns
bool
true if the point is in the bounds of the rectangle; otherwise false.
Deflate overloads
Deflate Method
Deflates the rectangle by a Avalonia.Thickness.
public Avalonia.Rect Deflate(Avalonia.Thickness thickness)
Parameters
thickness Avalonia.Thickness
The thickness to be subtracted for each side of the rectangle.
Returns
The deflated rectangle.
Deflate Method
Deflates the rectangle.
public Avalonia.Rect Deflate(double thickness)
Parameters
thickness double
The thickness to be subtracted for each side of the rectangle.
Returns
The deflated rectangle.
Equals overloads
Equals Method
Returns a boolean indicating whether the rect is equal to the other given rect.
public bool Equals(Avalonia.Rect other)
Parameters
other Avalonia.Rect
The other rect to test equality against.
Returns
bool
True if this rect is equal to other; False otherwise.
Equals Method
Returns a boolean indicating whether the given object is equal to this rectangle.
public bool Equals(object obj)
Parameters
obj object
The object to compare against.
Returns
bool
True if the object is equal to this rectangle; false otherwise.
GetHashCode Method
Returns the hash code for this instance.
public int GetHashCode()
Returns
int
The hash code.
Inflate overloads
Inflate Method
Inflates the rectangle.
public Avalonia.Rect Inflate(Avalonia.Thickness thickness)
Parameters
thickness Avalonia.Thickness
The thickness to be subtracted for each side of the rectangle.
Returns
The inflated rectangle.
Inflate Method
Inflates the rectangle.
public Avalonia.Rect Inflate(double thickness)
Parameters
thickness double
The thickness to be subtracted for each side of the rectangle.
Returns
The inflated rectangle.
Intersect Method
Gets the intersection of two rectangles.
public Avalonia.Rect Intersect(Avalonia.Rect rect)
Parameters
rect Avalonia.Rect
The other rectangle.
Returns
The intersection.
Intersects Method
Determines whether a rectangle intersects with this rectangle.
public bool Intersects(Avalonia.Rect rect)
Parameters
rect Avalonia.Rect
The other rectangle.
Returns
bool
True if the specified rectangle intersects with this one; otherwise false.
Normalize Method
Normalizes the rectangle so both the Avalonia.Rect.Width and Avalonia.Rect.Height are positive, without changing the location of the rectangle
public Avalonia.Rect Normalize()
Returns
Normalized Rect
Remarks
Empty rect will be return when Rect contains invalid values. Like NaN.
Parse Method
Parses a Avalonia.Rect string.
public Avalonia.Rect Parse(string s)
Parameters
s string
The string.
Returns
The parsed Avalonia.Rect.
ToString Method
Returns the string representation of the rectangle.
public string ToString()
Returns
string
The string representation of the rectangle.
TransformToAABB Method
Returns the axis-aligned bounding box of a transformed rectangle.
public Avalonia.Rect TransformToAABB(Avalonia.Matrix matrix)
Parameters
matrix Avalonia.Matrix
The transform.
Returns
The bounding box
Translate Method
Translates the rectangle by an offset.
public Avalonia.Rect Translate(Avalonia.Vector offset)
Parameters
offset Avalonia.Vector
The offset.
Returns
The translated rectangle.
Union Method
Gets the union of two rectangles.
public Avalonia.Rect Union(Avalonia.Rect rect)
Parameters
rect Avalonia.Rect
The other rectangle.
Returns
The union.
WithHeight Method
Returns a new Avalonia.Rect with the specified height.
public Avalonia.Rect WithHeight(double height)
Parameters
height double
The height.
Returns
The new Avalonia.Rect.
WithWidth Method
Returns a new Avalonia.Rect with the specified width.
public Avalonia.Rect WithWidth(double width)
Parameters
width double
The width.
Returns
The new Avalonia.Rect.
WithX Method
Returns a new Avalonia.Rect with the specified X position.
public Avalonia.Rect WithX(double x)
Parameters
x double
The x position.
Returns
The new Avalonia.Rect.
WithY Method
Returns a new Avalonia.Rect with the specified Y position.
public Avalonia.Rect WithY(double y)
Parameters
y double
The y position.
Returns
The new Avalonia.Rect.
Properties
| Name | Description |
|---|---|
| Bottom | Gets the bottom position of the rectangle. |
| BottomLeft | Gets the bottom left point of the rectangle. |
| BottomRight | Gets the bottom right point of the rectangle. |
| Center | Gets the center point of the rectangle. |
| Height | Gets the height. |
| Left | Gets the left position. |
| Position | Gets the position of the rectangle. |
| Right | Gets the right position of the rectangle. |
| Size | Gets the size of the rectangle. |
| Top | Gets the top position. |
| TopLeft | Gets the top left point of the rectangle. |
| TopRight | Gets the top right point of the rectangle. |
| Width | Gets the width. |
| X | Gets the X position. |
| Y | Gets the Y position. |
Bottom Property
Gets the bottom position of the rectangle.
public double Bottom { get; set; }
BottomLeft Property
Gets the bottom left point of the rectangle.
public Avalonia.Point BottomLeft { get; set; }
BottomRight Property
Gets the bottom right point of the rectangle.
public Avalonia.Point BottomRight { get; set; }
Center Property
Gets the center point of the rectangle.
public Avalonia.Point Center { get; set; }
Height Property
Gets the height.
public double Height { get; set; }
Left Property
Gets the left position.
public double Left { get; set; }
Position Property
Gets the position of the rectangle.
public Avalonia.Point Position { get; set; }
Right Property
Gets the right position of the rectangle.
public double Right { get; set; }
Size Property
Gets the size of the rectangle.
public Avalonia.Size Size { get; set; }
Top Property
Gets the top position.
public double Top { get; set; }
TopLeft Property
Gets the top left point of the rectangle.
public Avalonia.Point TopLeft { get; set; }
TopRight Property
Gets the top right point of the rectangle.
public Avalonia.Point TopRight { get; set; }
Width Property
Gets the width.
public double Width { get; set; }
X Property
Gets the X position.
public double X { get; set; }
Y Property
Gets the Y position.
public double Y { get; set; }