Show / Hide Table of Contents

Struct Rectangle

Represents a rectangle in terms of grid squares. Provides numerous static functions that enable creation and common operations involving rectangles, as well as implicit conversion operators that enable interoperability with rectangle representations from other libraries.

Implements
System.IEquatable<Rectangle>
System.IEquatable<System.ValueTuple<System.Int32, System.Int32, System.Int32, System.Int32>>
Inherited Members
System.Object.Equals(System.Object, System.Object)
System.Object.GetType()
System.Object.ReferenceEquals(System.Object, System.Object)
Namespace: GoRogue
Assembly: GoRogue.dll
Syntax
[Serializable]
public struct Rectangle : IEquatable<Rectangle>, IEquatable<(int x, int y, int width, int height)>
Remarks

Rectangle is designed to be extremely efficient and interoperable with equivalent representations in other libraries, so in general, in an environment where you have multiple rectangle representations defined, it is best to prefer Rectangle where possible, as something that accepts or works with Rectangle will generally work with other supported types as well.

Constructors

| Improve this Doc View Source

Rectangle(Coord, Coord)

Constructor.

Declaration
public Rectangle(Coord minExtent, Coord maxExtent)
Parameters
Type Name Description
Coord minExtent

Minimum x and y values that are considered inside the rectangle.

Coord maxExtent

Maximum x and y values that are considered inside the rectangle.

| Improve this Doc View Source

Rectangle(Coord, Int32, Int32)

Constructor.

Declaration
public Rectangle(Coord center, int horizontalRadius, int verticalRadius)
Parameters
Type Name Description
Coord center

The center point of the rectangle.

System.Int32 horizontalRadius

Number of units to the left and right of the center point that are included within the rectangle.

System.Int32 verticalRadius

Number of units to the top and bottom of the center point that are included within the rectangle.

| Improve this Doc View Source

Rectangle(Int32, Int32, Int32, Int32)

Constructor.

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

Minimum x coordinate that is inside the rectangle.

System.Int32 y

Minimum y coordinate that is inside the rectangle.

System.Int32 width

Width of the rectangle.

System.Int32 height

Height of the rectangle.

Fields

| Improve this Doc View Source

EMPTY

The empty rectangle. Has origin of (0, 0) with 0 width and height.

Declaration
[NonSerialized]
public static readonly Rectangle EMPTY
Field Value
Type Description
Rectangle
| Improve this Doc View Source

Height

The height of the rectangle.

Declaration
public readonly int Height
Field Value
Type Description
System.Int32
| Improve this Doc View Source

Width

The width of the rectangle.

Declaration
public readonly int Width
Field Value
Type Description
System.Int32
| Improve this Doc View Source

X

X-coordinate of position of the rectangle.

Declaration
public readonly int X
Field Value
Type Description
System.Int32
| Improve this Doc View Source

Y

Y-coordinate of position of the rectangle.

Declaration
public readonly int Y
Field Value
Type Description
System.Int32

Properties

| Improve this Doc View Source

Area

Calculates the area of the rectangle.

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

Center

The center coordinate of the rectangle, rounded up if the exact center is between two positions. The center of a rectangle with width/height 1 is its Position.

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

IsEmpty

Whether or not this rectangle is empty (has width and height of 0).

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

MaxExtent

The maximum X and Y coordinates that are included in the rectangle.

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

MaxExtentX

The maximum X-coordinate that is included in the rectangle.

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

MaxExtentY

The maximum Y-coordinate that is included in the rectangle.

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

MinExtent

Minimum extent of the rectangle (minimum x and y values that are included within it). Identical to Position because we define the rectangle's position by its minimum extent.

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

MinExtentX

X-value of the minimum extent of the rectangle (minimum x value that is included within it). Identical to the X value because we define the rectangle's position by its minimum extent.

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

MinExtentY

Y-value of the minimum extent of the rectangle (minimum y value that is included within it). Identical to the Y value because we define the rectangle's position by its minimum extent.

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

Perimeter

Calculates the perimeter length of the rectangle. This is equal to the mathematical perimeter, NOT the number of grid squares around the perimiter.

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

Position

Coord representing the position (min x- and y-values) of the rectangle.

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

Size

Returns a coordinate (Width, Height), which represents the size of the rectangle.

Declaration
public Coord Size { get; }
Property Value
Type Description
Coord

Methods

| Improve this Doc View Source

ChangeHeight(Int32)

Creates and returns a new rectangle whose position is the same as the current one, but has its height changed by the given delta-change value.

Declaration
public Rectangle ChangeHeight(int deltaHeight)
Parameters
Type Name Description
System.Int32 deltaHeight

Delta-change for the height of the new rectangle.

Returns
Type Description
Rectangle

A new rectangle whose height is modified by the given delta-change value.

| Improve this Doc View Source

