SVG renderer for QR code matrices.
Dot shapes
:square ■ (default)
:rounded ▢ rounded corners (25% radius)
:dots ● circles
:diamond ◆ diamond / rotated squareFinder pattern shapes
Finder patterns (the three big squares in corners) can be styled
independently with :finder_shape:
:square default
:rounded rounded outer ring + rounded inner
:dots circular outer ring + circular innerLogo embedding
Pass a :logo option to embed an image or SVG in the center.
Modules behind the logo are automatically cleared.
QQR.SVG.render(matrix,
logo: %{svg: ~s(<circle r="0.4" cx="0.5" cy="0.5" fill="red"/>), size: 0.25}
)
Summary
Types
@type dot_shape() :: :square | :rounded | :dots | :diamond
@type finder_shape() :: :square | :rounded | :dots
@type option() :: {:module_size, number()} | {:quiet_zone, non_neg_integer()} | {:color, String.t()} | {:background, String.t()} | {:dot_shape, dot_shape()} | {:dot_size, float()} | {:finder_shape, finder_shape()} | {:logo, logo_opts()}
Functions
@spec render(QQR.BitMatrix.t(), [option()]) :: String.t()
Render a QQR.BitMatrix as an SVG string.
See to_iodata/2 for options.
@spec to_iodata(QQR.BitMatrix.t(), [option()]) :: iodata()
Render a QQR.BitMatrix as SVG iodata.
Returns iodata (nested list of strings) — avoids an extra binary copy.
Pass to IO.iodata_to_binary/1 when you need a string, or use directly
in Phoenix templates with raw/1.
Options
:module_size— pixel size per module (default:10):quiet_zone— quiet zone in modules (default:4):color— dark module color (default:"#000"):background— background color (default:"#fff"):dot_shape—:square,:rounded,:dots, or:diamond(default::square):dot_size— module size multiplier, 0.1–1.0 (default:1.0):finder_shape—:square,:rounded, or:dots(default: matches:dot_shapeor:square):logo— logo options map (see module doc)