This is a high-performance QR code generator developed with Rust and WebAssembly technology. The project combines the efficiency of Rust with the cross-platform capabilities of WebAssembly to provide fast and efficient QR code generation for web applications.
- ⚡️ High Performance: Utilizing Rust and WebAssembly for high-speed QR code generation
- 🔄 Real-time Preview: Instantly updates QR codes as input changes
- 📋 Smart Copy Function: Copies QR code images directly to clipboard (with text fallback)
- 💾 Perfect Downloads: Downloads QR codes as crisp 450×450 pixel PNG images
- 🦖 Chromium-Style Dino: Supports dinosaur center images with white backgrounds
- 📱 Responsive Design: Adapts to different device screen sizes
- ✨ High DPI Support: Crystal clear rendering on retina and high-DPI displays
- 🎯 Chromium Compliance: Pixel-perfect implementation matching Chrome's QR generator
- Module Style: Circular dots (
ModuleStyle::kCircles) matching Chrome - Locator Style: Rounded corners (
LocatorStyle::kRounded) matching Chrome - Center Image: Dino with exact pixel data from Chromium source code
- Canvas Size: 240×240 pixels (
GetQRCodeImageSize()equivalent) - Module Size: 10 pixels per module (
kModuleSizePixels) - Dino Scale: 4 pixels per dino pixel (
kDinoTileSizePixels)
- Rust: Core QR code generation logic
- WebAssembly: Compiles Rust into a format that can run in browsers
- JavaScript: Front-end interaction and rendering
- HTML5/CSS: User interface
-
Clone the repository
git clone https://github.com/liuliangsir/chromium-style-qrcode-generator-with-wasm.git cd chromium-style-qrcode-generator-with-wasm -
Build the WebAssembly module
pnpm build:wasm
-
Install frontend dependencies
pnpm install
-
Start the development server
pnpm dev
-
Open the project in your browser (default: http://localhost:5173)
- Enter any text, URL, or data in the input field (up to 2000 characters)
- The QR code will be automatically generated and displayed with real-time updates
- Use the "Copy" button to copy the QR code image directly to clipboard
- Use the "Download" button to save the QR code as a crisp 450×450 PNG image
├── src/ # Source code directory
│ ├── lib.rs # Rust WebAssembly module core code
│ ├── app.js # Frontend JavaScript logic
│ └── app.css # Stylesheet
├── public/ # Static resources
├── index.html # Main HTML page
├── Cargo.toml # Rust project configuration
└── package.json # JavaScript project configuration
This QR code generator uses Rust's qr_code library to generate QR code data and exposes it to JavaScript via WebAssembly. The generation process includes:
- Receiving text data input from users
- Generating the corresponding QR code two-dimensional matrix in Rust
- Adding appropriate quiet zones
- Returning the two-dimensional matrix data to JavaScript
- Rendering the QR code image using the Canvas API
If you modify lib.rs or other Rust code, you need to rebuild the WebAssembly module:
pnpm build:wasmFrontend code modifications will automatically reload.
Issues and PRs are welcome! Please ensure your code adheres to the project's coding style.