How kozakdenys/qr-code-styling works
QR Code Styling is a JavaScript library for generating styled QR codes with optional center images, SVG or canvas output, and export/download support. The main workflow is to construct or update a QRCodeStyling instance with data and options, encode the data, render the QR matrix with styling, then append or export the result. The README also documents extensions. The sampled source shows SVG rendering and export paths; unsampled internals limit detail about some canvas and image-rendering links.
Main entry points: QRCodeStyling.ts QR instance · QRSVG.ts SVG renderer · index.ts Public exports · downloadURI.ts Download URI
Components 22
Library API
- QR instance
src/core/QRCodeStyling.ts - Public exports
src/index.ts - Defaults and options
src/core/QROptions.ts - Raw data export
src/core/QRCodeStyling.ts - File download
src/core/QRCodeStyling.ts - SVG extension
src/types/index.ts
QR Rendering
- QR encoding
- SVG renderer
src/core/QRSVG.ts - Dot figures
src/figures/dot/QRDot.ts - Corner dot figures
src/figures/cornerDot/QRCornerDot.ts - Corner square figures
src/figures/cornerSquare/QRCornerSquare.ts - Canvas output
src/core/QRCodeStyling.ts
Options and Export
- Option sanitizing
src/tools/sanitizeOptions.ts - Option merging
src/tools/merge.ts - Mode selection
src/tools/getMode.ts - Logo sizing
src/tools/calculateImageSize.ts - Image data URL
src/tools/toDataUrl.ts - Download URI
src/tools/downloadURI.ts
Other components
- Application
- qrcode-generator
- DOM container
- Saved file
Connections 23
- Application → Public exports: imports API
- Application → QR instance: sets data/options
- Public exports → QR instance: exports class
- QR instance → Defaults and options: loads defaults
- QR instance → Option merging: merges options
- QR instance → Option sanitizing: sanitizes options
- QR instance → Mode selection: selects mode
- QR instance → qrcode-generator: encodes data
- qrcode-generator → QR instance: returns QR matrix
- QR instance → SVG renderer: renders SVG
- SVG renderer → Dot figures: draws modules
- SVG renderer → Corner dot figures: draws corner dots
- SVG renderer → Corner square figures: draws corner squares
- SVG renderer → Logo sizing: sizes logo area
- SVG renderer → Image data URL: converts logo
- QR instance → Canvas output: renders canvas
- QR instance → SVG extension: applies extension
- QR instance → DOM container: appends output
- Application → Raw data export: requests export
- Raw data export → Saved file: returns raw data
- Application → File download: requests download
- File download → Download URI: starts download
- Download URI → Saved file: saves file