4.9 KiB
4.9 KiB
Render
This is the render module for Basalt. It tries to mimic the functionality of the term API. but with additional
functionality. It also has a buffer system to reduce the number of calls
Fields
| Field | Type | Description |
|---|---|---|
| terminal | table |
The terminal object to render to |
| width | number |
The width of the render |
| height | number |
The height of the render |
| buffer | table |
The buffer to render |
| xCursor | number |
The x position of the cursor |
| yCursor | number |
The y position of the cursor |
| blink | boolean |
Whether the cursor should blink |
Functions
| Method | Returns | Description |
|---|---|---|
| Render.new | Render | |
| Render:addDirtyRect | Render | |
| Render:bg | Render | |
| Render:blit | Render | |
| Render:clear | Render | |
| Render:clearArea | Render | |
| Render:fg | Render | |
| Render:getSize | number, | |
| Render:mergeRects | Render | |
| Render:multiBlit | Render | |
| Render:rectOverlaps | boolean | |
| Render:render | Render | |
| Render:setCursor | Render | |
| Render:text | Render | |
| Render:textBg | Render | |
| Render:textFg | Render |
Render.new(terminal)
Creates a new Render object
Parameters
terminaltableThe terminal object to render to
Returns
nilnilnil
Render:addDirtyRect(x, y, width, height)
Adds a dirty rectangle to the buffer
Parameters
xnumberThe x position of the rectangleynumberThe y position of the rectanglewidthnumberThe width of the rectangleheightnumberThe height of the rectangle
Returns
nilnilnil
Render:bg(x, y, bg)
Blits a background color to the screen
Parameters
xnumberThe x positionynumberThe y positionbgstringThe background color to blit
Returns
nilnilnil
Render:blit(x, y, text, fg, bg)
Blits text to the screen
Parameters
xnumberThe x position to blit toynumberThe y position to blit totextstringThe text to blitfgstringThe foreground color of the textbgstringThe background color of the text
Returns
nilnilnil
Render:clear(bg)
Clears the screen
Parameters
bgcolorsThe background color to clear the screen with
Returns
nilnilnil
Render:clearArea(x, y, width, height, bg)
Clears an area of the screen
Parameters
xnumberThe x position of the areaynumberThe y position of the areawidthnumberThe width of the areaheightnumberThe height of the areabgcolorsThe background color to clear the area with
Returns
nilnilnil
Render:fg(x, y, fg)
Blits a foreground color to the screen
Parameters
xnumberThe x positionynumberThe y positionfgstringThe foreground color to blit
Returns
nilnilnil
Render:getSize()
Gets the size of the render
Returns
nilnilnil
Render:mergeRects(target, source)
Merges two rectangles
Parameters
targettableThe target rectanglesourcetableThe source rectangle
Returns
nilnilnil
Render:multiBlit(x, y, width, height, text, fg, bg)
Blits text to the screen with multiple lines
Parameters
xnumberThe x position to blit toynumberThe y position to blit towidthnumberThe width of the textheightnumberThe height of the texttextstringThe text to blitfgcolorsThe foreground color of the textbgcolorsThe background color of the text
Returns
nilnilnil
Render:rectOverlaps(r1, r2)
Checks if two rectangles overlap
Parameters
r1tableThe first rectangler2tableThe second rectangle
Returns
nilnilnil
Render:render()
Renders the buffer to the screen
Returns
nilnilnil
Render:setCursor(x, y, blink)
Sets the cursor position
Parameters
xnumberThe x position of the cursorynumberThe y position of the cursorblinkbooleanWhether the cursor should blink
Returns
nilnilnil
Render:text(x, y, text)
Blits text to the screen
Parameters
xnumberThe x position to blit toynumberThe y position to blit totextstringThe text to blit
Returns
nilnilnil
Render:textBg(x, y, text, bg)
Blits text to the screen with a background color
Parameters
xnumberThe x position to blit toynumberThe y position to blit totextstringThe text to blitbgcolorsThe background color of the text
Returns
nilnilnil
Render:textFg(x, y, text, fg)
Blits text to the screen with a foreground color
Parameters
xnumberThe x position to blit toynumberThe y position to blit totextstringThe text to blitfgcolorsThe foreground color of the text
Returns
nilnilnil