ChangeSize(Coord)

Creates and returns a new rectangle whose position is the same as the current one, but has its width and height changed by the given delta-change values.

Declaration
public Rectangle ChangeSize(Coord deltaChange)
Parameters
Type Name Description
Coord deltaChange

Vector (deltaWidth, deltaHeight) specifying the delta-change values for the width/height of the new Rectangle.

Returns
Type Description
Rectangle

A new rectangle whose width/height are modified by the given delta-change values.

| Improve this Doc View Source

ChangeSize(Int32, Int32)

Creates and returns a new rectangle whose position is the same as the current one, but has its width and height changed by the given delta-change values.

Declaration
public Rectangle ChangeSize(int deltaWidth, int deltaHeight)
Parameters
Type Name Description
System.Int32 deltaWidth

Delta-change for the width of the new rectangle.

System.Int32 deltaHeight

Delta-change for the height of the new rectangle.

Returns
Type Description
Rectangle

A new rectangle whose width/height are modified by the given delta-change values.

| Improve this Doc View Source

ChangeWidth(Int32)

Creates and returns a new rectangle whose position is the same as the current one, but has its width changed by the given delta-change value.

Declaration
public Rectangle ChangeWidth(int deltaWidth)
Parameters
Type Name Description
System.Int32 deltaWidth

Delta-change for the width of the new rectangle.

Returns
Type Description
Rectangle

A new rectangle whose width is modified by the given delta-change value.

| Improve this Doc View Source

Contains(Coord)

Returns whether or not the specified point is considered within the rectangle.

Declaration
public bool Contains(Coord position)
Parameters
Type Name Description
Coord position

The position to check.

Returns
Type Description
System.Boolean

Whether or not the specified point is considered within the rectangle.

| Improve this Doc View Source

Contains(Rectangle)

Returns whether or not the specified rectangle is considered completely contained within the current one.

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

The rectangle to check.

Returns
Type Description
System.Boolean

True if the given rectangle is completely contained within the current one, false otherwise.

| Improve this Doc View Source

Contains(Int32, Int32)

Returns whether or not the specified point is considered within the rectangle.

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

The x-value position to check.

System.Int32 y

The y-value position to check.

Returns
Type Description
System.Boolean

Whether or not the specified point is considered within the rectangle.

| Improve this Doc View Source

Deconstruct(out Int32, out Int32, out Int32, out Int32)

Adds support for C# Deconstruction syntax.

Declaration
public void Deconstruct(out int x, out int y, out int width, out int height)
Parameters
Type Name Description
System.Int32 x
System.Int32 y
System.Int32 width
System.Int32 height
| Improve this Doc View Source

Equals(Rectangle)

Compares based upon whether or not the areas contained within the rectangle are identical in both position and extents.

Declaration
public bool Equals(Rectangle other)
Parameters
Type Name Description
Rectangle other
Returns
Type Description
System.Boolean

true if the area of the two rectangles encompass the exact same area, false otherwise.

| Improve this Doc View Source

Equals(Object)

Compares to an arbitrary object.

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

true if the object specified is a rectangle instance and encompasses the same area, false otherwise.

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

Equals((Int32 x, Int32 y, Int32 width, Int32 height))

True if the given position has equal x and y values to the current one.

Declaration
public bool Equals((int x, int y, int width, int height) other)
Parameters
Type Name Description
System.ValueTuple<System.Int32, System.Int32, System.Int32, System.Int32> other

Point to compare.

Returns
Type Description
System.Boolean

True if the two positions are equal, false if not.

| Improve this Doc View Source

Expand(Int32, Int32)

Returns a new rectangle, expanded to include the additional specified number of tiles on the left/right and top/bottom.

Declaration
public Rectangle Expand(int horizontalChange, int verticalChange)
Parameters
Type Name Description
System.Int32 horizontalChange

Number of additional tiles to include on the left/right of the rectangle.

System.Int32 verticalChange

Number of additional tiles to include on the top/bottom of the rectangle.

Returns
Type Description
Rectangle

A new rectangle, expanded appropriately.

| Improve this Doc View Source

GetDifference(Rectangle, Rectangle)

Gets a MapArea representing every location in rect1 that is NOT in rect2.

Declaration
public static MapArea GetDifference(Rectangle rect1, Rectangle rect2)
Parameters
Type Name Description
Rectangle rect1
Rectangle rect2
Returns
Type Description
MapArea

A MapArea representing every location in rect1 that is NOT in rect2.

| Improve this Doc View Source

GetExactUnion(Rectangle, Rectangle)

Gets a MapArea representing the exact union of the specified rectangles, eg. a MapArea containing all locations from either rectangle.

Declaration
public static MapArea GetExactUnion(Rectangle r1, Rectangle r2)
Parameters
Type Name Description
Rectangle r1
Rectangle r2
Returns
Type Description
MapArea

