RogueSharp
Show / Hide Table of Contents

Struct Rectangle

A struct that defines a rectangle

Implements
System.IEquatable<Rectangle>
Inherited Members
System.Object.Equals(System.Object, System.Object)
System.Object.GetType()
System.Object.ReferenceEquals(System.Object, System.Object)
Namespace: RogueSharp
Assembly: RogueSharp.dll
Syntax
public struct Rectangle : IEquatable<Rectangle>

Constructors

| Improve this Doc View Source

Rectangle(Point, Point)

Creates a new instance of Rectangle struct, with the specified location and size.

Declaration
public Rectangle(Point location, Point size)
Parameters
Type Name Description
Point location

The x and y coordinates of the top-left corner of the created Rectangle.

Point size

The width and height of the created Rectangle.

| Improve this Doc View Source

Rectangle(Int32, Int32, Int32, Int32)

Creates a new instance of Rectangle struct, with the specified position, width, and height.

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

The x coordinate of the top-left corner of the created Rectangle.

System.Int32 y

The y coordinate of the top-left corner of the created Rectangle.

System.Int32 width

The width of the created Rectangle.

System.Int32 height

The height of the created Rectangle.

Properties

| Improve this Doc View Source

Bottom

Returns the y-coordinate of the bottom of the rectangle

Declaration
public int Bottom { get; }
Property Value
Type Description
System.Int32
| Improve this Doc View Source

Center

Returns the Point that specifies the center of the rectangle

Declaration
public Point Center { get; }
Property Value
Type Description
Point
| Improve this Doc View Source

Empty

Returns a Rectangle with all of its values set to zero

Declaration
public static Rectangle Empty { get; }
Property Value
Type Description
Rectangle
| Improve this Doc View Source

Height

Specifies the Height of the Rectangle

Declaration
public int Height { get; set; }
Property Value
Type Description
System.Int32
| Improve this Doc View Source

IsEmpty

Returns a value that indicates whether the Rectangle is empty true if the Rectangle is empty; otherwise false

Declaration
public bool IsEmpty { get; }
Property Value
Type Description
System.Boolean
| Improve this Doc View Source

Left

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

Declaration
public int Left { get; }
Property Value
Type Description
System.Int32
| Improve this Doc View Source

Location

Gets or sets the Point representing the upper-left value of the Rectangle

Declaration
public Point Location { get; set; }
Property Value
Type Description
Point
| Improve this Doc View Source

Right

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

Declaration
public int Right { get; }
Property Value
Type Description
System.Int32
| Improve this Doc View Source

Top

Returns the y-coordinate of the top of the rectangle

Declaration
public int Top { get; }
Property Value
Type Description
System.Int32
| Improve this Doc View Source

Width

Specifies the Width of the Rectangle

Declaration
public int Width { get; set; }
Property Value
Type Description
System.Int32
| Improve this Doc View Source

X

Specifies the x-coordinate of the Rectangle with 0 being to the left and increasing as the Rectangle is moved to the right

Declaration
public int X { get; set; }
Property Value
Type Description
System.Int32
| Improve this Doc View Source

Y

Specifies the y-coordinate of the Rectangle with 0 being at the top and increasing as the Rectangle is moved downwards

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

Methods

| Improve this Doc View Source

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

True if the specified Point is contained within this Rectangle; False otherwise

| Improve this Doc View Source

Contains(Rectangle)

Determines whether this Rectangle entirely contains the specified Rectangle

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

The Rectangle to evaluate

Returns
Type Description
System.Boolean

True if this Rectangle entirely contains the specified Rectangle; False otherwise

| Improve this Doc View Source

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

True if the specified point is contained within this Rectangle; False otherwise

| Improve this Doc View Source

Equals(Rectangle)

Determines whether two Rectangle instances are equal

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

The Rectangle to compare this instance to

Returns
Type Description
System.Boolean

True if the instances are equal; False otherwise

| Improve this Doc View Source

Equals(Object)

Compares whether current instance is equal to specified System.Object.

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

The System.Object to compare.

Returns
Type Description
System.Boolean

true if the instances are equal; false otherwise.

Overrides
System.ValueType.Equals(System.Object)
| Improve this Doc View Source

GetHashCode()

Gets the hash code for this object which can help for quick checks of equality or when inserting this Rectangle into a hash-based collection such as a Dictionary or Hashtable

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

An integer hash used to identify this Rectangle

Overrides
System.ValueType.GetHashCode()
| Improve this Doc View Source

Inflate(Int32, Int32)

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

Declaration
public void Inflate(int horizontalValue, int verticalValue)
Parameters
Type Name Description
System.Int32 horizontalValue

Value to push the sides out by

System.Int32 verticalValue

Value to push the top and bottom out by

Exceptions
Type Condition
System.OverflowException

Thrown if the new width or height exceed Int32.MaxValue, or new X or Y are smaller than int32.MinValue

| Improve this Doc View Source

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

The area where the two specified Rectangles overlap. If the two Rectangles do not overlap the resulting Rectangle will be Empty

| Improve this Doc View Source

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

The area where the two specified Rectangles overlap. If the two Rectangles do not overlap the resulting Rectangle will be Empty

| Improve this Doc View Source

Intersects(Rectangle)

Determines whether this Rectangle intersects with the specified Rectangle

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

The Rectangle to evaluate

Returns
Type Description
System.Boolean

True if the specified Rectangle intersects with this one; False otherwise

| Improve this Doc View Source

Intersects(ref Rectangle, out Boolean)

Determines whether this Rectangle intersects with the specified Rectangle

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

The Rectangle to evaluate

System.Boolean result

True if the specified Rectangle intersects with this one; False otherwise

| Improve this Doc View Source

Offset(Point)

Changes the position of the Rectangles by the values of the specified Point

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

The values to adjust the position of the Rectangle by

| Improve this Doc View Source

Offset(Int32, Int32)

Changes the position of the Rectangle by the specified x and y offsets

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

| Improve this Doc View Source

ToString()

Returns a string that represents the current Rectangle

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

A string that represents the current Rectangle

Overrides
System.ValueType.ToString()
| Improve this Doc View Source

Union(Rectangle, Rectangle)

Creates a new Rectangle that exactly contains the specified two 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

A new Rectangle that exactly contains the specified two Rectangles

| Improve this Doc View Source

Union(ref Rectangle, ref Rectangle, out Rectangle)

Creates a new Rectangle that completely 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.

Rectangle value2

The second Rectangle.

Rectangle result

The union of the two rectangles as an output parameter.

Operators

| Improve this Doc View Source

Equality(Rectangle, Rectangle)

Compares two rectangles for equality

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

Rectangle on the left side of the equals sign

Rectangle b

Rectangle on the right side of the equals sign

Returns
Type Description
System.Boolean

True if the rectangles are equal; False otherwise

| Improve this Doc View Source

Inequality(Rectangle, Rectangle)

Compares two rectangles for inequality

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

Rectangle on the left side of the equals sign

Rectangle b

Rectangle on the right side of the equals sign

Returns
Type Description
System.Boolean

True if the rectangles are not equal; False otherwise

Implements

System.IEquatable<T>
  • Improve this Doc
  • View Source
RogueSharp © 2014-2020 Faron Bracy
Back to top