A* Pathfinding Project  4.1.19
The A* Pathfinding Project for Unity 3D
IntRect Struct Reference

Integer Rectangle. More...

Detailed Description

Integer Rectangle.

Works almost like UnityEngine.Rect but with integer coordinates

Public Member Functions

 IntRect (int xmin, int ymin, int xmax, int ymax)
 
bool Contains (int x, int y)
 
void DebugDraw (GraphTransform transform, Color color)
 Draws some debug lines representing the rect. More...
 
override bool Equals (System.Object obj)
 
IntRect Expand (int range)
 Returns a new rect which is expanded by range in all directions. More...
 
IntRect ExpandToContain (int x, int y)
 Returns a new IntRect which is expanded to contain the point. More...
 
override int GetHashCode ()
 
bool IsValid ()
 Returns if this rectangle is valid. More...
 
IntRect Offset (Int2 offset)
 Returns a new rect which is offset by the specified amount. More...
 
IntRect Offset (int x, int y)
 Returns a new rect which is offset by the specified amount. More...
 
IntRect Rotate (int r)
 Returns a new rect rotated around the origin 90*r degrees. More...
 
override string ToString ()
 

Static Public Member Functions

static IntRect Intersection (IntRect a, IntRect b)
 Returns the intersection rect between the two rects. More...
 
static bool Intersects (IntRect a, IntRect b)
 Returns if the two rectangles intersect each other. More...
 
static bool operator!= (IntRect a, IntRect b)
 
static bool operator== (IntRect a, IntRect b)
 
static IntRect Union (IntRect a, IntRect b)
 Returns a new rect which contains both input rects. More...
 

Public Attributes

int xmax
 
int xmin
 
int ymax
 
int ymin
 

Properties

int Height [get]
 
int Width [get]
 

Static Private Attributes

static readonly int [] Rotations
 Matrices for rotation. More...
 

Constructor & Destructor Documentation

◆ IntRect()

IntRect ( int  xmin,
int  ymin,
int  xmax,
int  ymax 
)

Member Function Documentation

◆ Contains()

bool Contains ( int  x,
int  y 
)

◆ DebugDraw()

void DebugDraw ( GraphTransform  transform,
Color  color 
)

Draws some debug lines representing the rect.

◆ Equals()

override bool Equals ( System.Object  obj)

◆ Expand()

IntRect Expand ( int  range)

Returns a new rect which is expanded by range in all directions.

Parameters
rangeHow far to expand. Negative values are permitted.

◆ ExpandToContain()

IntRect ExpandToContain ( int  x,
int  y 
)

Returns a new IntRect which is expanded to contain the point.

◆ GetHashCode()

override int GetHashCode ( )

◆ Intersection()

static IntRect Intersection ( IntRect  a,
IntRect  b 
)
static

Returns the intersection rect between the two rects.

The intersection rect is the area which is inside both rects. If the rects do not have an intersection, an invalid rect is returned.

See also
IsValid

◆ Intersects()

static bool Intersects ( IntRect  a,
IntRect  b 
)
static

Returns if the two rectangles intersect each other.

◆ IsValid()

bool IsValid ( )

Returns if this rectangle is valid.

An invalid rect could have e.g xmin > xmax. Rectamgles with a zero area area invalid.

◆ Offset() [1/2]

IntRect Offset ( Int2  offset)

Returns a new rect which is offset by the specified amount.

◆ Offset() [2/2]

IntRect Offset ( int  x,
int  y 
)

Returns a new rect which is offset by the specified amount.

◆ operator!=()

static bool operator!= ( IntRect  a,
IntRect  b 
)
static

◆ operator==()

static bool operator== ( IntRect  a,
IntRect  b 
)
static

◆ Rotate()

IntRect Rotate ( int  r)

Returns a new rect rotated around the origin 90*r degrees.

Ensures that a valid rect is returned.

◆ ToString()

override string ToString ( )

◆ Union()

static IntRect Union ( IntRect  a,
IntRect  b 
)
static

Returns a new rect which contains both input rects.

This rectangle may contain areas outside both input rects as well in some cases.

Member Data Documentation

◆ Rotations

readonly int [] Rotations
staticprivate
Initial value:
= {
1, 0,
0, 1,
0, 1,
-1, 0,
-1, 0,
0, -1,
0, -1,
1, 0
}

Matrices for rotation.

Each group of 4 elements is a 2x2 matrix. The XZ position is multiplied by this. So

//A rotation by 90 degrees clockwise, second matrix in the array
(5,2) * ((0, 1), (-1, 0)) = (2,-5)

◆ xmax

int xmax

◆ xmin

int xmin

◆ ymax

int ymax

◆ ymin

int ymin

Property Documentation

◆ Height

int Height
get

◆ Width

int Width
get

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