A MapArea containing every position in either rectangle.

| Improve this Doc View Source

GetHashCode()

Simple hashing.

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

Hash code for rectangle.

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

GetIntersection(Rectangle, Rectangle)

Returns the rectangle that represents the intersection of the two rectangles specified, or the empty rectangle if the specified rectangles do not intersect.

Declaration
public static Rectangle GetIntersection(Rectangle r1, Rectangle r2)
Parameters
Type Name Description
Rectangle r1
Rectangle r2
Returns
Type Description
Rectangle

Rectangle representing the intersection of r1 and r2, or the empty rectangle if the two rectangles do not intersect.

| Improve this Doc View Source

GetUnion(Rectangle, Rectangle)

Gets the smallest possible rectangle that includes the entire area of both r1 and r2.

Declaration
public static Rectangle GetUnion(Rectangle r1, Rectangle r2)
Parameters
Type Name Description
Rectangle r1
Rectangle r2
Returns
Type Description
Rectangle

The smallest possible rectangle that includes the entire area of both r1 and r2.

| Improve this Doc View Source

Intersects(Rectangle)

Returns whether or not the given rectangle intersects the current one.

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

The rectangle to check.

Returns
Type Description
System.Boolean

True if the given rectangle intersects with the current one, false otherwise.

| Improve this Doc View Source

MaxXPositions()

Gets all positions that reside on the max-x line of the rectangle.

Declaration
public IEnumerable<Coord> MaxXPositions()
Returns
Type Description
System.Collections.Generic.IEnumerable<Coord>

IEnumerable of all positions that lie on the max-x line of the rectangle.

| Improve this Doc View Source

MaxYPositions()

Gets all positions that reside on the max-y line of the rectangle.

Declaration
public IEnumerable<Coord> MaxYPositions()
Returns
Type Description
System.Collections.Generic.IEnumerable<Coord>

IEnumerable of all positions that lie on the max-y line of the rectangle.

| Improve this Doc View Source

MinXPositions()

Gets all positions that reside on the min-x line of the rectangle.

Declaration
public IEnumerable<Coord> MinXPositions()
Returns
Type Description
System.Collections.Generic.IEnumerable<Coord>

IEnumerable of all positions that lie on the min-x line of the rectangle.

| Improve this Doc View Source

MinYPositions()

Gets all positions that reside on the min-y line of the rectangle.

Declaration
public IEnumerable<Coord> MinYPositions()
Returns
Type Description
System.Collections.Generic.IEnumerable<Coord>

IEnumerable of all positions that lie on the min-y line of the rectangle.

| Improve this Doc View Source

PerimeterPositions()

Gets all positions that reside on the inner perimeter of the rectangle.

Declaration
public IEnumerable<Coord> PerimeterPositions()
Returns
Type Description
System.Collections.Generic.IEnumerable<Coord>

IEnumerable of all positions that reside on the inner perimeter of the rectangle.

| Improve this Doc View Source

Positions()

Returns all positions in the rectangle.

Declaration
public IEnumerable<Coord> Positions()
Returns
Type Description
System.Collections.Generic.IEnumerable<Coord>

All positions in the rectangle.

| Improve this Doc View Source

PositionsOnSide(Direction)

Gets an IEnumerable of all positions that line on the inner perimiter of the rectangle, on the given side of the rectangle.

Declaration
public IEnumerable<Coord> PositionsOnSide(Direction side)
Parameters
Type Name Description
Direction side

Side to get positions for.

Returns
Type Description
System.Collections.Generic.IEnumerable<Coord>

IEnumerable of all positions that line on the inner perimieter of the rectangle on the given side.

| Improve this Doc View Source

RandomPosition(Func<Coord, Boolean>, IGenerator)

Returns a random position from within this rectangle, for which the selector function specified returns true. Random positions will continuously be generated until one that qualifies is found.

Declaration
public Coord RandomPosition(Func<Coord, bool> selector, IGenerator rng = null)
Parameters
Type Name Description
System.Func<Coord, System.Boolean> selector

Selector function that takes a position, and returns true if it is an acceptable selection, and false otherwise.

Troschuetz.Random.IGenerator rng

The rng to use. Defaults to DefaultRNG.

Returns
Type Description
Coord

A random position from within the rectangle, for which the given selector function returned true.

| Improve this Doc View Source

RandomPosition(Func<Rectangle, Coord, Boolean>, IGenerator)

Returns a random position from within this rectangle, for which the selector function specified returns true. Random positions will continuously be generated until one that qualifies is found.

Declaration
public Coord RandomPosition(Func<Rectangle, Coord, bool> selector, IGenerator rng = null)
Parameters
Type Name Description
System.Func<Rectangle, Coord, System.Boolean> selector

