/qrcanvas

Generate characteristic qrcodes with a canvas.

Primary LanguageJavaScript

QRCanvas

NPM License Downloads

This is a QRCode generator written in pure javascript.

Based on Kazuhiko Arase's QRCode.

The only requirement is that the browser works with a canvas, which is supported by most modern browsers.

Installation

$ yarn add qrcanvas

Quick Start

  • Use in modules

    import qrcanvas from 'qrcanvas';
  • Use in browser

    You can either build the code or get released files from https://unpkg.com.

    <div id="qrcode"></div>
    
    <script src="https://unpkg.com/qrcanvas/dist/qrcanvas.min.js"></script>
    const canvas = qrcanvas({
      data: 'hello, world'
    });
    document.getElementById('qrcode').appendChild(canvas);
  • Use in Node.js

    node-canvas is required in Node.js.

    const fs = require('fs');
    const qrcanvas = require('qrcanvas/dist/qrcanvas.node.js');
    const canvas = qrcanvas({
      data: 'hello, world'
    });
    // canvas is an instance of `node-canvas`
    canvas.pngStream().pipe(fs.createWriteStream('qrcode.png'));

More

Snapshots

1

2