Show / Hide Table of Contents

Class Rectangle

Defines a rectangle.

Inheritance
System.Object
Rectangle
Namespace: VRageMath
Assembly: VRage.Math.dll
Syntax
public sealed class Rectangle : ValueType, IEquatable<Rectangle>

Constructors

Rectangle(Int32, Int32, Int32, Int32)

Initializes a new instance of Rectangle.

Declaration
public Rectangle(int x, int y, int width, int height)
Parameters
Type Name Description
System.Int32 x

The x-coordinate of the rectangle.

System.Int32 y

The y-coordinate of the rectangle.

System.Int32 width

Width of the rectangle.

System.Int32 height

Height of the rectangle.

Fields

Height

Specifies the height of the rectangle.

Declaration
public int Height
Field Value
Type Description
System.Int32

Width

Specifies the width of the rectangle.

Declaration
public int Width
Field Value
Type Description
System.Int32

X

Specifies the x-coordinate of the rectangle.

Declaration
public int X
Field Value
Type Description
System.Int32

Y

Specifies the y-coordinate of the rectangle.

Declaration
public int Y
Field Value
Type Description
System.Int32

Properties

Bottom

Returns the y-coordinate of the bottom of the rectangle.

Declaration
public int Bottom { get; }
Property Value
Type Description
System.Int32

Center

Gets the Point that specifies the center of the rectangle.

Declaration
public Point Center { get; }
Property Value
Type Description
Point

Left

Returns the x-coordinate of the left side of the rectangle.

Declaration
public int Left { get; }
Property Value
Type Description
System.Int32

Location

Gets or sets the upper-left value of the Rectangle.

Declaration
public Point Location { get; set; }
Property Value
Type Description
Point

Right

Returns the x-coordinate of the right side of the rectangle.

Declaration
public int Right { get; }
Property Value
Type Description
System.Int32

Top

Returns the y-coordinate of the top of the rectangle.

Declaration
public int Top { get; }
Property Value
Type Description
System.Int32

Methods

Contains(Int32, Int32)

Determines whether this Rectangle contains a specified point represented by its x- and y-coordinates.

Declaration
public bool Contains(int x, int y)
Parameters
Type Name Description
System.Int32 x

The x-coordinate of the specified point.

System.Int32 y

The y-coordinate of the specified point.

Returns
Type Description
System.Boolean

Contains(Point)

Determines whether this Rectangle contains a specified Point.

Declaration
public bool Contains(Point value)
Parameters
Type Name Description
Point value

The Point to evaluate.

Returns
Type Description
System.Boolean

Contains(ref Point, out Boolean)

Determines whether this Rectangle contains a specified Point.

Declaration
public void Contains(ref Point value, out bool result)
Parameters
Type Name Description
Point value

The Point to evaluate.

System.Boolean result

[OutAttribute] true if the specified Point is contained within this Rectangle; false otherwise.

Contains(Rectangle)

Determines whether this Rectangle entirely contains a specified Rectangle.

Declaration
public bool Contains(Rectangle value)
Parameters
Type Name Description
Rectangle value

The Rectangle to evaluate.

Returns
Type Description
System.Boolean

Contains(ref Rectangle, out Boolean)

Determines whether this Rectangle entirely contains a specified Rectangle.

Declaration
public void Contains(ref Rectangle value, out bool result)
Parameters
Type Name Description
Rectangle value

The Rectangle to evaluate.

System.Boolean result

[OutAttribute] On exit, is true if this Rectangle entirely contains the specified Rectangle, or false if not.

Equals(Object)

Returns a value that indicates whether the current instance is equal to a specified object.

Declaration
public override bool Equals(object obj)
Parameters
Type Name Description
System.Object obj

Object to make the comparison with.

Returns
Type Description
System.Boolean

Equals(Rectangle)

Determines whether the specified Object is equal to the Rectangle.

Declaration
public bool Equals(Rectangle other)
Parameters
Type Name Description
Rectangle other

The Object to compare with the current Rectangle.

