SVG Based QR Code Generator – QRcode.js

Category: Javascript | March 17, 2020
Author:datalog
Views Total:3,492 views
Official Page:Go to website
Last Update:March 17, 2020
License:MIT

Preview:

SVG Based QR Code Generator – QRcode.js

Description:

A simple, fast and customizable QR code generator that makes it easier to create QR codes using SVG.

Related:

How to use it:

1. Download and insert the qrcode.js library into the document.

<script src="qrcode.min.js"></script>

2. Generate a basic SVG QR code.

var svgNode = new QRCode("CSSScript.com").svg();

3. You can also define the data in the msg setting.

var svgNode = new QRCode({
    msg : 'https://cssscript.com'
}).svg();

4. Adjust the size of the QR code. Default: 256(px).

var svgNode = new QRCode({
    msg : 'https://cssscript.com',
    dim : 128
}).svg();

5. Set the white space padding. Default: 41.

var svgNode = new QRCode({
    msg : 'https://cssscript.com',
    pad : 30
}).svg();

6. Determine the error correction level: L, M(default), H, Q

var svgNode = new QRCode({
    msg : 'https://cssscript.com',
    ecl : 'M'
}).svg();

7. Set the path and background colors.

var svgNode = new QRCode({
    msg : 'https://cssscript.com',
    pal : [ color, background-color ]
}).svg();

8. Determine whether to swap the X and Y modules. 0 is set by default, 1 is for swapping.

var svgNode = new QRCode({
    msg : 'https://cssscript.com',
    swp :  0
}).svg();

You Might Be Interested In:


Leave a Reply