UISystemPlugin

UI System Global Object

Constructor

new UISystemPlugin(contextopt)

Create the global UI system object

Parameters:
NameTypeAttributesDescription
contextCanvasRenderingContext2D<optional>
Example
// create the ui plugin object
 new UISystemPlugin;

Members

defaultButtonColor

Properties
TypeDescription
Color

Default button color for UI elements

defaultColor

Properties
TypeDescription
Color

Default fill color for UI elements

defaultCornerRadius

Properties
TypeDescription
number

Default rounded rect corner radius for UI elements

defaultDisabledColor

Properties
TypeDescription
Color

Default color for disabled UI elements

defaultFont

Properties
TypeDescription
string

Default font for UI elements

defaultHoverColor

Properties
TypeDescription
Color

Default hover color for UI elements

defaultLineColor

Properties
TypeDescription
Color

Default outline color for UI elements

defaultLineWidth

Properties
TypeDescription
number

Default line width for UI elements

defaultSoundClick

Properties
TypeDescription
Sound

Default sound when interactive UI element is clicked

defaultSoundPress

Properties
TypeDescription
Sound

Default sound when interactive UI element is pressed

defaultSoundRelease

Properties
TypeDescription
Sound

Default sound when interactive UI element is released

defaultTextColor

Properties
TypeDescription
Color

Default text color for UI elements

defaultTextScale

Properties
TypeDescription
number

Default scale to use for fitting text to object

uiContext

Properties
TypeDescription
CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D

Context to render UI elements to

uiObjects

Properties
TypeDescription
Array.<UIObject>

List of all UI elements

Methods

drawLine(posA, posB, lineWidthopt, lineColoropt)

Draw a line to the UI context

Parameters:
NameTypeAttributesDefaultDescription
posAVector2
posBVector2
lineWidthnumber<optional>
uiSystem.defaultLineWidth
lineColorColor<optional>
uiSystem.defaultLineColor

drawRect(pos, size, coloropt, lineWidthopt, lineColoropt, cornerRadiusopt)

Draw a rectangle to the UI context

Parameters:
NameTypeAttributesDefaultDescription
posVector2
sizeVector2
colorColor<optional>
uiSystem.defaultColor
lineWidthnumber<optional>
uiSystem.defaultLineWidth
lineColorColor<optional>
uiSystem.defaultLineColor
cornerRadiusnumber<optional>
uiSystem.defaultCornerRadius

drawText(text, pos, size, coloropt, lineWidthopt, lineColoropt, alignopt, fontopt, applyMaxWidthopt)

Draw text to the UI context

Parameters:
NameTypeAttributesDefaultDescription
textstring
posVector2
sizeVector2
colorColor<optional>
uiSystem.defaultColor
lineWidthnumber<optional>
uiSystem.defaultLineWidth
lineColorColor<optional>
uiSystem.defaultLineColor
alignstring<optional>
center
fontstring<optional>
uiSystem.defaultFont
applyMaxWidthboolean<optional>
true

drawTile(pos, size, tileInfo, coloropt, angleopt, mirroropt)

Draw a tile to the UI context

Parameters:
NameTypeAttributesDefaultDescription
posVector2
sizeVector2
tileInfoTileInfo
colorColor<optional>
uiSystem.defaultColor
anglenumber<optional>
0
mirrorboolean<optional>
false