Returns
Type Description
System.Boolean

GetHashCode()

Gets the hash code for this object.

Declaration
public override int GetHashCode()
Returns
Type Description
System.Int32

Inflate(Int32, Int32)

Pushes the edges of the Rectangle out by the horizontal and vertical values specified.

Declaration
public void Inflate(int horizontalAmount, int verticalAmount)
Parameters
Type Name Description
System.Int32 horizontalAmount

Value to push the sides out by.

System.Int32 verticalAmount

Value to push the top and bottom out by.

Intersect(Rectangle, Rectangle)

Creates a Rectangle defining the area where one rectangle overlaps with another rectangle.

Declaration
public static Rectangle Intersect(Rectangle value1, Rectangle value2)
Parameters
Type Name Description
Rectangle value1

The first Rectangle to compare.

Rectangle value2

The second Rectangle to compare.

Returns
Type Description
Rectangle

Intersect(ref Rectangle, ref Rectangle, out Rectangle)

Creates a Rectangle defining the area where one rectangle overlaps with another rectangle.

Declaration
public static void Intersect(ref Rectangle value1, ref Rectangle value2, out Rectangle result)
Parameters
Type Name Description
Rectangle value1

The first Rectangle to compare.

Rectangle value2

The second Rectangle to compare.

Rectangle result

[OutAttribute] The area where the two first parameters overlap.

Intersects(Rectangle)

Determines whether a specified Rectangle intersects with this Rectangle.

Declaration
public bool Intersects(Rectangle value)
Parameters
Type Name Description
Rectangle value

The Rectangle to evaluate.

Returns
Type Description
System.Boolean

Intersects(ref Rectangle, out Boolean)

Determines whether a specified Rectangle intersects with this Rectangle.

Declaration
public void Intersects(ref Rectangle value, out bool result)
Parameters
Type Name Description
Rectangle value

The Rectangle to evaluate

System.Boolean result

[OutAttribute] true if the specified Rectangle intersects with this one; false otherwise.

Offset(Int32, Int32)

Changes the position of the Rectangle.

Declaration
public void Offset(int offsetX, int offsetY)
Parameters
Type Name Description
System.Int32 offsetX

Change in the x-position.

System.Int32 offsetY

Change in the y-position.

Offset(Point)

Changes the position of the Rectangle.

Declaration
public void Offset(Point amount)
Parameters
Type Name Description
Point amount

The values to adjust the position of the Rectangle by.

ToString()

Retrieves a string representation of the current object.

Declaration
public override string ToString()
Returns
Type Description
System.String

Union(Rectangle, Rectangle)

Creates a new Rectangle that exactly contains two other rectangles.

Declaration
public static Rectangle Union(Rectangle value1, Rectangle value2)
Parameters
Type Name Description
Rectangle value1

The first Rectangle to contain.

Rectangle value2

The second Rectangle to contain.

Returns
Type Description
Rectangle

Union(ref Rectangle, ref Rectangle, out Rectangle)

Creates a new Rectangle that exactly contains two other rectangles.

Declaration
public static void Union(ref Rectangle value1, ref Rectangle value2, out Rectangle result)
Parameters
Type Name Description
Rectangle value1

The first Rectangle to contain.

Rectangle value2

The second Rectangle to contain.

Rectangle result

[OutAttribute] The Rectangle that must be the union of the first two rectangles.

Operators

Equality(Rectangle, Rectangle)

Compares two rectangles for equality.

Declaration
public static bool operator ==(Rectangle a, Rectangle b)
Parameters
Type Name Description
Rectangle a

Source rectangle.

Rectangle b

Source rectangle.

Returns
Type Description
System.Boolean

Inequality(Rectangle, Rectangle)

Compares two rectangles for inequality.

Declaration
public static bool operator !=(Rectangle a, Rectangle b)
Parameters
Type Name Description
Rectangle a

Source rectangle.

Rectangle b

Source rectangle.

Returns
Type Description
System.Boolean
☀
☾
In This Article
Back to top
Generated by DocFX
☀
☾