Arcade
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Events
GameAPI.RectI Struct Reference

An axis-aligned rectangle, using signed integers for each component. More...

Public Member Functions

 RectI (Vector2I origin, Vector2I size)
 Constructs a rectangle with the given lower-left corner and size. More...
 
 RectI (int left, int bottom, int right, int top)
 Constructs a rectangle with the given left, bottom, right and top positions along their corresponding axes. More...
 
bool Intersects (RectI other)
 Returns true if this rectangle shares a non-zero intersection area with the given rectangle. More...
 
bool Intersects (Vector2I vec)
 Returns true if the given vector lies within the bounds of this rectangle, excluding the edges. More...
 
bool Touches (RectI other)
 Returns true if either the given rectangle shares an edge with this one, or if they intersect. More...
 
RectI Intersection (RectI other)
 Finds a rectangle representing the overlap between this and the given rectangle. More...
 
RectI Union (RectI other)
 Finds the smallest rectangle that surrounds both this and the given rectangle. More...
 
bool IntersectsLine (Vector2I start, Vector2I end)
 Returns true if the line between the given start and end vectors intersects with this rectangle. More...
 
bool IntersectsLine (ref Vector2I start, ref Vector2I end)
 Returns true if the line between the given start and end vectors intersects with this rectangle. If it does intersect, start and end are modified to be the start and end of the intersecting part of the line. More...
 
Vector2F Map (Vector2F vec)
 Maps a vector with each component in the range [0, 1] to a corresponding position within this rectangle. More...
 
override bool Equals (object obj)
 
bool Equals (RectI obj)
 Tests for equality with another rectangle. More...
 
bool Equals (RectF obj)
 Tests for equality with another rectangle. More...
 
override int GetHashCode ()
 
override string ToString ()
 Gets a string representing this rect in (Center, Size) format. More...
 

Static Public Member Functions

static RectI GetBounds (params Vector2I[] points)
 Returns the smallest rectangle that encloses all of the given points. More...
 
static RectI GetBounds (IEnumerable< Vector2I > points)
 Returns the smallest rectangle that encloses all of the given points. More...
 
static implicit operator RectF (RectI bounds)
 
static RectI operator& (RectI a, RectI b)
 Syntactic sugar for finding the intersection of two rectangles. More...
 
static RectI operator| (RectI a, RectI b)
 Syntactic sugar for finding the union of two rectangles. More...
 
static RectI operator+ (RectI bounds, Vector2I offset)
 Offsets the rectangle by the given amount. More...
 
static RectI operator- (RectI bounds, Vector2I offset)
 Offsets the rectangle by the negation of the given amount. More...
 
static RectI operator* (RectI bounds, int scale)
 Scales the rectangle by the given scalar. More...
 
static RectI operator* (RectI bounds, Vector2I scale)
 Scales the rectangle by the given vector. More...
 
static RectI operator/ (RectI bounds, int scale)
 Scales the rectangle by the inverse of the given scalar. More...
 
static RectI operator/ (RectI bounds, Vector2I scale)
 Scales the rectangle by the inverse of the given vector. More...
 

Public Attributes

int Left
 Horizontal position of the left-most edge. More...
 
int Bottom
 Vertical position of the lower-most edge. More...
 
int Right
 Horizontal position of the right-most edge. More...
 
int Top
 Vertical position of the upper-most edge. More...
 

Static Public Attributes

static readonly RectI Zero = new RectI(0, 0, 0, 0)
 A rectangle with zero width and height positioned at the origin. More...
 
static readonly RectI UnitSquare = new RectI(0, 0, 1, 1)
 A rectangle with unit width and height centered at (0.5, 0.5). More...
 

Properties

int Width [get, set]
 Difference between the right and left edges. Only modifies the right edge when set. More...
 
int Height [get, set]
 Difference between the top and bottom edges. Only modifies the top edge when set. More...
 
Vector2I TopLeft [get, set]
 Vector representing the top left corner. More...
 
Vector2I TopRight [get, set]
 Vector representing the top right corner. More...
 
Vector2I BottomLeft [get, set]
 Vector representing the lower left corner. More...
 
Vector2I BottomRight [get, set]
 Vector representing the lower right corner. More...
 
Vector2I Size [get, set]
 Vector representing the combined width and height. More...
 
Vector2I Center [get, set]
 Vector representing the approximate center of the rectangle. More...
 
int Area [get]
 Product of the width and height. More...
 

Detailed Description

An axis-aligned rectangle, using signed integers for each component.

Constructor & Destructor Documentation

GameAPI.RectI.RectI ( Vector2I  origin,
Vector2I  size 
)
inline

Constructs a rectangle with the given lower-left corner and size.

GameAPI.RectI.RectI ( int  left,
int  bottom,
int  right,
int  top 
)
inline

Constructs a rectangle with the given left, bottom, right and top positions along their corresponding axes.

Member Function Documentation

override bool GameAPI.RectI.Equals ( object  obj)
inline
bool GameAPI.RectI.Equals ( RectI  obj)
inline

Tests for equality with another rectangle.