Selector function that takes a position and a rectangle, and returns true if it is an acceptable selection, and false otherwise.

Troschuetz.Random.IGenerator rng

The rng to use. Defaults to DefaultRNG.

Returns
Type Description
Coord

A random position from within the rectangle, for which the given selector function returned true.

| Improve this Doc View Source

RandomPosition(IGenerator)

Returns a random position from within this rectangle.

Declaration
public Coord RandomPosition(IGenerator rng = null)
Parameters
Type Name Description
Troschuetz.Random.IGenerator rng

The rng to use. Defaults to DefaultRNG.

Returns
Type Description
Coord

A random position from within the rectangle.

| Improve this Doc View Source

ToString()

Returns a string representing the rectangle, formatted as (X, Y) -> (MaxExtentX, MaxExtentY)

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

String formatted as above.

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

Translate(Coord)

Creates and returns a new rectangle whose position has been moved by the given delta-change values.

Declaration
public Rectangle Translate(Coord deltaChange)
Parameters
Type Name Description
Coord deltaChange

Delta-x and delta-y values by which to move the new rectangle.

Returns
Type Description
Rectangle

A new rectangle, whose position has been moved by the given delta-change values.

| Improve this Doc View Source

Translate(Direction)

Creates and returns a new rectangle that has its position moved in the given direction.

Declaration
public Rectangle Translate(Direction direction)
Parameters
Type Name Description
Direction direction

The direction to move the new rectangle in.

Returns
Type Description
Rectangle

A new rectangle that has its position moved in the given direction.

| Improve this Doc View Source

Translate(Int32, Int32)

Creates and returns a new rectangle whose position has been moved by the given delta-change values.

Declaration
public Rectangle Translate(int dx, int dy)
Parameters
Type Name Description
System.Int32 dx

Delta-x value by which to move the new rectangle.

System.Int32 dy

Delta-y value by which to move the new rectangle.

Returns
Type Description
Rectangle

A new rectangle, whose position has been moved by the given delta-change values.

| Improve this Doc View Source

TranslateX(Int32)

Creates and returns a new rectangle whose x-position has been moved by the given delta value.

Declaration
public Rectangle TranslateX(int dx)
Parameters
Type Name Description
System.Int32 dx

Value by which to move the new rectangle's x-position.

Returns
Type Description
Rectangle

A new rectangle, whose x-position has been moved by the given delta-x value.

| Improve this Doc View Source

TranslateY(Int32)

Creates and returns a new rectangle whose y-position has been moved by the given delta value.

Declaration
public Rectangle TranslateY(int dy)
Parameters
Type Name Description
System.Int32 dy

Value by which to move the new rectangle's y-position.

Returns
Type Description
Rectangle

A new rectangle, whose y-position has been moved by the given delta-y value.

| Improve this Doc View Source

WithCenter(Coord)

Creates and returns a new rectangle that is the same size as the current one, but with the center moved to the given position.

Declaration
public Rectangle WithCenter(Coord center)
Parameters
Type Name Description
Coord center

The center-point for the new rectangle.

Returns
Type Description
Rectangle

A new rectangle that is the same size as the current one, but with the center moved to the given location.

| Improve this Doc View Source

WithCenter(Int32, Int32)

Creates and returns a new rectangle that is the same size as the current one, but with the center moved to the given position.

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

X-value for the center-point of the new rectangle.

System.Int32 y

Y-value for the center-point of the new rectangle.

Returns
Type Description
Rectangle

A new rectangle that is the same size as the current one, but with the center moved to the given location.

| Improve this Doc View Source

WithExtents(Coord, Coord)

Creates a rectangle with the given minimum and maximum extents. Effectively a constructor, but with extra overloads not possible to provide in constructors alone.

Declaration
public static Rectangle WithExtents(Coord minExtent, Coord maxExtent)
Parameters
Type Name Description
Coord minExtent

Minimum (x, y) coordinates that are inside the rectangle.

Coord maxExtent

Maximum (x, y) coordinates that are inside the rectangle.

Returns
Type Description
Rectangle

A new Rectangle with the given minimum and maximum extents.

| Improve this Doc View Source

WithExtents(Int32, Int32, Int32, Int32)

Creates a rectangle with the given minimum and maximum extents. Effectively a constructor, but with extra overloads not possible to provide in constructors alone.

Declaration
public static Rectangle WithExtents(int minX, int minY, int maxX, int maxY)
Parameters
Type Name Description
System.Int32 minX

Minimum x coordinate that is inside the rectangle.

System.Int32 minY

Minimum y coordinate that is inside the rectangle.

System.Int32 maxX

Maximum x coordinate that is inside the rectangle.

System.Int32 maxY

Maximum y coordinate that is inside the rectangle.

Returns
Type Description
Rectangle

