Rectangle class

Rectangle class

Stores a set of four integers that represent the location and size of a rectangle.

The Rectangle type exposes the following members:

Constructors

ConstructorDescription
initInitializes a new instance of the Rectangle structure with the specified location and size.
initInitializes a new instance of the Rectangle structure with the specified location and size.
initConstructs a new instance of Rectangle

Properties

PropertyDescription
emptyGets a new instance of the Rectangle structure that has Rectangle.x, Rectangle.y, Rectangle.width and Rectangle.height values set to zero.
locationGets or sets the coordinates of the upper-left corner of this Rectangle structure.
sizeGets or sets the size of this Rectangle.
xGets or sets the x-coordinate of the upper-left corner of this Rectangle structure.
yGets or sets the y-coordinate of the upper-left corner of this Rectangle structure.
widthGets or sets the width of this Rectangle structure.
heightGets or sets the height of this Rectangle structure.
leftGets or sets the x-coordinate of the left edge of this Rectangle structure.
topGets or sets the y-coordinate of the top edge of this Rectangle structure.
rightGets or sets the x-coordinate that is the sum of Rectangle.x and Rectangle.width property values of this Rectangle structure.
bottomGets or sets the y-coordinate that is the sum of the Rectangle.y and Rectangle.height property values of this Rectangle structure.
is_emptyGets a value indicating whether all numeric properties of this Rectangle have values of zero.

Methods

MethodDescription
inflateCreates and returns an inflated copy of the specified Rectangle structure. The copy is inflated by the specified amount. The original Rectangle structure remains unmodified.
inflateInflates this Rectangle by the specified amount.
inflateInflates this Rectangle by the specified amount.
intersectReturns a third Rectangle structure that represents the intersection of two other Rectangle structures. If there is no intersection, an empty Rectangle is returned.
intersectReplaces this Rectangle with the intersection of itself and the specified Rectangle.
containsDetermines if the specified point is contained within this Rectangle structure.
containsDetermines if the specified point is contained within this Rectangle structure.
containsDetermines if the rectangular region represented by rect is entirely contained within this Rectangle structure.
offsetAdjusts the location of this rectangle by the specified amount.
offsetAdjusts the location of this rectangle by the specified amount.
from_pointsCreates a new Rectangle from two points specified. Two verticales of the created Rectangle will be equal to the passed point1 and point2. These would be typically the opposite vertices.
ceilingConverts the specified RectangleF structure to a Rectangle structure by rounding the RectangleF values to the next higher integer values.
truncateConverts the specified RectangleF to a Rectangle by truncating the RectangleF values.
roundConverts the specified RectangleF to a Rectangle by rounding the RectangleF values to the nearest integer values.
unionGets a Rectangle structure that contains the union of two Rectangle structures.
from_left_top_right_bottomCreates a Rectangle structure with the specified edge locations.
intersects_withDetermines if this rectangle intersects with rect.
normalizeNormalizes the rectangle by making it’s width and height positive, left less than right and top less than bottom.

See Also