Skip to main content

qrgen

QR code generation for Lune and Roblox.

local qrgen = require("@packages/qrgen")
local qr = qrgen.encodeText("Hello", qrgen.ecc.medium)
print(qrgen.toString(qr))

Properties

ecc

Error correction levels. Higher = more recovery, larger code.

  • low: ~7%
  • medium: ~15%
  • quartile: ~25%
  • high: ~30%

mode

qrgen.mode: {
numericMode,
alphanumericMode,
byteMode,
kanjiMode,
eciMode
}

Encoding modes for segments.

minVersion

This item is read only and cannot be modified. Read Only
qrgen.minVersion: number

Minimum QR code version (1).

maxVersion

This item is read only and cannot be modified. Read Only
qrgen.maxVersion: number

Maximum QR code version (40).

segment

qrgen.segment: QrSegment

Segment creation. See QrSegment.

code

qrgen.code: QrCode

Low-level QR code access. See QrCode.

svg

qrgen.svg: SvgRenderer

SVG output. See svgRenderer.

frame

qrgen.frame: FrameRenderer?

Roblox Frame renderer. Nil outside Roblox. See frameRenderer.

Functions

encodeText

qrgen.encodeText(
textstring,--

Text to encode

eccErrorCorrectionLevel--

Error correction level

) → QrCode

Encode text into a QR code. Auto-selects optimal mode.

encodeBinary

qrgen.encodeBinary(
data{number},--

Byte array

eccErrorCorrectionLevel--

Error correction level

) → QrCode

Encode binary data (bytes 0-255).

encodeSegments

qrgen.encodeSegments(
segs{QrSegment},--

Segments to encode

eccErrorCorrectionLevel,--

Error correction level

minVersionnumber?,--

Min version 1-40 (default 1)

maxVersionnumber?,--

Max version 1-40 (default 40)

masknumber?,--

Mask pattern -1 to 7 (-1 = auto)

boostEclboolean?--

Boost ECC if possible (default true)

) → QrCode

Encode segments with full control.

renderToFrame

Roblox
qrgen.renderToFrame(
qrQrCode,--

QR code to render

optionsRenderOptions?--

Render options

) → Frame

Render QR code to Roblox Frame. Roblox only.

createContainer

Roblox
qrgen.createContainer(
parentGuiObject,--

Parent GuiObject

sizeUDim2?,--

Size (default 1x1 scale)

positionUDim2?--

Position (default 0,0)

) → Frame

Create Frame container with aspect ratio constraint. Roblox only.

toSvg

qrgen.toSvg(
qrQrCode,--

QR code

optionsSvgOptions?--

SVG options

) → string--

SVG markup

Render a QR code as an SVG string.

local svg = qrgen.toSvg(qr, {
    border = 4,
    darkColor = "#000000",
    lightColor = "#FFFFFF",
})

toSvgMinimal

qrgen.toSvgMinimal(
qrQrCode,--

QR code

bordernumber?--

Border size (default 4)

) → string--

SVG markup

Render QR code as minimal path-based SVG.

svgToDataUri

qrgen.svgToDataUri(
svgstring--

SVG string

) → string--

Data URI

Convert SVG to data URI.

toString

qrgen.toString(
qrQrCode,--

QR code

darkCharstring?,--

Dark char (default "██")

lightCharstring?--

Light char (default " ")

) → string

Convert QR code to ASCII string.

getMatrix

qrgen.getMatrix(
qrQrCode--

QR code

) → {{boolean}}

Get matrix as 2D boolean table.

getMatrixFlat

qrgen.getMatrixFlat(
qrQrCode--

QR code

) → {number}

Get matrix as flat array of 0s and 1s.

toTable

qrgen.toTable(
qrQrCode--

QR code

) → table

Get QR code as JSON-compatible table.