A new Rectangle with the given minimum and maximum extents.

| Improve this Doc View Source

WithHeight(Int32)

Creates and returns a new rectangle that has the same position and width as the current one, but with the height changed to the given value.

Declaration
public Rectangle WithHeight(int height)
Parameters
Type Name Description
System.Int32 height

The height for the new rectangle.

Returns
Type Description
Rectangle

A new rectangle with its height changed to the given value.

| Improve this Doc View Source

WithMaxExtent(Coord)

Creates and returns a new rectangle that has been shrunk/expanded as necessary, such that the maximum extent is the specified value.

Declaration
public Rectangle WithMaxExtent(Coord maxExtent)
Parameters
Type Name Description
Coord maxExtent

The maximum extent of the new rectangle.

Returns
Type Description
Rectangle

A new rectangle that has its maximum extent adjusted to the specified value.

| Improve this Doc View Source

WithMaxExtent(Int32, Int32)

Creates and returns a new rectangle that has been shrunk/expanded as necessary, such that the maximum extent is the specified value.

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

The x-value for the minimum extent of the new rectangle.

System.Int32 y

The y-value for the minimum extent of the new rectangle.

Returns
Type Description
Rectangle

A new rectangle that has its maximum extent adjusted to the specified value.

| Improve this Doc View Source

WithMaxExtentX(Int32)

Creates and returns a new rectangle that has been shrunk/expanded as necessary, such that the x-value of maximum extent is changed to the specified value.

Declaration
public Rectangle WithMaxExtentX(int x)
Parameters
Type Name Description
System.Int32 x

The x-coordinate for the maximum extent of the new rectangle.

Returns
Type Description
Rectangle

A new rectangle, with its MaxExtentX adjusted to the specified value.

| Improve this Doc View Source

WithMaxExtentY(Int32)

Creates and returns a new rectangle that has been shrunk/expanded as necessary, such that the y-value of maximum extent is changed to the specified value.

Declaration
public Rectangle WithMaxExtentY(int y)
Parameters
Type Name Description
System.Int32 y

The y-coordinate for the maximum extent of the new rectangle.

Returns
Type Description
Rectangle

A new rectangle, with its MaxExtentY adjusted to the specified value.

| Improve this Doc View Source

WithMinExtent(Coord)

Creates and returns a new rectangle that has been shrunk/expanded as necessary, such that the minimum extent is the specified value.

Declaration
public Rectangle WithMinExtent(Coord minExtent)
Parameters
Type Name Description
Coord minExtent

The minimum extent of the new rectangle.

Returns
Type Description
Rectangle

A new rectangle that has its minimum extent adjusted to the specified value.

| Improve this Doc View Source

WithMinExtent(Int32, Int32)

Creates and returns a new rectangle that has been shrunk/expanded as necessary, such that the minimum extent is the specified value.

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

The x-value for the minimum extent of the new rectangle.

System.Int32 y

The y-value for the minimum extent of the new rectangle.

Returns
Type Description
Rectangle

A new rectangle that has its minimum extent adjusted to the specified value.

| Improve this Doc View Source

WithMinExtentX(Int32)

Creates and returns a new rectangle that has been shrunk/expanded as necessary, such that the x-value of minimum extent is changed to the specified value.

Declaration
public Rectangle WithMinExtentX(int x)
Parameters
Type Name Description
System.Int32 x

The x-coordinate for the minimum extent of the new rectangle.

Returns
Type Description
Rectangle

A new rectangle, with its MinExtentX adjusted to the specified value.

| Improve this Doc View Source

WithMinExtentY(Int32)

Creates and returns a new rectangle that has been shrunk/expanded as necessary, such that the y-value of minimum extent is changed to the specified value.

Declaration
public Rectangle WithMinExtentY(int y)
Parameters
Type Name Description
System.Int32 y

The y-coordinate for the minimum extent of the new rectangle.

Returns
Type Description
Rectangle

A new rectangle, with its MinExtentY adjusted to the specified value.

| Improve this Doc View Source

WithPosition(Coord)

Creates and returns a new rectangle that has its Position moved to the given position.

Declaration
public Rectangle WithPosition(Coord position)
Parameters
Type Name Description
Coord position

The position for the new rectangle.

Returns
Type Description
Rectangle

A new rectangle that has its position changed to the given value.

| Improve this Doc View Source

WithPosition(Int32, Int32)

Creates and returns a new rectangle that has its position moved to the given position.

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

X-value for the position of the new rectangle.

System.Int32 y

Y-value for the position of the new rectangle.

Returns
Type Description
Rectangle

A new rectangle with the position changed to the given value.

| Improve this Doc View Source

WithPositionAndSize(Int32, Int32, Int32, Int32)

Creates a rectangle with the given position and size. Effectively a constructor, but with extra overloads not possible to provide in constructors alone.

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

