4.0 KiB
4.0 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 |
| autoResize | boolean | false | Whether to automatically resize the image when content exceeds bounds |
| offsetX | number | 0 | Horizontal offset for viewing larger images |
| offsetY | number | 0 | Vertical offset for viewing larger images |
Combined Properties
| Name | Properties | Description |
|---|---|---|
| offset | offsetX offsetY |
Combined property for offsetX and offsetY |
Functions
| Method | Returns | Description |
|---|---|---|
| Image:addFrame | Image | Adds a new frame to the image |
| Image:getBg | - | |
| Image:getFg | - | |
| Image:getFrame | - | |
| Image:getImageSize | number | Gets the size of the image |
| Image:getMetadata | - | |
| Image:getPixelData | number? | Gets pixel information at position |
| Image:getText | - | |
| Image:nextFrame | Image | Advances to the next frame in the animation |
| Image:resizeImage | Image | Resizes the image to the specified width and height |
| Image:setBg | Image | Sets the background color at the specified position |
| Image:setFg | Image | Sets the foreground color at the specified position |
| Image:setMetadata | - | |
| Image:setPixel | Image | Sets the pixel at the specified position |
| Image:setText | Image | Sets the text at the specified position |
| Image:updateFrame | - |
Protected Functions
| Method | Returns | Description |
|---|---|---|
| Image:init | Image | Initializes the Image instance |
| Image:render | - | Renders the Image |
Image:addFrame()
Adds a new frame to the image
Returns
ImageselfThe Image instance
Image:getBg()
Image:getFg()
Image:getFrame()
Image:getImageSize()
Gets the size of the image
Returns
numberwidthThe width of the imagenumberheightThe height of the image
Image:getMetadata()
Image:getPixelData(x, y)
Gets pixel information at position
Parameters
xnumberX positionynumberY position
Returns
number?fgForeground colornumber?bgBackground colorstring?charCharacter at position
Image:getText()
Image:nextFrame()
Advances to the next frame in the animation
Returns
ImageselfThe Image instance
Image:resizeImage(width, height)
Resizes the image to the specified width and height
Parameters
widthnumberThe new width of the imageheightnumberThe new height of the image
Returns
ImageselfThe Image instance
Image:setBg(x, y, pattern)
Sets the background color at the specified position
Parameters
xnumberThe x positionynumberThe y positionpatternstringThe background color pattern
Returns
ImageselfThe Image instance
Image:setFg(x, y, pattern)
Sets the foreground color at the specified position
Parameters
xnumberThe x positionynumberThe y positionpatternstringThe foreground color pattern
Returns
ImageselfThe Image instance
Image:setMetadata()
Image:setPixel(x, y, char, fg, bg)
Sets the pixel at the specified position
Parameters
xnumberThe x positionynumberThe y positioncharstringThe character to setfgstringThe foreground color patternbgstringThe background color pattern
Returns
ImageselfThe Image instance
Image:setText(x, y, text)
Sets the text at the specified position
Parameters
xnumberThe x positionynumberThe y positiontextstringThe text to set
Returns
ImageselfThe Image instance