GearBlocks
The GearBlocks Lua scripting API
Public Member Functions | Static Public Member Functions | Properties | List of all members
SmashHammer.Scripting.RectProxy Struct Reference

A 2D rectangle. More...

Public Member Functions

 RectProxy (float x, float y, float width, float height)
 Constructor.
 
 RectProxy (Vector2Proxy position, Vector2Proxy size)
 Constructor.
 
void Set (float x, float y, float width, float height)
 Set the components of the rect.
 
bool Contains (Vector2Proxy point)
 Test if a point lies within the rect.
 
bool Contains (Vector3Proxy point)
 Test if a point lies within the rect.
 
bool Overlaps (RectProxy rect)
 Test if another rect overlaps this one.
 

Static Public Member Functions

static RectProxy MinMaxRect (float xMin, float yMin, float xMax, float yMax)
 Create a rect from min / max coordinate values.
 
static bool operator== (RectProxy lhs, RectProxy rhs)
 Compare two rects.
 
static bool operator!= (RectProxy lhs, RectProxy rhs)
 Compare two rects.
 

Properties

float X [get, set]
 The rect's x coordinate.
 
float Y [get, set]
 The rect's y coordinate.
 
float Width [get, set]
 The rect's width.
 
float Height [get, set]
 The rect's height.
 
Vector2Proxy Position [get, set]
 The rect's position.
 
Vector2Proxy Center [get, set]
 The rect's centre.
 
Vector2Proxy Min [get, set]
 The rect's minimum corner.
 
Vector2Proxy Max [get, set]
 The rect's maximum corner.
 
Vector2Proxy Size [get, set]
 The rect's size.
 
float XMin [get, set]
 The rect's min x coordinate.
 
float YMin [get, set]
 The rect's min y coordinate.
 
float XMax [get, set]
 The rect's max x coordinate.
 
float YMax [get, set]
 The rect's max y coordinate.
 
static RectProxy Zero [get]
 A zero sized rect.
 

Detailed Description

A 2D rectangle.

Static methods available in Lua via the "Rect" global, for example:

local rect = Rect.__new( 0, 0, 10, 10 )

Constructor & Destructor Documentation

◆ RectProxy() [1/2]

SmashHammer.Scripting.RectProxy.RectProxy ( float  x,
float  y,
float  width,
float  height 
)

Constructor.

Parameters
xThe x coordinate to initialise with.
yThe y coordinate to initialise with.
widthThe width to initialise with.
heightThe height to initialise with.

◆ RectProxy() [2/2]

SmashHammer.Scripting.RectProxy.RectProxy ( Vector2Proxy  position,
Vector2Proxy  size 
)

Constructor.

Parameters
positionThe position to initialise with.
sizeThe size to initialise with.

Member Function Documentation

◆ MinMaxRect()

static RectProxy SmashHammer.Scripting.RectProxy.MinMaxRect ( float  xMin,
float  yMin,
float  xMax,
float  yMax 
)
static

Create a rect from min / max coordinate values.

Parameters
xMinThe minimum x coordinate.
yMinThe minimum y coordinate.
xMaxThe maximum x coordinate.
yMaxThe maximum y coordinate.
Returns
The new rect.

◆ Set()

void SmashHammer.Scripting.RectProxy.Set ( float  x,
float  y,
float  width,
float  height 
)

Set the components of the rect.

Parameters
xThe x coordinate of the rect.
yThe y coordinate of the rect.
widthThe width of the rect.
heightThe height of the rect.

◆ Contains() [1/2]

bool SmashHammer.Scripting.RectProxy.Contains ( Vector2Proxy  point)

Test if a point lies within the rect.

Parameters
pointThe point to test.
Returns
true if the rect contains the point; otherwise, false.

◆ Contains() [2/2]

bool SmashHammer.Scripting.RectProxy.Contains ( Vector3Proxy  point)

Test if a point lies within the rect.

Parameters
pointThe point to test.
Returns
true if the rect contains the point; otherwise, false.

◆ Overlaps()

bool SmashHammer.Scripting.RectProxy.Overlaps ( RectProxy  rect)

Test if another rect overlaps this one.

Parameters
rectThe rect to test.
Returns
true if the rects overlap; otherwise, false.

◆ operator==()

static bool SmashHammer.Scripting.RectProxy.operator== ( RectProxy  lhs,
RectProxy  rhs 
)
static

Compare two rects.

Parameters
lhsThe first rect.
rhsThe second rect.
Returns
true if the rects are equal; otherwise, false.

◆ operator!=()

static bool SmashHammer.Scripting.RectProxy.operator!= ( RectProxy  lhs,
RectProxy  rhs 
)
static

Compare two rects.

Parameters
lhsThe first rect.
rhsThe second rect.
Returns
true if the rects are not equal; otherwise, false.

Property Documentation

◆ X

float SmashHammer.Scripting.RectProxy.X
getset

The rect's x coordinate.

The x coordinate of this rect.

◆ Y

float SmashHammer.Scripting.RectProxy.Y
getset

The rect's y coordinate.

The y coordinate of this rect.

◆ Width

float SmashHammer.Scripting.RectProxy.Width
getset

The rect's width.

The width of this rect.

◆ Height

float SmashHammer.Scripting.RectProxy.Height
getset

The rect's height.

The height of this rect.

◆ Position

Vector2Proxy SmashHammer.Scripting.RectProxy.Position
getset

The rect's position.

The position of this rect.

◆ Center

Vector2Proxy SmashHammer.Scripting.RectProxy.Center
getset

The rect's centre.

The centre of this rect.

◆ Min

Vector2Proxy SmashHammer.Scripting.RectProxy.Min
getset

The rect's minimum corner.

The minimum corner of this rect.

◆ Max

Vector2Proxy SmashHammer.Scripting.RectProxy.Max
getset

The rect's maximum corner.

The maximum corner of this rect.

◆ Size

Vector2Proxy SmashHammer.Scripting.RectProxy.Size
getset

The rect's size.

The width and height of this rect.

◆ XMin

float SmashHammer.Scripting.RectProxy.XMin
getset

The rect's min x coordinate.

The minimum x coordinate of this rect.

◆ YMin

float SmashHammer.Scripting.RectProxy.YMin
getset

The rect's min y coordinate.

The minimum y coordinate of this rect.

◆ XMax

float SmashHammer.Scripting.RectProxy.XMax
getset

The rect's max x coordinate.

The maximum x coordinate of this rect.

◆ YMax

float SmashHammer.Scripting.RectProxy.YMax
getset

The rect's max y coordinate.

The maximum y coordinate of this rect.

◆ Zero

RectProxy SmashHammer.Scripting.RectProxy.Zero
staticget

A zero sized rect.

A new rect with all components initialised to zero.