Minimum x coordinate that is inside the rectangle.

System.Int32 y

Minimum y coordinate that is inside the rectangle.

System.Int32 width

Width of the rectangle.

System.Int32 height

Height of the rectangle.

Returns
Type Description
Rectangle

A new rectangle at the given position with the given width and height.

| Improve this Doc View Source

WithPostionAndSize(Coord, Coord)

Creates a rectangle with the given position and size. Effectively a constructor, but with extra overloads not possible to provide in constructors alone.

Declaration
public static Rectangle WithPostionAndSize(Coord position, Coord size)
Parameters
Type Name Description
Coord position

Minimum (x, y) values that are inside the resulting rectangle.

Coord size

The size of the rectangle, in form (width, height).

Returns
Type Description
Rectangle

A new rectangle at the given position with the given size.

| Improve this Doc View Source

WithRadius(Coord, Int32, Int32)

Creates a rectangle centered on the given position, with the given horizontal and vertical radius values. Effectively a constructor, but with extra overloads not possible to provide in constructors alone.

Declaration
public static Rectangle WithRadius(Coord center, int horizontalRadius, int verticalRadius)
Parameters
Type Name Description
Coord center

Center of the rectangle.

System.Int32 horizontalRadius

Number of units to the left and right of the center point that are included within the rectangle.

System.Int32 verticalRadius

Number of units to the top and bottom of the center point that are included within the rectangle.

Returns
Type Description
Rectangle

A new rectangle with the given center point and radius values.

| Improve this Doc View Source

WithRadius(Int32, Int32, Int32, Int32)

Creates a rectangle centered on the given position, with the given horizontal and vertical radius values. Effectively a constructor, but with extra overloads not possible to provide in constructors alone.

Declaration
public static Rectangle WithRadius(int centerX, int centerY, int horizontalRadius, int verticalRadius)
Parameters
Type Name Description
System.Int32 centerX

X-value of the center of the rectangle.

System.Int32 centerY

Y-value of the center of the rectangle.

System.Int32 horizontalRadius

Number of units to the left and right of the center point that are included within the rectangle.

System.Int32 verticalRadius

Number of units to the top and bottom of the center point that are included within the rectangle.

Returns
Type Description
Rectangle

A new rectangle with the given center point and radius values.

| Improve this Doc View Source

WithSize(Coord)

Creates and returns a new rectangle whose position is the same as the current one, but has the specified width and height.

Declaration
public Rectangle WithSize(Coord size)
Parameters
Type Name Description
Coord size

Vector (width, height) specifying the width/height of the new rectangle.

Returns
Type Description
Rectangle

A new rectangle with the given width and height.

| Improve this Doc View Source

WithSize(Int32, Int32)

Creates and returns a new rectangle whose position is the same as the current one, but has the specified width and height.

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

The width for the new rectangle.

System.Int32 height

The height for the new rectangle.

Returns
Type Description
Rectangle

A new rectangle with the given width and height.

| Improve this Doc View Source

WithWidth(Int32)

Creates and returns a new rectangle that is exactly the same as the current one, but with the width changed to the given value.

Declaration
public Rectangle WithWidth(int width)
Parameters
Type Name Description
System.Int32 width

The width for the new rectangle.

Returns
Type Description
Rectangle

A new rectangle with its Width changed to the given value.

| Improve this Doc View Source

WithX(Int32)

Creates and returns a new rectangle that has its X value moved to the given x-coordinate.

Declaration
public Rectangle WithX(int x)
Parameters
Type Name Description
System.Int32 x

The X value for the new rectangle.

Returns
Type Description
Rectangle

A new rectangle with X changed to the given value.

| Improve this Doc View Source

WithY(Int32)

Creates and returns a new rectangle that has its Y value moved to the given y-coordinate.

Declaration
public Rectangle WithY(int y)
Parameters
Type Name Description
System.Int32 y

The Y value for the new rectangle.

Returns
Type Description
Rectangle

A new rectangle with Y changed to the given value.

Operators

| Improve this Doc View Source

Equality(Rectangle, Rectangle)

Returns whether or not the rectangles have the same position and extents.

Declaration
public static bool operator ==(Rectangle r1, Rectangle r2)
Parameters
Type Name Description
Rectangle r1
Rectangle r2
Returns
Type Description
System.Boolean

true if the area of the two rectangles encompass the exact same area, false otherwise.

| Improve this Doc View Source

Equality(Rectangle, Rectangle)

True if the two rectangles represent the same area.

Declaration
public static bool operator ==(Rectangle r1, Rectangle r2)
Parameters
Type Name Description
Rectangle r1
Microsoft.Xna.Framework.Rectangle r2
Returns
Type Description
System.Boolean

True if the two rectangles are equal, false if not.

| Improve this Doc View Source

