Nebula
Loading...
Searching...
No Matches
Mathf.Rectangle Struct Reference

Detailed Description

Describes a 2D-rectangle.

Inherits IEquatable< Rectangle >.

Public Member Functions

 Rectangle (int x, int y, int width, int height)
 Creates a new instance of Rectangle struct, with the specified position, width, and height.
 
 Rectangle (Point location, Point size)
 Creates a new instance of Rectangle struct, with the specified location and size.
 
bool Contains (int x, int y)
 Gets whether or not the provided coordinates lie within the bounds of this Rectangle.
 
bool Contains (float x, float y)
 Gets whether or not the provided coordinates lie within the bounds of this Rectangle.
 
bool Contains (Point value)
 Gets whether or not the provided Point lies within the bounds of this Rectangle.
 
void Contains (ref Point value, out bool result)
 Gets whether or not the provided Point lies within the bounds of this Rectangle.
 
bool Contains (Vector2 value)
 Gets whether or not the provided Vector2 lies within the bounds of this Rectangle.
 
void Contains (ref Vector2 value, out bool result)
 Gets whether or not the provided Vector2 lies within the bounds of this Rectangle.
 
bool Contains (Rectangle value)
 Gets whether or not the provided Rectangle lies within the bounds of this Rectangle.
 
void Contains (ref Rectangle value, out bool result)
 Gets whether or not the provided Rectangle lies within the bounds of this Rectangle.
 
override bool Equals (object obj)
 Compares whether current instance is equal to specified Object.
 
bool Equals (Rectangle other)
 Compares whether current instance is equal to specified Rectangle.
 
override int GetHashCode ()
 Gets the hash code of this Rectangle.
 
void Inflate (int horizontalAmount, int verticalAmount)
 Adjusts the edges of this Rectangle by specified horizontal and vertical amounts.
 
void Inflate (float horizontalAmount, float verticalAmount)
 Adjusts the edges of this Rectangle by specified horizontal and vertical amounts.
 
bool Intersects (Rectangle value)
 Gets whether or not the other Rectangle intersects with this rectangle.
 
void Intersects (ref Rectangle value, out bool result)
 Gets whether or not the other Rectangle intersects with this rectangle.
 
void Offset (int offsetX, int offsetY)
 Changes the Location of this Rectangle.
 
void Offset (float offsetX, float offsetY)
 Changes the Location of this Rectangle.
 
void Offset (Point amount)
 Changes the Location of this Rectangle.
 
void Offset (Vector2 amount)
 Changes the Location of this Rectangle.
 
override string ToString ()
 Returns a String representation of this Rectangle in the format: {X:[X] Y:[Y] Width:[Width] Height:[Height]}.
 
void Deconstruct (out int x, out int y, out int width, out int height)
 Deconstruction method for Rectangle.
 

Static Public Member Functions

static bool operator== (Rectangle a, Rectangle b)
 Compares whether two Rectangle instances are equal.
 
static bool operator!= (Rectangle a, Rectangle b)
 Compares whether two Rectangle instances are not equal.
 
static Rectangle Intersect (Rectangle value1, Rectangle value2)
 Creates a new Rectangle that contains overlapping region of two other rectangles.
 
static void Intersect (ref Rectangle value1, ref Rectangle value2, out Rectangle result)
 Creates a new Rectangle that contains overlapping region of two other rectangles.
 
static Rectangle Union (Rectangle value1, Rectangle value2)
 Creates a new Rectangle that completely contains two other rectangles.
 
static void Union (ref Rectangle value1, ref Rectangle value2, out Rectangle result)
 Creates a new Rectangle that completely contains two other rectangles.
 

Public Attributes

int X
 The x coordinate of the top-left corner of this Rectangle.
 
int Y
 The y coordinate of the top-left corner of this Rectangle.
 
int Width
 The width of this Rectangle.
 
int Height
 The height of this Rectangle.
 

Properties

static Rectangle Empty [get]
 Returns a Rectangle with X=0, Y=0, Width=0, Height=0.
 
int Left [get]
 Returns the x coordinate of the left edge of this Rectangle.
 
int Right [get]
 Returns the x coordinate of the right edge of this Rectangle.
 
int Top [get]
 Returns the y coordinate of the top edge of this Rectangle.
 
int Bottom [get]
 Returns the y coordinate of the bottom edge of this Rectangle.
 
bool IsEmpty [get]
 Whether or not this Rectangle has a Width and Height of 0, and a Location of (0, 0).
 
Point Location [get, set]
 The top-left coordinates of this Rectangle.
 
Point Size [get, set]
 The width-height coordinates of this Rectangle.
 
Point Center [get]
 A Point located in the center of this Rectangle.
 
string DebugDisplayString [get]
 

Static Private Attributes

static Rectangle emptyRectangle = new Rectangle()
 

Constructor & Destructor Documentation

◆ Rectangle() [1/2]

Mathf.Rectangle.Rectangle ( int x,
int y,
int width,
int height )
inline

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

Parameters
xThe x coordinate of the top-left corner of the created Rectangle.
yThe y coordinate of the top-left corner of the created Rectangle.
widthThe width of the created Rectangle.
heightThe height of the created Rectangle.

