Sinespace Client  2023.2.17543
Client-side scripting for Sinespace
SineSpace.Scripting.Types.SRect Struct Reference

Implements a 2D Rectangle class More...

Inheritance diagram for SineSpace.Scripting.Types.SRect:

Public Member Functions

bool Contains (SVector point)
 Returns true if the x and y components of point is a point inside this rectangle.If allowInverse is present and true , the width and height of the Rect are allowedto take negative values (ie, the min value is greater than the max), and thetest will still work. More...
 
bool Contains (SVector point, bool allowInverse)
 Returns true if the x and y components of point is a point inside this rectangle.If allowInverse is present and true , the width and height of the Rect are allowedto take negative values (ie, the min value is greater than the max), and thetest will still work. More...
 
bool Overlaps (SRect other)
 Returns true if the other rectangle overlaps this one. If allowInverse is present and true, the widths and heights of the Rects are allowed to take negative values (ie, the min value is greater than the max), and the test will still work. More...
 
bool Overlaps (SRect other, bool allowInverse)
 Returns true if the other rectangle overlaps this one. If allowInverse is present and true, the widths and heights of the Rects are allowed to take negative values (ie, the min value is greater than the max), and the test will still work. More...
 
bool Equals (Rect other)
 
string ToString (string format)
 Returns a nicely formatted string for this Rect. More...
 
 SRect (float x, float y, float width, float height)
 
bool Equals (SRect other)
 Returns true if the rect is same as other. More...
 
override string ToString ()
 Returns string for this Rect. More...
 

Static Public Member Functions

static SRect New (float x, float y, float width, float height)
 Constructs a new SRect (for easier Lua Access) More...
 

Public Attributes

float X
 Axis parameters More...
 
float Y
 
float Width
 
float Height
 

Properties

SVector Position [get]
 The X and Y position of the rectangle. More...
 
SVector Center [get]
 The position of the center of the rectangle. More...
 
SVector Min [get]
 The position of the minimum corner of the rectangle. More...
 
SVector Max [get]
 The position of the maximum corner of the rectangle. More...
 
SVector Size [get]
 The width and height of the rectangle. More...
 
float XMin [get]
 The minimum X coordinate of the rectangle. More...
 
float YMin [get]
 The minimum Y coordinate of the rectangle. More...
 
float XMax [get]
 The maximum X coordinate of the rectangle. More...
 
float YMax [get]
 The maximum Y coordinate of the rectangle. More...
 
float Left [get]
 
float Right [get]
 
float Top [get]
 
float Bottom [get]
 

Detailed Description

Implements a 2D Rectangle class

Constructor & Destructor Documentation

◆ SRect()

SineSpace.Scripting.Types.SRect.SRect ( float  x,
float  y,
float  width,
float  height 
)

Member Function Documentation

◆ Contains() [1/2]

bool SineSpace.Scripting.Types.SRect.Contains ( SVector  point)

Returns true if the x and y components of point is a point inside this rectangle.If allowInverse is present and true , the width and height of the Rect are allowedto take negative values (ie, the min value is greater than the max), and thetest will still work.

Parameters
pointPoint to test.
local newRect=Rect.New(0,0,-150,-150)
if newRect.Contains(Vector.New(-70,0,0))then
Space.Log("Contains")
else
Space.Log("NOT")
end
–Print "NOT"

◆ Contains() [2/2]

bool SineSpace.Scripting.Types.SRect.Contains ( SVector  point,
bool  allowInverse 
)

Returns true if the x and y components of point is a point inside this rectangle.If allowInverse is present and true , the width and height of the Rect are allowedto take negative values (ie, the min value is greater than the max), and thetest will still work.

Parameters
pointPoint to test.
allowInverseDoes the test allow the Rect's width and height to be negative?
local newRect=Rect.New(0,0,-150,-150)
if newRect.Contains(Vector.New(-70,0,0),true)then
Space.Log("Contains")
else
Space.Log("NOT")
end
–Print "Contains"

◆ Equals() [1/2]

bool SineSpace.Scripting.Types.SRect.Equals ( Rect  other)

◆ Equals() [2/2]

bool SineSpace.Scripting.Types.SRect.Equals ( SRect  other)

Returns true if the rect is same as other.

Parameters
otherOther rect.
local newRect=Rect.New(0,0,150,150)
local otherRect=Rect.New(50,50,150,150)
Space.Log(newRect.Equals(otherRect))
–Print "true"

◆ New()

static SRect SineSpace.Scripting.Types.SRect.New ( float  x,
float  y,
float  width,
float  height 
)
static

Constructs a new SRect (for easier Lua Access)

Parameters
xThe X value the rect is measured from.
yThe Y value the rect is measured from.
widthThe width of the rectangle.
heightThe height of the rectangle.
local newRect=Rect.New(0,0,150,150)

◆ Overlaps() [1/2]

bool SineSpace.Scripting.Types.SRect.Overlaps ( SRect  other)