Equality(Rectangle, Rectangle)

True if the two rectangles represent the same area.

Declaration
public static bool operator ==(Rectangle r1, Rectangle r2)
Parameters
Type Name Description
Rectangle r1
System.Drawing.Rectangle r2
Returns
Type Description
System.Boolean

True if the two rectangles are equal, false if not.

| Improve this Doc View Source

Equality(Rectangle, RectangleF)

True if the two rectangles represent the same area.

Declaration
public static bool operator ==(Rectangle r1, RectangleF r2)
Parameters
Type Name Description
Rectangle r1
System.Drawing.RectangleF r2
Returns
Type Description
System.Boolean

True if the two rectangles are equal, false if not.

| Improve this Doc View Source

Equality(Rectangle, (Int32 x, Int32 y, Int32 width, Int32 height))

True if the two rectangles represent the same area.

Declaration
public static bool operator ==(Rectangle r1, (int x, int y, int width, int height) r2)
Parameters
Type Name Description
Rectangle r1
System.ValueTuple<System.Int32, System.Int32, System.Int32, System.Int32> r2
Returns
Type Description
System.Boolean

True if the two rectangles are equal, false if not.

| Improve this Doc View Source

Equality(Rectangle, Rectangle)

True if the two rectangles represent the same area.

Declaration
public static bool operator ==(Rectangle r1, Rectangle r2)
Parameters
Type Name Description
Microsoft.Xna.Framework.Rectangle r1
Rectangle r2
Returns
Type Description
System.Boolean

True if the two rectangles are equal, false if not.

| Improve this Doc View Source

Equality(Rectangle, Rectangle)

True if the two rectangles represent the same area.

Declaration
public static bool operator ==(Rectangle r1, Rectangle r2)
Parameters
Type Name Description
System.Drawing.Rectangle r1
Rectangle r2
Returns
Type Description
System.Boolean

True if the two rectangles are equal, false if not.

| Improve this Doc View Source

Equality(RectangleF, Rectangle)

True if the two rectangles represent the same area.

Declaration
public static bool operator ==(RectangleF r1, Rectangle r2)
Parameters
Type Name Description
System.Drawing.RectangleF r1
Rectangle r2
Returns
Type Description
System.Boolean

True if the two rectangles are equal, false if not.

| Improve this Doc View Source

Equality((Int32 x, Int32 y, Int32 width, Int32 height), Rectangle)

True if the two rectangles represent the same area.

Declaration
public static bool operator ==((int x, int y, int width, int height) r1, Rectangle r2)
Parameters
Type Name Description
System.ValueTuple<System.Int32, System.Int32, System.Int32, System.Int32> r1
Rectangle r2
Returns
Type Description
System.Boolean

True if the two rectangles are equal, false if not.

| Improve this Doc View Source

Implicit(Rectangle to Rectangle)

Implicitly converts a GoRogue Rectangle to an equivalent MonoGame Rectangle.

Declaration
public static implicit operator Rectangle(Rectangle rect)
Parameters
Type Name Description
Rectangle rect
Returns
Type Description
Microsoft.Xna.Framework.Rectangle
| Improve this Doc View Source

Implicit(Rectangle to Rectangle)

Implicitly converts a GoRogue Rectangle to an equivalent System.Drawing.Rectangle.

Declaration
public static implicit operator Rectangle(Rectangle rect)
Parameters
Type Name Description
Rectangle rect
Returns
Type Description
System.Drawing.Rectangle
| Improve this Doc View Source

Implicit(Rectangle to RectangleF)

Implicitly converts a GoRogue Rectangle to an equivalent System.Drawing.RectangleF.

Declaration
public static implicit operator RectangleF(Rectangle rect)
Parameters
Type Name Description
Rectangle rect
Returns
Type Description
System.Drawing.RectangleF
| Improve this Doc View Source

Implicit(Rectangle to (Int32 x, Int32 y, Int32 width, Int32 height))

Implicitly converts a GoRogue Rectangle to an equivalent tuple of 4 integers (x, y, width, height).

Declaration
public static implicit operator (int x, int y, int width, int height)(Rectangle rect)
Parameters
Type Name Description
Rectangle rect
Returns
Type Description
System.ValueTuple<System.Int32, System.Int32, System.Int32, System.Int32>
| Improve this Doc View Source

Implicit(Rectangle to Rectangle)

Implicitly converts a MonoGame Rectangle to an equivalent GoRogue Rectangle.

Declaration
public static implicit operator Rectangle(Rectangle rect)
Parameters
Type Name Description
Microsoft.Xna.Framework.Rectangle rect
Returns
Type Description
Rectangle
| Improve this Doc View Source

Implicit(Rectangle to Rectangle)

Implicitly converts a System.Drawing.Rectangle to an equivalent GoRogue Rectangle.