◆ Rectangle() [2/2]

Mathf.Rectangle.Rectangle ( Point location,
Point size )
inline

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

Parameters
locationThe x and y coordinates of the top-left corner of the created Rectangle.
sizeThe width and height of the created Rectangle.

Member Function Documentation

◆ Contains() [1/8]

bool Mathf.Rectangle.Contains ( float x,
float y )
inline

Gets whether or not the provided coordinates lie within the bounds of this Rectangle.

Parameters
xThe x coordinate of the point to check for containment.
yThe y coordinate of the point to check for containment.
Returns
true if the provided coordinates lie inside this Rectangle; false otherwise.

◆ Contains() [2/8]

bool Mathf.Rectangle.Contains ( int x,
int y )
inline

Gets whether or not the provided coordinates lie within the bounds of this Rectangle.

Parameters
xThe x coordinate of the point to check for containment.
yThe y coordinate of the point to check for containment.
Returns
true if the provided coordinates lie inside this Rectangle; false otherwise.

◆ Contains() [3/8]

bool Mathf.Rectangle.Contains ( Point value)
inline

Gets whether or not the provided Point lies within the bounds of this Rectangle.

Parameters
valueThe coordinates to check for inclusion in this Rectangle.
Returns
true if the provided Point lies inside this Rectangle; false otherwise.

◆ Contains() [4/8]

bool Mathf.Rectangle.Contains ( Rectangle value)
inline

Gets whether or not the provided Rectangle lies within the bounds of this Rectangle.

Parameters
valueThe Rectangle to check for inclusion in this Rectangle.
Returns
true if the provided Rectangle's bounds lie entirely inside this Rectangle; false otherwise.

◆ Contains() [5/8]

void Mathf.Rectangle.Contains ( ref Point value,
out bool result )
inline

Gets whether or not the provided Point lies within the bounds of this Rectangle.

Parameters
valueThe coordinates to check for inclusion in this Rectangle.
resulttrue if the provided Point lies inside this Rectangle; false otherwise. As an output parameter.

◆ Contains() [6/8]

void Mathf.Rectangle.Contains ( ref Rectangle value,
out bool result )
inline

Gets whether or not the provided Rectangle lies within the bounds of this Rectangle.

Parameters
valueThe Rectangle to check for inclusion in this Rectangle.
resulttrue if the provided Rectangle's bounds lie entirely inside this Rectangle; false otherwise. As an output parameter.

◆ Contains() [7/8]

void Mathf.Rectangle.Contains ( ref Vector2 value,
out bool result )
inline

Gets whether or not the provided Vector2 lies within the bounds of this Rectangle.

Parameters
valueThe coordinates to check for inclusion in this Rectangle.
resulttrue if the provided Vector2 lies inside this Rectangle; false otherwise. As an output parameter.

◆ Contains() [8/8]

bool Mathf.Rectangle.Contains ( Vector2 value)
inline

Gets whether or not the provided Vector2 lies within the bounds of this Rectangle.

Parameters
valueThe coordinates to check for inclusion in this Rectangle.
Returns
true if the provided Vector2 lies inside this Rectangle; false otherwise.

◆ Deconstruct()

void Mathf.Rectangle.Deconstruct ( out int x,
out int y,
out int width,
out int height )
inline

Deconstruction method for Rectangle.

Parameters
x
y
width
height

◆ Equals() [1/2]

override bool Mathf.Rectangle.Equals ( object obj)
inline

Compares whether current instance is equal to specified Object.

Parameters
objThe Object to compare.
Returns
true if the instances are equal; false otherwise.

◆ Equals() [2/2]

bool Mathf.Rectangle.Equals ( Rectangle other)
inline

Compares whether current instance is equal to specified Rectangle.

Parameters
otherThe Rectangle to compare.
Returns
true if the instances are equal; false otherwise.

◆ GetHashCode()

override int Mathf.Rectangle.GetHashCode ( )
inline

Gets the hash code of this Rectangle.

Returns
Hash code of this Rectangle.

◆ Inflate() [1/2]

void Mathf.Rectangle.Inflate ( float horizontalAmount,
float verticalAmount )
inline

Adjusts the edges of this Rectangle by specified horizontal and vertical amounts.

Parameters
horizontalAmountValue to adjust the left and right edges.
verticalAmountValue to adjust the top and bottom edges.

◆ Inflate() [2/2]

void Mathf.Rectangle.Inflate ( int horizontalAmount,
int verticalAmount )
inline

Adjusts the edges of this Rectangle by specified horizontal and vertical amounts.

Parameters
horizontalAmountValue to adjust the left and right edges.
verticalAmountValue to adjust the top and bottom edges.

◆ Intersect() [1/2]

static Rectangle Mathf.Rectangle.Intersect ( Rectangle value1,
Rectangle value2 )
inlinestatic

Creates a new Rectangle that contains overlapping region of two other rectangles.

Parameters
value1The first Rectangle.
value2The second Rectangle.
Returns
Overlapping region of the two rectangles.

◆ Intersect() [2/2]