Returns true if the other rectangle overlaps this one. If allowInverse is present and true, the widths and heights of the Rects are allowed to take negative values (ie, the min value is greater than the max), and the test will still work.

Parameters
otherOther rectangle to test overlapping with.
local newRect=Rect.New(0,0,-150,-150)
local otherRect=Rect.New(0,0,-100,-100)
if newRect.Overlaps(otherRect)then
Space.Log("Overlaps")
else
Space.Log("NOT")
end
–Print "NOT"

◆ Overlaps() [2/2]

bool SineSpace.Scripting.Types.SRect.Overlaps ( SRect  other,
bool  allowInverse 
)

Returns true if the other rectangle overlaps this one. If allowInverse is present and true, the widths and heights of the Rects are allowed to take negative values (ie, the min value is greater than the max), and the test will still work.

Parameters
otherOther rectangle to test overlapping with.
allowInverseDoes the test allow the Rect's width and height to be negative?
local newRect=Rect.New(0,0,-150,-150)
local otherRect=Rect.New(0,0,-100,-100)
if newRect.Overlaps(otherRect,true)then
Space.Log("Overlaps")
else
Space.Log("NOT")
end
–Print "Overlaps"

◆ ToString() [1/2]

override string SineSpace.Scripting.Types.SRect.ToString ( )

Returns string for this Rect.

Parameters
formatOther rectangle to test overlapping with.
local newRect=Rect.New(0,0,150,150)
Space.Log(newRect.ToString())
–Print "[50, 50, 150, 150]"

◆ ToString() [2/2]

string SineSpace.Scripting.Types.SRect.ToString ( string  format)

Returns a nicely formatted string for this Rect.

Parameters
formatOther rectangle to test overlapping with.
local newRect=Rect.New(0,0,150,150)
Space.Log(newRect.ToString("-0-"))
–Print "(x:-0-, y:-0-, width:-150-, height:-150-)"

Member Data Documentation

◆ Height

float SineSpace.Scripting.Types.SRect.Height

◆ Width

float SineSpace.Scripting.Types.SRect.Width

◆ X

float SineSpace.Scripting.Types.SRect.X

Axis parameters

local newRect=Rect.New(0,0,150,150)
Space.Log(rect.X.." "..rect.Y.." "..rect.Width.." "..rect.Height)

◆ Y

float SineSpace.Scripting.Types.SRect.Y

Property Documentation

◆ Bottom

float SineSpace.Scripting.Types.SRect.Bottom
get

◆ Center

SVector SineSpace.Scripting.Types.SRect.Center
get

The position of the center of the rectangle.

local newRect=Rect.New(50,50,150,150)
Space.Log(newRect.Center.ToString())
–Print "[125, 125, 0]"

◆ Left

float SineSpace.Scripting.Types.SRect.Left
get

◆ Max

SVector SineSpace.Scripting.Types.SRect.Max
get

The position of the maximum corner of the rectangle.

local newRect=Rect.New(50,50,150,150)
Space.Log(newRect.Max.ToString())
–Print "[200, 200, 0]"

◆ Min

SVector SineSpace.Scripting.Types.SRect.Min
get

The position of the minimum corner of the rectangle.

local newRect=Rect.New(50,50,150,150)
Space.Log(newRect.Min.ToString())
–Print "[50, 50, 0]"

◆ Position

SVector SineSpace.Scripting.Types.SRect.Position
get

The X and Y position of the rectangle.

local newRect=Rect.New(50,50,150,150)
Space.Log(newRect.Position.ToString())
–Print "[50, 50, 0]"

◆ Right

float SineSpace.Scripting.Types.SRect.Right
get

◆ Size

SVector SineSpace.Scripting.Types.SRect.Size
get

The width and height of the rectangle.

local newRect=Rect.New(50,50,150,150)
Space.Log(newRect.Size.ToString())
–Print "[150, 150, 0]"

◆ Top

float SineSpace.Scripting.Types.SRect.Top
get

◆ XMax

float SineSpace.Scripting.Types.SRect.XMax
get

The maximum X coordinate of the rectangle.

local newRect=Rect.New(50,50,150,150)
Space.Log(newRect.XMax)
–Print "200"

◆ XMin

float SineSpace.Scripting.Types.SRect.XMin
get

The minimum X coordinate of the rectangle.

local newRect=Rect.New(50,50,150,150)
Space.Log(newRect.XMin)
–Print "50"

◆ YMax

float SineSpace.Scripting.Types.SRect.YMax
get

The maximum Y coordinate of the rectangle.

local newRect=Rect.New(50,50,150,150)
Space.Log(newRect.YMax)
–Print "200"

◆ YMin

float SineSpace.Scripting.Types.SRect.YMin
get

The minimum Y coordinate of the rectangle.

local newRect=Rect.New(50,50,150,150)
Space.Log(newRect.YMin)
–Print "50"