Declaration
public static implicit operator Rectangle(Rectangle rect)
Parameters
Type Name Description
System.Drawing.Rectangle rect
Returns
Type Description
Rectangle
| Improve this Doc View Source

Implicit((Int32 x, Int32 y, Int32 width, Int32 height) to Rectangle)

Implicitly converts a tuple of 4 integers (x, y, width, height) to an equivalent GoRogue Rectangle.

Declaration
public static implicit operator Rectangle((int x, int y, int width, int height) tuple)
Parameters
Type Name Description
System.ValueTuple<System.Int32, System.Int32, System.Int32, System.Int32> tuple
Returns
Type Description
Rectangle
| Improve this Doc View Source

Inequality(Rectangle, Rectangle)

Returns whether or not the rectangles differ in either their positions or extents.

Declaration
public static bool operator !=(Rectangle r1, Rectangle r2)
Parameters
Type Name Description
Rectangle r1
Rectangle r2
Returns
Type Description
System.Boolean

true if the rectangles do NOT encompass the same area, false otherwise.

| Improve this Doc View Source

Inequality(Rectangle, Rectangle)

True if any of the rectangles' x/y/width/height values are not equal.

Declaration
public static bool operator !=(Rectangle r1, Rectangle r2)
Parameters
Type Name Description
Rectangle r1
Microsoft.Xna.Framework.Rectangle r2
Returns
Type Description
System.Boolean

True if any of the x/y/width/height values are not equal, false if they are all equal.

| Improve this Doc View Source

Inequality(Rectangle, Rectangle)

True if any of the rectangles' x/y/width/height values are not equal.

Declaration
public static bool operator !=(Rectangle r1, Rectangle r2)
Parameters
Type Name Description
Rectangle r1
System.Drawing.Rectangle r2
Returns
Type Description
System.Boolean

True if any of the x/y/width/height values are not equal, false if they are all equal.

| Improve this Doc View Source

Inequality(Rectangle, RectangleF)

True if any of the rectangles' x/y/width/height values are not equal.

Declaration
public static bool operator !=(Rectangle r1, RectangleF r2)
Parameters
Type Name Description
Rectangle r1
System.Drawing.RectangleF r2
Returns
Type Description
System.Boolean

True if any of the x/y/width/height values are not equal, false if they are all equal.

| Improve this Doc View Source

Inequality(Rectangle, (Int32 x, Int32 y, Int32 width, Int32 height))

True if any of the rectangles' x/y/width/height values are not equal.

Declaration
public static bool operator !=(Rectangle r1, (int x, int y, int width, int height) r2)
Parameters
Type Name Description
Rectangle r1
System.ValueTuple<System.Int32, System.Int32, System.Int32, System.Int32> r2
Returns
Type Description
System.Boolean

True if any of the x/y/width/height values are not equal, false if they are all equal.

| Improve this Doc View Source

Inequality(Rectangle, Rectangle)

True if any of the rectangles' x/y/width/height values are not equal.

Declaration
public static bool operator !=(Rectangle r1, Rectangle r2)
Parameters
Type Name Description
Microsoft.Xna.Framework.Rectangle r1
Rectangle r2
Returns
Type Description
System.Boolean

True if any of the x/y/width/height values are not equal, false if they are all equal.

| Improve this Doc View Source

Inequality(Rectangle, Rectangle)

True if any of the rectangles' x/y/width/height values are not equal.

Declaration
public static bool operator !=(Rectangle r1, Rectangle r2)
Parameters
Type Name Description
System.Drawing.Rectangle r1
Rectangle r2
Returns
Type Description
System.Boolean

True if any of the x/y/width/height values are not equal, false if they are all equal.

| Improve this Doc View Source

Inequality(RectangleF, Rectangle)

True if any of the rectangles' x/y/width/height values are not equal.

Declaration
public static bool operator !=(RectangleF r1, Rectangle r2)
Parameters
Type Name Description
System.Drawing.RectangleF r1
Rectangle r2
Returns
Type Description
System.Boolean

True if any of the x/y/width/height values are not equal, false if they are all equal.

| Improve this Doc View Source

Inequality((Int32 x, Int32 y, Int32 width, Int32 height), Rectangle)

True if any of the rectangles' x/y/width/height values are not equal.

Declaration
public static bool operator !=((int x, int y, int width, int height) r1, Rectangle r2)
Parameters
Type Name Description
System.ValueTuple<System.Int32, System.Int32, System.Int32, System.Int32> r1
Rectangle r2
Returns
Type Description
System.Boolean

True if any of the x/y/width/height values are not equal, false if they are all equal.

Implements

System.IEquatable<T>
System.IEquatable<T>

Extension Methods

Utility.Yield<T>(T)
  • Improve this Doc
  • View Source
Back to top Generated by DocFX