static void Mathf.Rectangle.Intersect ( ref Rectangle value1,
ref Rectangle value2,
out Rectangle result )
inlinestatic

Creates a new Rectangle that contains overlapping region of two other rectangles.

Parameters
value1The first Rectangle.
value2The second Rectangle.
resultOverlapping region of the two rectangles as an output parameter.

◆ Intersects() [1/2]

bool Mathf.Rectangle.Intersects ( Rectangle value)
inline

Gets whether or not the other Rectangle intersects with this rectangle.

Parameters
valueThe other rectangle for testing.
Returns
true if other Rectangle intersects with this rectangle; false otherwise.

◆ Intersects() [2/2]

void Mathf.Rectangle.Intersects ( ref Rectangle value,
out bool result )
inline

Gets whether or not the other Rectangle intersects with this rectangle.

Parameters
valueThe other rectangle for testing.
resulttrue if other Rectangle intersects with this rectangle; false otherwise. As an output parameter.

◆ Offset() [1/4]

void Mathf.Rectangle.Offset ( float offsetX,
float offsetY )
inline

Changes the Location of this Rectangle.

Parameters
offsetXThe x coordinate to add to this Rectangle.
offsetYThe y coordinate to add to this Rectangle.

◆ Offset() [2/4]

void Mathf.Rectangle.Offset ( int offsetX,
int offsetY )
inline

Changes the Location of this Rectangle.

Parameters
offsetXThe x coordinate to add to this Rectangle.
offsetYThe y coordinate to add to this Rectangle.

◆ Offset() [3/4]

void Mathf.Rectangle.Offset ( Point amount)
inline

Changes the Location of this Rectangle.

Parameters
amountThe x and y components to add to this Rectangle.

◆ Offset() [4/4]

void Mathf.Rectangle.Offset ( Vector2 amount)
inline

Changes the Location of this Rectangle.

Parameters
amountThe x and y components to add to this Rectangle.

◆ operator!=()

static bool Mathf.Rectangle.operator!= ( Rectangle a,
Rectangle b )
inlinestatic

Compares whether two Rectangle instances are not equal.

Parameters
aRectangle instance on the left of the not equal sign.
bRectangle instance on the right of the not equal sign.
Returns
true if the instances are not equal; false otherwise.

◆ operator==()

static bool Mathf.Rectangle.operator== ( Rectangle a,
Rectangle b )
inlinestatic

Compares whether two Rectangle instances are equal.

Parameters
aRectangle instance on the left of the equal sign.
bRectangle instance on the right of the equal sign.
Returns
true if the instances are equal; false otherwise.

◆ ToString()

override string Mathf.Rectangle.ToString ( )
inline

Returns a String representation of this Rectangle in the format: {X:[X] Y:[Y] Width:[Width] Height:[Height]}.

Returns
String representation of this Rectangle.

◆ Union() [1/2]

static Rectangle Mathf.Rectangle.Union ( Rectangle value1,
Rectangle value2 )
inlinestatic

Creates a new Rectangle that completely contains two other rectangles.

Parameters
value1The first Rectangle.
value2The second Rectangle.
Returns
The union of the two rectangles.

◆ Union() [2/2]

static void Mathf.Rectangle.Union ( ref Rectangle value1,
ref Rectangle value2,
out Rectangle result )
inlinestatic

Creates a new Rectangle that completely contains two other rectangles.

Parameters
value1The first Rectangle.
value2The second Rectangle.
resultThe union of the two rectangles as an output parameter.

Member Data Documentation

◆ emptyRectangle

Rectangle Mathf.Rectangle.emptyRectangle = new Rectangle()
staticprivate

◆ Height

int Mathf.Rectangle.Height

The height of this Rectangle.

◆ Width

int Mathf.Rectangle.Width

The width of this Rectangle.

◆ X

int Mathf.Rectangle.X

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

◆ Y

int Mathf.Rectangle.Y

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

Property Documentation

◆ Bottom

int Mathf.Rectangle.Bottom
get

Returns the y coordinate of the bottom edge of this Rectangle.

◆ Center

Point Mathf.Rectangle.Center
get

A Point located in the center of this Rectangle.

If Width or Height is an odd number, the center point will be rounded down.

◆ DebugDisplayString

string Mathf.Rectangle.DebugDisplayString
getpackage

◆ Empty

Rectangle Mathf.Rectangle.Empty
staticget

Returns a Rectangle with X=0, Y=0, Width=0, Height=0.

◆ IsEmpty

bool Mathf.Rectangle.IsEmpty
get

Whether or not this Rectangle has a Width and Height of 0, and a Location of (0, 0).

◆ Left

int Mathf.Rectangle.Left
get

Returns the x coordinate of the left edge of this Rectangle.

◆ Location

Point Mathf.Rectangle.Location
getset

The top-left coordinates of this Rectangle.

◆ Right

int Mathf.Rectangle.Right
get

Returns the x coordinate of the right edge of this Rectangle.

◆ Size

Point Mathf.Rectangle.Size
getset

The width-height coordinates of this Rectangle.

◆ Top

int Mathf.Rectangle.Top
get

Returns the y coordinate of the top edge of this Rectangle.


The documentation for this struct was generated from the following file: