Compartilhar via


Rectangle Struct

Definition

Struct defining a rectangle, using doubles.

[System.Diagnostics.DebuggerDisplay("X={X}, Y={Y}, Width={Width}, Height={Height}")]
[Xamarin.Forms.TypeConverter(typeof(Xamarin.Forms.RectangleTypeConverter))]
public struct Rectangle
type Rectangle = struct
Inheritance
System.ValueType
Rectangle
Attributes
System.Diagnostics.DebuggerDisplayAttribute TypeConverterAttribute

Remarks

Application developers should be aware of the limits of floating-point representations, specifically the possibility of incorrect comparisons and equality checks for values with small differences. David Goldberg's paper What Every Computer Scientist Should Know About Floating-Point Arithmetic describes the issues excellently.

Constructors

Rectangle(Double, Double, Double, Double)

Creates a new Rectangle object with its top left corner at (x, y) and width wide and height tall.

Rectangle(Point, Size)

Creates a new Rectangle object with its top left corner at loc with a height and width that are specified by sz.

Fields

Zero

The Rectangle at {0,0} whose Size is {0,0}.

Properties

Bottom

The bottom of the Rectangle.

Center

The Point halfway between Left and Right, Top and Bottom.

Height

Extent along the Y axis.

IsEmpty

Whether thisRectangle has either Height or Width less than or equal to 0.

Left

The position of the Rectangle on the X axis.

Location

The Point defined by Left and Top.

Right

The furthest extent along the X axis.

Size

The extent of the Rectangle along its X and Y axes.

Top

The top of the Rectangle.

Width

The extent of this Rectangle along the X axis.

X

The position of this Rectangle on the X axis.

Y

The position of this Rectangle on the Y axis.

Methods

Contains(Double, Double)

Whether the point described by x and y is within, or along the periphery of, this Rectangle.

Contains(Point)

Whether the pt is within, or along the periphery, of this Rectangle.

Contains(Rectangle)

Whether rect is entirely within, or along the periphery, of this Rectangle.

Deconstruct(Double, Double, Double, Double)
Equals(Object)

Whether an System.Object is a Rectangle and has exactly the same values as thisRectangle.

Equals(Rectangle)

Whether a Rectangle has exactly the same values as thisRectangle.

FromLTRB(Double, Double, Double, Double)

Factory method to create a Rectangle from left, top, right, and bottom.

GetHashCode()

The hashcode for the Rectangle.

Inflate(Double, Double)

Creates a Rectangle whose borders are inflated in every direction.

Inflate(Size)

Creates a Rectangle whose borders are inflated in every direction.

Intersect(Rectangle, Rectangle)

A new Rectangle that is the intersection of r1 and r2.

Intersect(Rectangle)

A new Rectangle that is the intersection of this and r.

IntersectsWith(Rectangle)

Whether thisRectangle intersects r.

Offset(Double, Double)

A new Rectangle whose Location is offset by dx and dy.

Offset(Point)

A new Rectangle whose Location is offset by dr.

Round()

Returns a new Rectangle whose values have been rounded to their nearest integral value.

ToString()

A human-readable description of the Rectangle.

Union(Rectangle, Rectangle)

A new Rectangle whose bounds cover the union of r1 and r2.

Union(Rectangle)

A new Rectangle whose bounds cover the union of thisRectangle and r.

Operators

Equality(Rectangle, Rectangle)

Whether two Rectangles have equal values.

Implicit(Rect to Rectangle)
Implicit(Rectangle to Rect)
Inequality(Rectangle, Rectangle)

Whether two Rectangles have unequal values.

Applies to