2.4 KiB
2.4 KiB
Image : VisualElement
This is the Image element class which can be used to display bimg format images. The bimg format is a universal ComputerCraft image format. See: https://github.com/SkyTheCodeMaster/bimg
Properties
| Property | Type | Default | Description |
|---|---|---|---|
| bimg | table | {} | The bimg image data |
| currentFrame | number | 1 | Current animation frame |
| metadata | table | {} | Image metadata (version, palette, etc) |
Functions
| Method | Returns | Description |
|---|---|---|
| Image:getPixelData | number? | Gets pixel information at position |
| Image:loadBimg | Image | Loads a bimg format image |
| Image:nextFrame | Image | Advances to the next frame in the animation |
| Image:setBg | - | Sets background color at position |
| Image:setChar | - | Sets character at position |
| Image:setFg | - | Sets foreground color at position |
| Image:setPixel | - | Sets all properties at position |
Protected Functions
| Method | Returns | Description |
|---|---|---|
| Image:init | Image | Initializes the Image instance |
| Image:render | - | Renders the Image |
Image:getPixelData(x, y)
Gets pixel information at position
Parameters
xnumberX positionynumberY position
Returns
number?fgForeground colornumber?bgBackground colorstring?charCharacter at position
Image:loadBimg(bimgData)
Loads a bimg format image
Parameters
bimgDatatableThe bimg image data
Returns
ImageselfThe Image instance
Image:nextFrame()
Advances to the next frame in the animation
Returns
ImageselfThe Image instance
Image:setBg(x, y, color)
Sets background color at position
Parameters
xnumberX positionynumberY positioncolornumberColor value (0-15)
Image:setChar(x, y, char)
Sets character at position
Parameters
xnumberX positionynumberY positioncharstringSingle character to set
Image:setFg(x, y, color)
Sets foreground color at position
Parameters
xnumberX positionynumberY positioncolornumberColor value (0-15)
Image:setPixel(x, y, char, fg, bg)
Sets all properties at position
Parameters
xnumberX positionynumberY positioncharstring?Character to set (optional)fgnumber?Foreground color (optional)bgnumber?Background color (optional)