qr ~main

A simple library to generate Qr Codes


To use this package, run the following command in your project's root directory:

Manual usage
Put the following dependency into your project's dependences section:

QR Code for D

A QR Code generator library for D. It is self-contained and does not require any external dependencies. You can use it to generate QR Codes and save them as PNG, SVG, SVGZ, PPM files (or print them as ASCII art).

Based on Project Nayuki's code

Usage

Basic example:

import qr;
QrCode("Hello, world!").saveAs("test.png");

/* same as above
QrCode qrcode = "Hello, world!";
qrcode.saveAs("test.png");
*/

You can set extra options for generator:

  • ecl: Error Correction Level.
  • mask: Mask pattern.
  • boostEcl: Boost the error correction level (without increasing the size of the QR Code).

For example:

import qr;
QrCode("Hello, world!", ecl: ErrorCorrectionLevel.HIGH).writeln; // Print QR Code to stdout

You can save the QR Code to a file (PNG, SVG, PPM) with some options:

  • moduleSize: Size of each module (pixel)
  • padding: Padding around the QR Code (in modules)
  • foreground: Foreground color (default: #000000)
  • background: Background color (default: #FFFFFF)
import qr;
QrCode("Hello, world!").saveAs("test.png", moduleSize: 10, foreground: "#ff0000"); // Save a red QR Code as PNG

You can also access the raw QR Code data:

import qr;
QrCode qrcode = "Hello, world!";
qrcode.size.writeln; // Print the size (number of modules per side) of the QR Code
qrcode[0,0].writeln; // Print the module at position (0, 0) (true = black, false = white)

You can print QR Code as ASCII art:

import qr;
QrCode("Hello, world!").writeln; // Print QR Code as ASCII art
QrCode("Hello, world!").toString(dense: true).writeln; // Print QR Code as ASCII art, dense!

License

This project is licensed under the MIT License. See the LICENSE file for more details.

Authors:
  • Andrea Fontana
Dependencies:
none
Versions:
1.0.2 2024-Oct-18
1.0.1 2024-Oct-16
1.0.0 2024-Oct-16
~main 2024-Oct-18
Show all 4 versions
Download Stats:
  • 0 downloads today

  • 0 downloads this week

  • 2 downloads this month

  • 16 downloads total

Score:
0.6
Short URL:
qr.dub.pm