You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 serde feature
Installation
[dependencies]
qr-code-styling = "0.1"
Quick Start
use qr_code_styling::{QRCodeStyling,OutputFormat};use qr_code_styling::config::{DotsOptions,Color};use qr_code_styling::types::DotType;let qr = QRCodeStyling::builder().data("https://example.com").size(300).dots_options(DotsOptions::new(DotType::Rounded).with_color(Color::rgb(0,0,128))).build().unwrap();// Render as SVG stringlet svg = qr.render_svg().unwrap();// Save to file
qr.save("qr.png",OutputFormat::Png).unwrap();
Examples
Styled dots with custom corners
use qr_code_styling::{QRCodeStyling,OutputFormat};use qr_code_styling::config::{DotsOptions,CornersSquareOptions,CornersDotOptions,Color};use qr_code_styling::types::{DotType,CornerSquareType,CornerDotType};let qr = QRCodeStyling::builder().data("Hello, Rust!").size(350).dots_options(DotsOptions::new(DotType::Rounded).with_color(Color::from_hex("#2C3E50").unwrap()),).corners_square_options(CornersSquareOptions::new(CornerSquareType::ExtraRounded).with_color(Color::from_hex("#E74C3C").unwrap()),).corners_dot_options(CornersDotOptions::new(CornerDotType::Dot).with_color(Color::from_hex("#E74C3C").unwrap()),).build().unwrap();
qr.save("styled.svg",OutputFormat::Svg).unwrap();
With gradient
use qr_code_styling::QRCodeStyling;use qr_code_styling::config::{DotsOptions,Color,Gradient};use qr_code_styling::types::{DotType,OutputFormat};let qr = QRCodeStyling::builder().data("https://example.com").size(300).dots_options(DotsOptions::new(DotType::Rounded).with_gradient(Gradient::simple_linear(Color::from_hex("#8E2DE2").unwrap(),Color::from_hex("#4A00E0").unwrap(),),)).build().unwrap();
qr.save("gradient.png",OutputFormat::Png).unwrap();
With logo
use qr_code_styling::{QRCodeStyling,OutputFormat};use qr_code_styling::config::{DotsOptions,ImageOptions,Color};use qr_code_styling::types::DotType;let logo_bytes = std::fs::read("logo.png").unwrap();let qr = QRCodeStyling::builder().data("https://rust-lang.org").size(400).image(logo_bytes).image_options(ImageOptions::default().with_image_size(0.4).with_margin(5).with_hide_background_dots(true),).dots_options(DotsOptions::new(DotType::Rounded).with_color(Color::from_hex("#2C3E50").unwrap()),).build().unwrap();
qr.save("with_logo.png",OutputFormat::Png).unwrap();