UISystem. 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

activeObject

Properties
TypeDescription
UIObject

Object user is currently interacting with

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

defaultGradientColor

Properties
TypeDescription
Color

Uses a gradient fill combined with color

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

hoverObject

Properties
TypeDescription
UIObject

Top most object user is over

lastHoverObject

Properties
TypeDescription
UIObject

Hover object at start of update

nativeHeight

Properties
TypeDescription
number

If set ui coords will be renormalized to this canvas height

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, gradientColoropt)

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
gradientColorColor<optional>
uiSystem.defaultGradientColor

drawText(text, pos, size, coloropt, lineWidthopt, lineColoropt, alignopt, fontopt, fontStyleopt, 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
fontStylestring<optional>
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

setupDragAndDrop(onDropopt, onDragEnteropt, onDragLeaveopt, onDragOveropt)

Setup drag and drop event handlers Automatically prevents defaults and calls the given functions

Parameters:
NameTypeAttributesDescription
onDropDragAndDropCallback<optional>

when a file is dropped

onDragEnterDragAndDropCallback<optional>

when a file is dragged onto the window

onDragLeaveDragAndDropCallback<optional>

when a file is dragged off the window

onDragOverDragAndDropCallback<optional>

continously when dragging over