Image
This is the Image element class which can be used to display bimg formatted images.Bimg is a universal ComputerCraft image format.See: https://github.com/SkyTheCodeMaster/bimg
Extends: VisualElement
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 |
Functions
| Method | Returns | Description |
|---|---|---|
| Image:resizeImage | Image | Resizes the image to the specified width and height |
| Image:getImageSize | number, number | Gets the size of the image |
| Image:getPixelData | fg, bg, char | Gets pixel information at position |
| Image:setText | Image | Sets the text at the specified position |
| Image:getText | string | Gets the text at the specified position |
| Image:setFg | Image | Sets the foreground color at the specified position |
| Image:getFg | string | Gets the foreground color at the specified position |
| Image:setBg | Image | Sets the background color at the specified position |
| Image:getBg | string | Gets the background color at the specified position |
| Image:setPixel | Image | Sets the pixel at the specified position |
| Image:nextFrame | Image | Advances to the next frame in the animation |
| Image:addFrame | Image | Adds a new frame to the image |
| Image:updateFrame | Image | Updates the specified frame with the provided data |
| Image:getFrame | table | Gets the specified frame |
| Image:getMetadata | table | Gets the metadata of the image |
| Image:setMetadata | Image | Sets the metadata of the image |
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:getImageSize()
Gets the size of the image
Returns
numberwidthThe width of the imagenumberheightThe height of the image
Image:getPixelData(x, y)
Gets pixel information at position
Parameters
xnumberX positionynumberY position
Returns
fgForegroundcolorbgBackgroundcolorcharCharacterat position
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
Image:getText(x, y, length)
Gets the text at the specified position
Parameters
xnumberThe x positionynumberThe y positionlengthnumberThe length of the text to get
Returns
stringtextThe text at the specified position
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:getFg(x, y, length)
Gets the foreground color at the specified position
Parameters
xnumberThe x positionynumberThe y positionlengthnumberThe length of the foreground color pattern to get
Returns
stringfgThe foreground color pattern
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:getBg(x, y, length)
Gets the background color at the specified position
Parameters
xnumberThe x positionynumberThe y positionlengthnumberThe length of the background color pattern to get
Returns
stringbgThe background color pattern
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:nextFrame()
Advances to the next frame in the animation
Returns
ImageselfThe Image instance
Image:addFrame()
Adds a new frame to the image
Returns
ImageselfThe Image instance
Image:updateFrame(frameIndex, frame)
Updates the specified frame with the provided data
Parameters
frameIndexnumberThe index of the frame to updateframetableThe new frame data
Returns
ImageselfThe Image instance
Image:getFrame(frameIndex)
Gets the specified frame
Parameters
frameIndexnumberThe index of the frame to get
Returns
tableframeThe frame data
Image:getMetadata()
Gets the metadata of the image
Returns
tablemetadataThe metadata of the image
Image:setMetadata(key, value)
Sets the metadata of the image
Parameters
keystringThe key of the metadata to setvaluestringThe value of the metadata to set
Returns
ImageselfThe Image instance