qrkit/render/ascii
Terminal renderers for qrkit QR codes.
Default callers use to_string,
with_inverse, and
to_string_compact which keep the
ISO/IEC 18004 4-module quiet zone. Callers that need a tighter
margin (debug dumps, fixture diffs, README terminal panels)
build an AsciiOptions via
default_options /
with_margin / with_inverse_option
and render through to_string_with or
to_string_compact_with.
Types
Render options for the terminal renderers. Build with
default_options and the with_* setters.
pub opaque so the renderer can grow knobs (background colour,
glyph set, …) without breaking callers.
pub opaque type AsciiOptions
Values
pub fn default_options() -> AsciiOptions
Default rendering options: 4-module quiet zone (ISO/IEC 18004), non-inverted colours.
pub fn to_string(qr: qrkit.QrCode) -> String
Render the QR code using double-width full blocks. Uses the
ISO/IEC 18004 default 4-module quiet zone. See
to_string_with when a different margin is
needed.
pub fn to_string_compact(qr: qrkit.QrCode) -> String
Render the QR code using Unicode half blocks to halve the height,
keeping the default 4-module quiet zone. See
to_string_compact_with for a
caller-controlled margin.
pub fn to_string_compact_with(
qr: qrkit.QrCode,
options: AsciiOptions,
) -> String
Render the QR code using Unicode half blocks with a caller-
supplied margin. The inverse setting on
AsciiOptions is currently ignored for the
half-block renderer — the compact form’s glyph set already
encodes both top and bottom modules per character cell.
pub fn to_string_with(
qr: qrkit.QrCode,
options: AsciiOptions,
) -> String
Render using double-width full blocks with caller-supplied
AsciiOptions. The inverse setting on the
options flips dark / light glyphs identically to
with_inverse.
pub fn with_inverse(qr: qrkit.QrCode) -> String
Render the QR code with inverted colours and the default 4-module quiet zone.
pub fn with_inverse_option(
options: AsciiOptions,
inverse: Bool,
) -> AsciiOptions
Toggle inverted rendering (dark cells render as spaces, light cells as blocks).
pub fn with_margin(
options: AsciiOptions,
modules: Int,
) -> AsciiOptions
Override the quiet zone in modules. Values below 0 are clamped to 0. The 4-module default is the ISO/IEC 18004 minimum for reliable scannability — tightening it is appropriate for debug / fixture / inline-doc output, not for QR codes intended to be scanned from a camera.