3.6 KiB
3.6 KiB
@alias color number
VisualElement : BaseElement
Properties
| Property | Type | Default | Description |
|---|---|---|---|
| x | number | 1 | x position of the element |
| y | number | 1 | y position of the element |
| z | number | 1 | z position of the element |
| width | number | 1 | width of the element |
| height | number | 1 | height of the element |
| background | color | black | background color of the element |
| foreground | color | white | foreground color of the element |
| clicked | boolean | false | element is currently clicked |
Functions
| Method | Returns | Description |
|---|---|---|
| VisualElement.new | VisualElement | |
| VisualElement:getAbsolutePosition | - | |
| VisualElement:getRelativePosition | number, | |
| VisualElement:handleEvent | boolean? | |
| VisualElement:isInBounds | boolean | |
| VisualElement:mouse_click | boolean | |
| VisualElement:mouse_release | - | |
| VisualElement:mouse_up | - | |
| VisualElement:multiBlit | - | |
| VisualElement:render | - | |
| VisualElement:textFg | - |
VisualElement.new(id, basalt)
Creates a new VisualElement instance
Parameters
idstringThe unique identifier for this elementbasalttableThe basalt instance
Returns
VisualElementobjectThe newly created VisualElement instance
Usage
local element = VisualElement.new("myId", basalt)
VisualElement:getAbsolutePosition(x?, y?)
Returns the absolute position of the element or the given coordinates.
Parameters
x(optional)numberx positiony(optional)numbery position
VisualElement:getRelativePosition(x?, y?)
Returns the relative position of the element or the given coordinates.
Parameters
x(optional)numberx positiony(optional)numbery position
Returns
nilnilnil
VisualElement:handleEvent(event)
Handles all events @vararg any The arguments for the event
Parameters
eventstringThe event to handle
Returns
boolean?handledWhether the event was handled
VisualElement:isInBounds(x, y)
Checks if the specified coordinates are within the bounds of the element
Parameters
xnumberThe x position to checkynumberThe y position to check
Returns
booleanisInBoundsWhether the coordinates are within the bounds of the element
VisualElement:mouse_click(button, x, y)
Handles a mouse click event
Parameters
buttonnumberThe button that was clickedxnumberThe x position of the clickynumberThe y position of the click
Returns
booleanclickedWhether the element was clicked
VisualElement:mouse_release()
VisualElement:mouse_up()
VisualElement:multiBlit(x, y, width, height, text, fg, bg)
Draws a text character/fg/bg at the specified position with a certain size, used in the rendering system
Parameters
xnumberThe x position to drawynumberThe y position to drawwidthnumberThe width of the elementheightnumberThe height of the elementtextstringThe text char to drawfgcolorThe foreground colorbgcolorThe background color
VisualElement:render()
Renders the element
Usage
element:render()
VisualElement:textFg(x, y, text, fg)
Draws a text character at the specified position, used in the rendering system
Parameters
xnumberThe x position to drawynumberThe y position to drawtextstringThe text char to drawfgcolorThe foreground color