Giter VIP home page Giter VIP logo

qr.js's Introduction

QR.js

Simple HTML5 Canvas-based QR Code generation

Based on jsqrencode. Provides an API that's easier to work with. It requires ES5/Canvas so it only works on IE9+.

License: GPLv3.

How to Use

// draw into a canvas
QR.draw('Hello world!', document.getElementById('qr-canvas'));

// make an image
document.body.append(QR.makeImage('Hello again!'));

// set options so you can omit them for later use
QR.size = 500;
QR.ecclevel = 4;
QR.canvas = document.getElementById('qr-canvas'); // make sure your canvas is the right size.
QR.draw('Now it\'s easier!');

API


QR.draw(string, canvas [, size] [, ecclevel])

Draws directly into an existing canvas element.

Arguments:

  • string: string to encode.
  • canvas: a canvas DOM element. Optional if you have set QR.canvas.
  • size: size of code in pixels. Default: fill canvas.
  • ecclevel: Error Correction Capability level. Range: 1~4. Default: 2.

QR.makeImage(string [, size] [, ecclevel])
QR.toDataURL(string [, size] [, ecclevel])

Returns an image DOM element, or get the DataURL string.

Arguments:

  • string: string to encode.
  • size: size of image in pixels. Default: 300.
  • ecclevel: Error Correction Capability level. Range: 1~4. Default: 2.

QR.getFrame(string)

Returns an array containing value for each grid in the generated code. Black grids have value 1, empty ones are undefined.

Arguments:

  • string: string to encode.

qr.js's People

Contributors

yyx990803 avatar

Watchers

James Cloos avatar -A- avatar Rabbit avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.