Gpu
Appearance
The GpuUD component is what allows for rendering to screens. It offers the following functionality:
| Name | Type | Read/Write | Description |
|---|---|---|---|
remainingVideoRam |
integer |
READ | The amount of video ram remaining. Every alive buffer requires a certain amount of video memory. |
| Name | Returns | Description |
|---|---|---|
:newBuffer(integer:width, integer:height)
|
TextBufferUD
|
Attempts to allocate and return a new TextBuffer of the given size. |
:assignBuffer(textBufferUD, screenBlockUD:screenComponent)
|
void
|
Assigns the given textBuffer to the given Screen, displaying the contents on the screen. |
:freeAllBuffers()
|
int
|
Frees all buffers allocated by this GPU and returns the number of freed buffers. |
TextBufferUD
You can interact with textBuffers using the following api:
| Name | Type | Read/Write | Description |
|---|---|---|---|
width |
int |
READ | The width/height of this buffer, as specified in GpuUD:newBuffer(...).
|
height
|
int
|
READ | |
isAlive
|
bool
|
READ | Whether this buffer is still alive, i.e. has not been deleted yet via :free().
|
In the following, x refers to the horizontal axis (like width) and y refers to the vertical axis (like height).
| Name | Returns | Description |
|---|---|---|
:getTextAsString()
|
string
|
Returns the entire content of this buffer as a single string. |
:free()
|
void
|
Deletes this buffer, releasing the held video memory. |
:getFg(x:int, y:int)
|
byte
|
Returns the foreground color of this position. Currently does not have any visible effect. |
:getBg(x:int, y:int)
|
byte
|
Returns the background color of this position. Currently does not have any visible effect. |
:getText(x:int, y:int)
|
char
|
Returns a single-letter string representing the letter stored at this position. |
:set(x:int, y:int, chr:char, fgColor:byte, bgColor: byte)
|
void
|
Sets the given position's character data, foreground and background color. Any arguments except for the position may be nil and will then have no effect. Color rendering is currently not implemented. |
:rotRows(cnt:int)
|
void
|
Rotates the lines of the buffer, allowing for efficient implementation of scrolling. |
:clearRow(line:int)
|
void
|
Clears the given line, resetting colors and text content of all positions of the given line. |
:newline()
|
void
|
Shorthand for: clearRow(0); rotRows(1);
|
:pasteText(x:int, y:int, mode:PasteMode, uText:string)
|
x:int, y:int
|
Pastes the given text uText at the given position with the given pasteMode mode. Returns the position directly after the pasted text. So when performing multiple paste-operations you likely want to supply the previously returned position as the next position argument.
|
:pasteText(uText:string)
|
x:int, y:int
|
Shorthand for: :pasteText(0, 0, uText)
|
:pasteText(x:int, y:int, uText:string)
|
x:int, y:int
|
Shorthand for: :pasteText(x, y, PasteMode.STOP, uText)
|