qr-code-styling
A Rust library for generating styled QR codes with customizable dots, corners, gradients, and logo embedding.
Features
- 6 dot styles — Square, Dots, Rounded, Classy, ClassyRounded, ExtraRounded
- 3 corner square styles — Square, Dot, ExtraRounded
- 2 corner dot styles — Dot, Square
- Gradient support — Linear and radial gradients for dots, corners, and background
- Logo embedding — Center an image inside the QR code with automatic dot hiding
- Circle shape — Render QR codes in a circular frame
- Border plugin — Add decorative borders with text labels
- Multiple output formats — SVG, PNG, JPEG, WebP, PDF
- Optional serde support — Serialize/deserialize configuration with the
serdefeature
Installation
[]
= "0.1"
Quick Start
use ;
use ;
use DotType;
let qr = builder
.data
.size
.dots_options
.build
.unwrap;
// Render as SVG string
let svg = qr.render_svg.unwrap;
// Save to file
qr.save.unwrap;
Examples
Styled dots with custom corners
use ;
use ;
use ;
let qr = builder
.data
.size
.dots_options
.corners_square_options
.corners_dot_options
.build
.unwrap;
qr.save.unwrap;
With logo
use ;
use ;
use DotType;
let logo_bytes = read.unwrap;
let qr = builder
.data
.size
.image
.image_options
.dots_options
.build
.unwrap;
qr.save.unwrap;
Circle shape with border
use ;
use ;
use ;
use DotType;
let qr = builder
.data
.size
.margin
.shape
.dots_options
.build
.unwrap;
let svg = qr.render_svg.unwrap;
let border_options = new
.with_round
.with_styled_text
.with_styled_text;
let bordered_svg = new.apply;
write.unwrap;
Output Formats
| Format | Method | Feature |
|---|---|---|
| SVG | render_svg() / save(_, Svg) |
always available |
| PNG | save(_, Png) |
png (default) |
| JPEG | save(_, Jpeg) |
jpeg (default) |
| WebP | save(_, WebP) |
webp (default) |
save(_, Pdf) |
always available |
Feature Flags
| Feature | Default | Description |
|---|---|---|
png |
yes | PNG raster output |
jpeg |
yes | JPEG raster output |
webp |
yes | WebP raster output |
serde |
no | Serialize/deserialize support |
License
MIT