RLS Studios
ProjectsPatreonCommunityDocsAbout
Join Patreon
BeamNG Modding Docs

Guides

Reference

cdefDebugDraw ReferencecdefGpuMesh ReferencecdefImgui ReferencecdefMath Referencecdefs ReferencecontrolSystems Referencecsvlib ReferencedelayLine Referencedequeue ReferencedevUtils ReferenceEvent Referenceextensions Referencefilters Referencegraphpath Referenceguihooks ReferenceinputFilters ReferenceinterpolatedMap Referenceintrospection ReferencejbeamWriter Referencejson-ast Referencejson ReferencejsonDebug ReferencejsonPrettyEncoderCustom Referencekdtreebox2d Referencekdtreebox3d Referencekdtreepoint3d Referencelpack ReferenceluaBinding ReferenceluaCore ReferenceluaProfiler Referencemathlib Referenceparticles Referencequadtree Referencesettings ReferencetcpServer ReferencetimeEvents Referenceutils Reference
calltracer ReferencedateUtils ReferencedebugDraw Referencefilterchain Referenceutils/ - Utility Modulesheatmap ReferencehttpJsonServer ReferenceinteractiveShell ReferencelanguageMap Referenceperf Referencepixellib ReferencesimpleHttpServer ReferencetorqueScriptParser ReferencewsUtils Reference

UI

Resources

BeamNG Game Engine Lua Cheat SheetGE Developer RecipesMCP Server Setup

// RLS.STUDIOS=true

Premium Mods for BeamNG.drive. Career systems, custom vehicles, and immersive gameplay experiences.

Index

HomeProjectsPatreon

Socials

DiscordPatreon (RLS)Patreon (Vehicles)

© 2026 RLS Studios. All rights reserved.

Modding since 2024

API Referencecommonutils

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 pixels
    • height - 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 coordinate
    • y - number - Y coordinate
    • color - rgba_pixel_t - Pixel color

buf:getPixel(x, y)

Get a pixel's color value.

  • Parameters:
    • x - number - X coordinate
    • y - 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 X
    • y - number - Center Y
    • color - rgba_pixel_t - Color
    • size - 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 radius
    • color - rgba_pixel_t - Color
    • lineWidth - number|nil - Line width (default 1)

buf:drawFilledCircle(pos, radius, color)

Draw a filled circle.

  • Parameters:
    • pos - table - Center {x, y}
    • radius - number - Circle radius
    • color - 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 width
    • height - number - Rectangle height
    • color - rgba_pixel_t - Color
    • lineWidth - 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 width
    • height - number - Rectangle height
    • color - 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 - Color
    • lineWidth - 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 render
    • color - 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 identifier
    • color - rgba_pixel_t - Color

Internal Notes

  • Uses FFI for RGBA pixel struct (rgba_pixel_t: {r, g, b, a})
  • Uses string.buffer for efficient binary pixel data
  • saveRGBABufferToFile converts to GBitmap for file output
  • Supports primitive drawing (lines, rectangles, etc.) and mini bitmap font text
  • LuaPixelBuffer is 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.

On this page

ExportsFunctionsM.create()M.test()LuaPixelBuffer Methodsbuf:init(width, height)buf:saveFile(filename)buf:drawPixel(x, y, color)buf:getPixel(x, y)buf:drawPoint(x, y, color, size)buf:fill(color)buf:drawCircle(pos, radius, color, lineWidth)buf:drawFilledCircle(pos, radius, color)buf:drawRect(p1, width, height, color, lineWidth)buf:drawFilledRect(p1, width, height, color)buf:drawLine(pos1, pos2, color, lineWidth)buf:drawText(pos, text, color)buf:drawIcon(pos, type, color)Internal Notes