pixellib Reference
Module defined in `lua/common/utils/pixellib.lua`. Small pixel drawing library for rendering primitives and text to RGBA buffers, with file save support.
Module defined in lua/common/utils/pixellib.lua. Small pixel drawing library for rendering primitives and text to RGBA buffers, with file save support.
Exports
Functions
M.create()
Create a new pixel buffer instance.
- Returns: LuaPixelBuffer - New pixel buffer object
M.test()
Run built-in test/demo. Usage: require('utils/pixellib').test()
LuaPixelBuffer Methods
buf:init(width, height)
Initialize the buffer with given dimensions.
- Parameters:
width- number - Buffer width in pixelsheight- number - Buffer height in pixels
buf:saveFile(filename)
Save the buffer contents to an image file.
- Parameters:
filename- string - Output file path
buf:drawPixel(x, y, color)
Set a single pixel.
- Parameters:
x- number - X coordinatey- number - Y coordinatecolor- rgba_pixel_t - Pixel color
buf:getPixel(x, y)
Get a pixel's color value.
- Parameters:
x- number - X coordinatey- number - Y coordinate
- Returns: rgba_pixel_t - Pixel color
buf:drawPoint(x, y, color, size)
Draw a point (filled square) at a position.
- Parameters:
x- number - Center Xy- number - Center Ycolor- rgba_pixel_t - Colorsize- number - Point size in pixels
buf:fill(color)
Fill the entire buffer with a single color.
- Parameters:
color- rgba_pixel_t - Fill color
buf:drawCircle(pos, radius, color, lineWidth)
Draw a circle outline.
- Parameters:
pos- table - Center{x, y}radius- number - Circle radiuscolor- rgba_pixel_t - ColorlineWidth- number|nil - Line width (default 1)
buf:drawFilledCircle(pos, radius, color)
Draw a filled circle.
- Parameters:
pos- table - Center{x, y}radius- number - Circle radiuscolor- rgba_pixel_t - Color
buf:drawRect(p1, width, height, color, lineWidth)
Draw a rectangle outline.
- Parameters:
p1- table - Top-left corner{x, y}width- number - Rectangle widthheight- number - Rectangle heightcolor- rgba_pixel_t - ColorlineWidth- number|nil - Line width (default 1)
buf:drawFilledRect(p1, width, height, color)
Draw a filled rectangle.
- Parameters:
p1- table - Top-left corner{x, y}width- number - Rectangle widthheight- number - Rectangle heightcolor- rgba_pixel_t - Color
buf:drawLine(pos1, pos2, color, lineWidth)
Draw a line between two points.
- Parameters:
pos1- table - Start point{x, y}pos2- table - End point{x, y}color- rgba_pixel_t - ColorlineWidth- number|nil - Line width (default 1)
buf:drawText(pos, text, color)
Draw text using a built-in mini bitmap font.
- Parameters:
pos- table - Position{x, y}text- string - Text to rendercolor- rgba_pixel_t - Color
buf:drawIcon(pos, type, color)
Draw a small icon at a position.
- Parameters:
pos- table - Position{x, y}type- string - Icon type identifiercolor- rgba_pixel_t - Color
Internal Notes
- Uses FFI for RGBA pixel struct (
rgba_pixel_t: {r, g, b, a}) - Uses
string.bufferfor efficient binary pixel data saveRGBABufferToFileconverts toGBitmapfor file output- Supports primitive drawing (lines, rectangles, etc.) and mini bitmap font text
LuaPixelBufferis a class with metatable-based methods
perf Reference
Module defined in `lua/common/utils/perf.lua`. Performance profiler that tracks function execution times using debug hooks, with windowed statistics and CSV export.
simpleHttpServer Reference
Module defined in `lua/common/utils/simpleHttpServer.lua`. Simple HTTP server with static file serving, JSON responses, custom route handlers, and HTML templating.