Show raw api
{
    "functions": [
        {
            "name": "encodeText",
            "desc": "Encode text into a QR code. Auto-selects optimal mode.",
            "params": [
                {
                    "name": "text",
                    "desc": "Text to encode",
                    "lua_type": "string"
                },
                {
                    "name": "ecc",
                    "desc": "Error correction level",
                    "lua_type": "ErrorCorrectionLevel"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "QrCode"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 118,
                "path": "src/init.luau"
            }
        },
        {
            "name": "encodeBinary",
            "desc": "Encode binary data (bytes 0-255).",
            "params": [
                {
                    "name": "data",
                    "desc": "Byte array",
                    "lua_type": "{ number }"
                },
                {
                    "name": "ecc",
                    "desc": "Error correction level",
                    "lua_type": "ErrorCorrectionLevel"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "QrCode"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 129,
                "path": "src/init.luau"
            }
        },
        {
            "name": "encodeSegments",
            "desc": "Encode segments with full control.",
            "params": [
                {
                    "name": "segs",
                    "desc": "Segments to encode",
                    "lua_type": "{ QrSegment }"
                },
                {
                    "name": "ecc",
                    "desc": "Error correction level",
                    "lua_type": "ErrorCorrectionLevel"
                },
                {
                    "name": "minVersion",
                    "desc": "Min version 1-40 (default 1)",
                    "lua_type": "number?"
                },
                {
                    "name": "maxVersion",
                    "desc": "Max version 1-40 (default 40)",
                    "lua_type": "number?"
                },
                {
                    "name": "mask",
                    "desc": "Mask pattern -1 to 7 (-1 = auto)",
                    "lua_type": "number?"
                },
                {
                    "name": "boostEcl",
                    "desc": "Boost ECC if possible (default true)",
                    "lua_type": "boolean?\n"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "QrCode"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 144,
                "path": "src/init.luau"
            }
        },
        {
            "name": "renderToFrame",
            "desc": "Render QR code to Roblox Frame. Roblox only.",
            "params": [
                {
                    "name": "qr",
                    "desc": "QR code to render",
                    "lua_type": "QrCode"
                },
                {
                    "name": "options",
                    "desc": "Render options",
                    "lua_type": "RenderOptions?"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Frame"
                }
            ],
            "function_type": "static",
            "tags": [
                "Roblox"
            ],
            "source": {
                "line": 163,
                "path": "src/init.luau"
            }
        },
        {
            "name": "createContainer",
            "desc": "Create Frame container with aspect ratio constraint. Roblox only.",
            "params": [
                {
                    "name": "parent",
                    "desc": "Parent GuiObject",
                    "lua_type": "GuiObject"
                },
                {
                    "name": "size",
                    "desc": "Size (default 1x1 scale)",
                    "lua_type": "UDim2?"
                },
                {
                    "name": "position",
                    "desc": "Position (default 0,0)",
                    "lua_type": "UDim2?"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Frame"
                }
            ],
            "function_type": "static",
            "tags": [
                "Roblox"
            ],
            "source": {
                "line": 176,
                "path": "src/init.luau"
            }
        },
        {
            "name": "toSvg",
            "desc": "Render a QR code as an SVG string.\n\n```lua\nlocal svg = qrgen.toSvg(qr, {\n    border = 4,\n    darkColor = \"#000000\",\n    lightColor = \"#FFFFFF\",\n})\n```",
            "params": [
                {
                    "name": "qr",
                    "desc": "QR code",
                    "lua_type": "QrCode"
                },
                {
                    "name": "options",
                    "desc": "SVG options",
                    "lua_type": "SvgOptions?"
                }
            ],
            "returns": [
                {
                    "desc": "SVG markup",
                    "lua_type": "string"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 195,
                "path": "src/init.luau"
            }
        },
        {
            "name": "toSvgMinimal",
            "desc": "Render QR code as minimal path-based SVG.",
            "params": [
                {
                    "name": "qr",
                    "desc": "QR code",
                    "lua_type": "QrCode"
                },
                {
                    "name": "border",
                    "desc": "Border size (default 4)",
                    "lua_type": "number?"
                }
            ],
            "returns": [
                {
                    "desc": "SVG markup",
                    "lua_type": "string"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 206,
                "path": "src/init.luau"
            }
        },
        {
            "name": "svgToDataUri",
            "desc": "Convert SVG to data URI.",
            "params": [
                {
                    "name": "svg",
                    "desc": "SVG string",
                    "lua_type": "string"
                }
            ],
            "returns": [
                {
                    "desc": "Data URI",
                    "lua_type": "string"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 216,
                "path": "src/init.luau"
            }
        },
        {
            "name": "toString",
            "desc": "Convert QR code to ASCII string.",
            "params": [
                {
                    "name": "qr",
                    "desc": "QR code",
                    "lua_type": "QrCode"
                },
                {
                    "name": "darkChar",
                    "desc": "Dark char (default \"██\")",
                    "lua_type": "string?"
                },
                {
                    "name": "lightChar",
                    "desc": "Light char (default \"  \")",
                    "lua_type": "string?"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "string"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 228,
                "path": "src/init.luau"
            }
        },
        {
            "name": "getMatrix",
            "desc": "Get matrix as 2D boolean table.",
            "params": [
                {
                    "name": "qr",
                    "desc": "QR code",
                    "lua_type": "QrCode"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "{ { boolean } }"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 250,
                "path": "src/init.luau"
            }
        },
        {
            "name": "getMatrixFlat",
            "desc": "Get matrix as flat array of 0s and 1s.",
            "params": [
                {
                    "name": "qr",
                    "desc": "QR code",
                    "lua_type": "QrCode"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "{ number }"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 260,
                "path": "src/init.luau"
            }
        },
        {
            "name": "toTable",
            "desc": "Get QR code as JSON-compatible table.",
            "params": [
                {
                    "name": "qr",
                    "desc": "QR code",
                    "lua_type": "QrCode"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "table"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 278,
                "path": "src/init.luau"
            }
        }
    ],
    "properties": [
        {
            "name": "ecc",
            "desc": "Error correction levels. Higher = more recovery, larger code.\n- `low`: ~7%\n- `medium`: ~15%\n- `quartile`: ~25%\n- `high`: ~30%",
            "lua_type": "{ low: ErrorCorrectionLevel, medium: ErrorCorrectionLevel, quartile: ErrorCorrectionLevel, high: ErrorCorrectionLevel }",
            "source": {
                "line": 48,
                "path": "src/init.luau"
            }
        },
        {
            "name": "mode",
            "desc": "Encoding modes for segments.",
            "lua_type": "{ numeric: Mode, alphanumeric: Mode, byte: Mode, kanji: Mode, eci: Mode }",
            "source": {
                "line": 56,
                "path": "src/init.luau"
            }
        },
        {
            "name": "minVersion",
            "desc": "Minimum QR code version (1).",
            "lua_type": "number",
            "readonly": true,
            "source": {
                "line": 65,
                "path": "src/init.luau"
            }
        },
        {
            "name": "maxVersion",
            "desc": "Maximum QR code version (40).",
            "lua_type": "number",
            "readonly": true,
            "source": {
                "line": 74,
                "path": "src/init.luau"
            }
        },
        {
            "name": "segment",
            "desc": "Segment creation. See [QrSegment].",
            "lua_type": "QrSegment",
            "source": {
                "line": 81,
                "path": "src/init.luau"
            }
        },
        {
            "name": "code",
            "desc": "Low-level QR code access. See [QrCode].",
            "lua_type": "QrCode",
            "source": {
                "line": 88,
                "path": "src/init.luau"
            }
        },
        {
            "name": "svg",
            "desc": "SVG output. See [svgRenderer].",
            "lua_type": "SvgRenderer",
            "source": {
                "line": 95,
                "path": "src/init.luau"
            }
        },
        {
            "name": "frame",
            "desc": "Roblox Frame renderer. Nil outside Roblox. See [frameRenderer].",
            "lua_type": "FrameRenderer?",
            "source": {
                "line": 102,
                "path": "src/init.luau"
            }
        }
    ],
    "types": [],
    "name": "qrgen",
    "desc": "QR code generation for Lune and Roblox.\n\n```lua\nlocal qrgen = require(\"@packages/qrgen\")\nlocal qr = qrgen.encodeText(\"Hello\", qrgen.ecc.medium)\nprint(qrgen.toString(qr))\n```",
    "source": {
        "line": 13,
        "path": "src/init.luau"
    }
}