GithubHelp home page GithubHelp logo

nhv33 / nobsqr.js Goto Github PK

View Code? Open in Web Editor NEW

This project forked from chuckfairy/vanillaqr.js

1.0 0.0 0.0 118 KB

Simple, No BS, Client-side QR Generator

Home Page: http://www.nobsqr.com/

License: Other

Shell 0.27% JavaScript 92.29% CSS 1.22% HTML 6.21%
client-side javascript qr qrcode qrcode-generator

nobsqr.js's Introduction

NoBSQR client-side javascript QR code generator

A fork of Chuck Fairy's Vanilla.js, which is a small javascript file that runs client-side and outputs QR codes using the HTML5 Canvas element or tables for support with legacy browsers.

New Features:

  • Border width can now be updated dynamically (HTML canvas & tables).
  • QR code background and pixels can be rendered with alpha transparency.
  • QR code pixels can be rendered with rounded corners.
  • URL/text string can be displayed above, below, or over the QR code (HTML canvas only).
  • When URL/text is displayed over the QR code, error correction is automatically set to maximum.

Live Demos

How to use

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

//Create a qr object
//Below are the custom parameters and their default values (except for url)
var qr = new NoBSQR({

    // QR Content (only supports ASCII characters)
    url: "https://github.com/NHV33/NoBSQR.js",

    // Error Correction (levels 1-4)
    ecclevel: 1,

    // Size Parameters
    size: 300,
    borderSize: 30,

    // Background Color (supports alpha transparency)
    // Colors must be a hexidecimal color value (with or without the alpha channel)
    colorLight: "#FFFFFFFF",

    // Pixel Color (supports alpha transparency)
    // Colors must be a hexidecimal color value (with or without the alpha channel)
    colorDark: "#000000FF",
    
    // Toggle border
    noBorder: false,

    // Toggle use of HTML canvas or tables (for legacy browsers)
    toTable: false,

    // Toggle text display (can also be hidden if textPosition is "hidden")
    textDisplay: true,

    // Text Position ("top", "center", "bottom", "hidden")
    textPosition: "bottom",

    // Manual Text Adjustment (Accepts a number between -99 and 100)
    // This is useful if textPosition is "center" and large text prevents scanning.
    textSizeAdjust: 0,
    
    // Pixel Rounding Percent (0-100)
    // Values larger than 0 will disable transparency for pixels (colorDark property)
    pixelRadius: 0,

    // Automatic Text Resizing
    // These determine text resizing accuracy. Only change if performance is slow.
    textResizeIterationCap = customize.textResizeIterationCap || 1000,
    textResizeAmount = customize.textResizeAmount || 1,

});

//Canvas or table is stored in domElement property
document.body.appendChild(qr.domElement);

//Alternatively you can create an image from the canvas
//png, jpg, jpeg, webp, gif, bmp, tiff, x-icon, svg+xml, xxx
//Currently canvas dataURL mime types are not the same
var imageElement = qr.toImage("png");

if(imageElement) {
    document.body.appendChild(imageElement);
}


//You can recreate the qr code to a new url like so
//If you have appended the domElement it will change
qr.url = "https://github.com/chuckfairy"; // <== Shoutout to the original creator
qr.colorLight = "#0000000";
qr.colorDark = "#ffffff";
qr.init();

</script>

How to import as a module

import NoBSQR from "NoBSQR"


//See above for more
var qr = new NoBSQR({
    url: "https://github.com/NHV33/NoBSQR.js",
});

Browser support

All browsers with canvas and canvas 2d context support

  • Chrome > 30
  • IE > 8
  • Firefox > 33
  • Opera > 25
  • Safari > 7.0
  • Android > 4.0

Table support fallback

  • Chrome
  • IE > 6
  • Firefox
  • Opera
  • Safari
  • Andriod

NoBSQR is based on Vanilla QR by Chuck Fairy, which is based on a port of a java qr code library that he could no longer find. Legend says he is still searching for it to this very day.

Special Thanks

  • Creator of VanillaQR.js: chuckfairy

nobsqr.js's People

Contributors

chuckfairy avatar nhv33 avatar kristerv avatar

Stargazers

 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.