Rectangle 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
RectangleRectangle
Attributes

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.

Where Xamarin.Forms supports XAML for Rectangle structures, app devs can represent the rectangle as a comma-separated list of the X-coordinate, Y-Coordinate, Width, and Height.

Constructors

Rectangle(Point, Size) 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.

Rectangle(Double, Double, Double, Double) Rectangle(Double, Double, Double, Double)

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

Fields

Zero Zero

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

Properties

Bottom Bottom

The bottom of the Rectangle.

Center Center

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

Height Height

Extent along the Y axis.

IsEmpty IsEmpty

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

Left Left

The position of the Rectangle on the X axis.

Location Location

The Point defined by Left and Top.

Right Right

The furthest extent along the X axis.

Size Size

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

Top Top

The top of the Rectangle.

Width Width

The extent of this Rectangle along the X axis.

X X

The position of this Rectangle on the X axis.

Y Y

The position of this Rectangle on the Y axis.

Methods

Contains(Point) Contains(Point)

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

Contains(Rectangle) Contains(Rectangle)

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

Contains(Double, Double) Contains(Double, Double)

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

Deconstruct(Double, Double, Double, Double) Deconstruct(Double, Double, Double, Double)

Stores the components of the location and size of the rectangle in the corresponding arguments.

Equals(Rectangle) Equals(Rectangle)

Whether a Rectangle has exactly the same values as thisRectangle.

Equals(Object) Equals(Object)

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

FromLTRB(Double, Double, Double, Double) FromLTRB(Double, Double, Double, Double)

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

GetHashCode() GetHashCode()

The hashcode for the Rectangle.

Inflate(Size) Inflate(Size)

Creates a Rectangle whose borders are inflated in every direction.

Inflate(Double, Double) Inflate(Double, Double)

Creates a Rectangle whose borders are inflated in every direction.

Intersect(Rectangle) Intersect(Rectangle)

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

Intersect(Rectangle, Rectangle) Intersect(Rectangle, Rectangle)

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

IntersectsWith(Rectangle) IntersectsWith(Rectangle)

Whether thisRectangle intersects r.

Offset(Point) Offset(Point)

A new Rectangle whose Location is offset by dr.

Offset(Double, Double) Offset(Double, Double)

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

Round() Round()

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

ToString() ToString()

A human-readable description of the Rectangle.

Union(Rectangle) Union(Rectangle)

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

Union(Rectangle, Rectangle) Union(Rectangle, Rectangle)

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

Operators

Equality(Rectangle, Rectangle) Equality(Rectangle, Rectangle)

Whether two Rectangles have equal values.

Inequality(Rectangle, Rectangle) Inequality(Rectangle, Rectangle)

Whether two Rectangles have unequal values.

Applies to