bool GameAPI.RectI.Equals ( RectF  obj)
inline

Tests for equality with another rectangle.

static RectI GameAPI.RectI.GetBounds ( params Vector2I[]  points)
inlinestatic

Returns the smallest rectangle that encloses all of the given points.

Parameters
pointsCollection of points to find the bounding rectangle of.
static RectI GameAPI.RectI.GetBounds ( IEnumerable< Vector2I points)
inlinestatic

Returns the smallest rectangle that encloses all of the given points.

Parameters
pointsCollection of points to find the bounding rectangle of.
override int GameAPI.RectI.GetHashCode ( )
inline
RectI GameAPI.RectI.Intersection ( RectI  other)
inline

Finds a rectangle representing the overlap between this and the given rectangle.

bool GameAPI.RectI.Intersects ( RectI  other)
inline

Returns true if this rectangle shares a non-zero intersection area with the given rectangle.

bool GameAPI.RectI.Intersects ( Vector2I  vec)
inline

Returns true if the given vector lies within the bounds of this rectangle, excluding the edges.

bool GameAPI.RectI.IntersectsLine ( Vector2I  start,
Vector2I  end 
)
inline

Returns true if the line between the given start and end vectors intersects with this rectangle.

Parameters
startStart vector of the line.
endEnd vector of the line.
bool GameAPI.RectI.IntersectsLine ( ref Vector2I  start,
ref Vector2I  end 
)
inline

Returns true if the line between the given start and end vectors intersects with this rectangle. If it does intersect, start and end are modified to be the start and end of the intersecting part of the line.

Parameters
startStart vector of the line.
endEnd vector of the line.
Vector2F GameAPI.RectI.Map ( Vector2F  vec)
inline

Maps a vector with each component in the range [0, 1] to a corresponding position within this rectangle.

static implicit GameAPI.RectI.operator RectF ( RectI  bounds)
inlinestatic
static RectI GameAPI.RectI.operator& ( RectI  a,
RectI  b 
)
inlinestatic

Syntactic sugar for finding the intersection of two rectangles.

static RectI GameAPI.RectI.operator* ( RectI  bounds,
int  scale 
)
inlinestatic

Scales the rectangle by the given scalar.

static RectI GameAPI.RectI.operator* ( RectI  bounds,
Vector2I  scale 
)
inlinestatic

Scales the rectangle by the given vector.

static RectI GameAPI.RectI.operator+ ( RectI  bounds,
Vector2I  offset 
)
inlinestatic

Offsets the rectangle by the given amount.

static RectI GameAPI.RectI.operator- ( RectI  bounds,
Vector2I  offset 
)
inlinestatic

Offsets the rectangle by the negation of the given amount.

static RectI GameAPI.RectI.operator/ ( RectI  bounds,
int  scale 
)
inlinestatic

Scales the rectangle by the inverse of the given scalar.

static RectI GameAPI.RectI.operator/ ( RectI  bounds,
Vector2I  scale 
)
inlinestatic

Scales the rectangle by the inverse of the given vector.

static RectI GameAPI.RectI.operator| ( RectI  a,
RectI  b 
)
inlinestatic

Syntactic sugar for finding the union of two rectangles.

override string GameAPI.RectI.ToString ( )
inline

Gets a string representing this rect in (Center, Size) format.

bool GameAPI.RectI.Touches ( RectI  other)
inline

Returns true if either the given rectangle shares an edge with this one, or if they intersect.

RectI GameAPI.RectI.Union ( RectI  other)
inline

Finds the smallest rectangle that surrounds both this and the given rectangle.

Member Data Documentation

int GameAPI.RectI.Bottom

Vertical position of the lower-most edge.

int GameAPI.RectI.Left

Horizontal position of the left-most edge.

int GameAPI.RectI.Right

Horizontal position of the right-most edge.

int GameAPI.RectI.Top

Vertical position of the upper-most edge.

readonly RectI GameAPI.RectI.UnitSquare = new RectI(0, 0, 1, 1)
static

A rectangle with unit width and height centered at (0.5, 0.5).

readonly RectI GameAPI.RectI.Zero = new RectI(0, 0, 0, 0)
static

A rectangle with zero width and height positioned at the origin.

Property Documentation

int GameAPI.RectI.Area
get

Product of the width and height.

Vector2I GameAPI.RectI.BottomLeft
getset

Vector representing the lower left corner.

Vector2I GameAPI.RectI.BottomRight
getset

Vector representing the lower right corner.

Vector2I GameAPI.RectI.Center
getset

Vector representing the approximate center of the rectangle.

int GameAPI.RectI.Height
getset

Difference between the top and bottom edges. Only modifies the top edge when set.

Vector2I GameAPI.RectI.Size
getset

Vector representing the combined width and height.

Vector2I GameAPI.RectI.TopLeft
getset

Vector representing the top left corner.

Vector2I GameAPI.RectI.TopRight
getset

Vector representing the top right corner.

int GameAPI.RectI.Width
getset

Difference between the right and left edges. Only modifies the right edge when set.