diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..8c52ff9 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,12 @@ +root = true + +[*] +charset = utf-8 +end_of_line = lf +indent_style = space +indent_size = 2 +insert_final_newline = true +trim_trailing_whitespace = true + +[*.md] +trim_trailing_whitespace = false diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 0000000..4aecb50 --- /dev/null +++ b/.eslintignore @@ -0,0 +1,3 @@ +dist/ + +Gruntfile.js diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 0000000..6d95cb5 --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,333 @@ +{ + "env": { + "browser": true, + "es6": true, + "node": true + }, + "parser": "babel-eslint", + "parserOptions": { + "ecmaVersion": 6, + "sourceType": "module" + }, + "rules": { + "arrow-parens": [ + 2, + "always" + ], + "arrow-spacing": [ + 2, + { + "before": true, + "after": true + } + ], + "constructor-super": 2, + "generator-star-spacing": [ + 2, + { + "before": true, + "after": false + } + ], + "no-class-assign": 2, + "no-const-assign": 2, + "no-dupe-class-members": 2, + "no-this-before-super": 2, + "no-var": 2, + "object-shorthand": [ + 1, + "always" + ], + "prefer-arrow-callback": 2, + "prefer-const": 0, + "prefer-spread": 0, + "prefer-reflect": 0, + "prefer-template": 1, + "require-yield": 0, + "comma-dangle": [ + 2, + "never" + ], + "no-cond-assign": [ + 2, + "except-parens" + ], + "no-console": 0, + "no-constant-condition": 2, + "no-control-regex": 2, + "no-debugger": 2, + "no-dupe-args": 2, + "no-dupe-keys": 2, + "no-duplicate-case": 2, + "no-empty-character-class": 2, + "no-empty": 2, + "no-ex-assign": 2, + "no-extra-boolean-cast": 2, + "no-extra-parens": 2, + "no-extra-semi": 2, + "no-func-assign": 2, + "no-inner-declarations": 2, + "no-invalid-regexp": 2, + "no-irregular-whitespace": 2, + "no-negated-in-lhs": 2, + "no-obj-calls": 2, + "no-regex-spaces": 2, + "no-sparse-arrays": 2, + "no-unreachable": 2, + "use-isnan": 2, + "valid-jsdoc": 0, + "valid-typeof": 2, + "block-scoped-var": 0, + "complexity": [ + 1, + 6 + ], + "consistent-return": 2, + "curly": 2, + "default-case": 0, + "dot-notation": [ + 2, + { + "allowKeywords": true, + "allowPattern": "" + } + ], + "dot-location": [ + 2, + "property" + ], + "eqeqeq": [ + 2, + "allow-null" + ], + "guard-for-in": 2, + "no-alert": 2, + "no-caller": 2, + "no-div-regex": 2, + "no-else-return": 2, + "no-eq-null": 0, + "no-eval": 2, + "no-extend-native": 2, + "no-extra-bind": 2, + "no-fallthrough": 2, + "no-floating-decimal": 2, + "no-implied-eval": 2, + "no-iterator": 2, + "no-labels": 2, + "no-lone-blocks": 2, + "no-loop-func": 2, + "no-multi-spaces": 2, + "no-multi-str": 2, + "no-native-reassign": 2, + "no-new-func": 2, + "no-new-wrappers": 2, + "no-new": 2, + "no-octal-escape": 2, + "no-octal": 0, + "no-param-reassign": 0, + "no-process-env": 0, + "no-proto": 2, + "no-redeclare": 0, + "no-return-assign": 2, + "no-script-url": 2, + "no-self-compare": 2, + "no-sequences": 2, + "no-throw-literal": 2, + "no-unused-expressions": 2, + "no-void": 2, + "no-warning-comments": 1, + "no-with": 2, + "radix": 2, + "vars-on-top": 0, + "wrap-iife": [ + 2, + "inside" + ], + "yoda": 0, + "strict": [ + 2, + "safe" + ], + "no-catch-shadow": 0, + "no-delete-var": 2, + "no-label-var": 2, + "no-shadow-restricted-names": 2, + "no-shadow": 0, + "no-undef-init": 2, + "no-undef": 2, + "no-undefined": 2, + "no-unused-vars": [ + 1, + { + "vars": "all", + "args": "after-used" + } + ], + "no-use-before-define": [ + 2, + "nofunc" + ], + "handle-callback-err": [ + 2, + "^(err|error)$" + ], + "no-mixed-requires": [ + 1, + true + ], + "no-new-require": 2, + "no-path-concat": 2, + "no-process-exit": 2, + "no-restricted-modules": 0, + "no-sync": 2, + "brace-style": [ + 2, + "1tbs", + { + "allowSingleLine": false + } + ], + "camelcase": [ + 2, + { + "properties": "always" + } + ], + "comma-spacing": [ + 2, + { + "before": false, + "after": true + } + ], + "comma-style": [ + 2, + "last" + ], + "consistent-this": 0, + "eol-last": 0, + "func-names": 0, + "func-style": 0, + "indent": [ + 2, + 2 + ], + "key-spacing": [ + 2, + { + "beforeColon": false, + "afterColon": true + } + ], + "linebreak-style": [ + 2, + "unix" + ], + "max-nested-callbacks": [ + 2, + 3 + ], + "new-cap": [ + 2, + { + "newIsCap": true, + "capIsNew": true + } + ], + "new-parens": 2, + "newline-after-var": 0, + "no-array-constructor": 2, + "no-continue": 0, + "no-inline-comments": 2, + "no-lonely-if": 2, + "no-mixed-spaces-and-tabs": 2, + "no-multiple-empty-lines": 2, + "no-nested-ternary": 2, + "no-new-object": 2, + "no-spaced-func": 2, + "no-ternary": 0, + "no-trailing-spaces": 2, + "no-underscore-dangle": 0, + "no-unneeded-ternary": 2, + "one-var": [ + 2, + "never" + ], + "operator-assignment": [ + 2, + "always" + ], + "operator-linebreak": [ + 2, + "after" + ], + "padded-blocks": [ + 2, + "never" + ], + "quote-props": [ + 2, + "as-needed" + ], + "quotes": [ + 2, + "single" + ], + "semi-spacing": [ + 2, + { + "before": false, + "after": true + } + ], + "semi": [ + 2, + "never" + ], + "sort-vars": 0, + "keyword-spacing": [ + 2, + { + "before": true, + "after": true + } + ], + "space-before-blocks": [ + 2, + "always" + ], + "space-before-function-paren": [ + 2, + "never" + ], + "object-curly-spacing": [ + 2, + "always" + ], + "computed-property-spacing": [ + 2, + "never" + ], + "array-bracket-spacing": [ + 2, + "always" + ], + "space-in-parens": [ + 2, + "never" + ], + "space-infix-ops": 2, + "space-unary-ops": [ + 2, + { + "words": true, + "nonwords": false + } + ], + "spaced-comment": [ + 2, + "always" + ], + "wrap-regex": 0 + } +} diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..fcadb2c --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +* text eol=lf diff --git a/.gitignore b/.gitignore index aa19737..552f221 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,2 @@ -node_modules -npm-debug.log - -.DS_Store? -ehthumbs.db -Icon? -Thumbs.db +node_modules/ +*.log diff --git a/.jshintrc b/.jshintrc deleted file mode 100644 index c491a0b..0000000 --- a/.jshintrc +++ /dev/null @@ -1,23 +0,0 @@ -{ - "boss": true, - "browser": true, - "camelcase": true, - "curly": false, - "eqeqeq": true, - "immed": true, - "latedef": true, - "laxcomma": true, - "maxlen": 100, - "newcap": true, - "noarg": true, - "node": true, - "nonew": true, - "quotmark": "single", - "strict": true, - "undef": true, - "unused": true, - "-W018": true, - "globals": { - "define": true - } -} \ No newline at end of file diff --git a/.npmignore b/.npmignore index 94fe8b4..6f4396a 100644 --- a/.npmignore +++ b/.npmignore @@ -1,11 +1,8 @@ -docs -.jshintrc +.* AUTHORS.md +bower.json CHANGES.md CONTRIBUTING.md +demo.html Gruntfile.js -INSTALL.md README.md -bower.json -qr.min.js -qr.min.map diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..615a35d --- /dev/null +++ b/.travis.yml @@ -0,0 +1,23 @@ +language: node_js +node_js: + - "0.10" + - "0.12" + - "4.0" + - "6.0" +script: + - npm test +env: + - CXX=g++-4.8 +addons: + apt: + sources: + - ubuntu-toolchain-r-test + packages: + - build-essential + - g++-4.8 + - libcairo2-dev + - libgif-dev + - libjpeg-dev + - libpango1.0-dev + - make + - python diff --git a/AUTHORS.md b/AUTHORS.md index 0fa53ce..c4cc6cf 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -1,6 +1,6 @@ # Authors ordered by first contribution -* tz +* Tom Zerucha * Alasdair Mercer * Alexandre Perrin * Michael Mason diff --git a/CHANGES.md b/CHANGES.md index 08a1f2d..c745c39 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,16 +1,31 @@ +## Version 2.0.0, 2016.06.26 + +* Rename library to QRious and move package from `qr-js` to `qrious` +* Completely redesign API to follow OOP pattern for simplicity +* Remove `save` and `saveSync` method +* Remove `noConflict` method +* Remove documentation generated by `docco` +* Restructure code base to make it more maintainable and use [Rollup](http://rollupjs.org) to build it +* Provide better built-in support for [Browserify](http://browserify.org) and [Webpack](http://webpack.github.io) etc +* Switch from [JSHint](https://github.com/jshint/jshint) to [ESLint](http://eslint.org) +* Add `demo.html` to allow contributors to experiment and test with changes due to lack of unit tests +* Remove `INSTALL.md` and consolidate contents into `README.md` and `CONTRIBUTING.md` +* Add [EditorConfig](http://editorconfig.org) file +* Add support for [Travis CI](https://travis-ci.org) + ## Version 1.1.4, 2015.11.11 -* [#2](https://github.com/neocotic/qr.js/issues/2): Fix padding issues -* [#35](https://github.com/neocotic/qr.js/pull/35): Make the QR-code center-aligned -* [#38](https://github.com/neocotic/qr.js/pull/38): Update node-canvas dependency version to support Node.js v4 and above +* Fix padding issues [#2](https://github.com/neocotic/qrious/issues/2) +* Make the QR code center-aligned [#35](https://github.com/neocotic/qrious/pull/35) +* Update [node-canvas](https://github.com/Automattic/node-canvas) dependency version to support [Node.js](https://nodejs.org) v4 and above [#38](https://github.com/neocotic/qrious/pull/38) ## Version 1.1.3, 2014.09.01 -* [#23](https://github.com/neocotic/qr.js/issues/23): Revert back to [GPL License][] +* Revert back to [GPL License](http://www.gnu.org/licenses/) [#23](https://github.com/neocotic/qrious/issues/23) ## Version 1.1.2, 2014.04.27 -* [#20](https://github.com/neocotic/qr.js/issues/20): Fix "too many open files" bug +* Fix "too many open files" bug [#20](https://github.com/neocotic/qrious/issues/20) ## Version 1.1.1, 2013.12.03 @@ -18,43 +33,35 @@ ## Version 1.1.0, 2013.12.02 -* [#9](https://github.com/neocotic/qr.js/issues/9): Fix RequireJS support -* [#13](https://github.com/neocotic/qr.js/issues/13): Remove [Ender][] support -* [#14](https://github.com/neocotic/qr.js/issues/14): Improve code formatting and style -* [#16](https://github.com/neocotic/qr.js/issues/16): Support different MIME types for `toDataURL` and other related functions -* [#17](https://github.com/neocotic/qr.js/issues/17): Remove unnecessary callback arguments from synchronous functions -* [#17](https://github.com/neocotic/qr.js/issues/17): Make `save` fully asynchronous -* [#17](https://github.com/neocotic/qr.js/issues/17): Add `saveSync` for synchronous saving -* [#18](https://github.com/neocotic/qr.js/issues/18): Add [Grunt][] build system -* [#18](https://github.com/neocotic/qr.js/issues/18): Generate source map as part of build -* [#18](https://github.com/neocotic/qr.js/issues/18): Improve developer documentation -* [#19](https://github.com/neocotic/qr.js/issues/19): Add support for [Bower][] +* Fix [RequireJS](http://requirejs.org) support [#9](https://github.com/neocotic/qrious/issues/9) +* Remove [Ender](http://enderjs.com) support [#13](https://github.com/neocotic/qrious/issues/13) +* Improve code formatting and style [#14](https://github.com/neocotic/qrious/issues/14) +* Support different MIME types for `toDataURL` and other related functions [#16](https://github.com/neocotic/qrious/issues/16) +* Remove unnecessary callback arguments from synchronous functions [#17](https://github.com/neocotic/qrious/issues/17) +* Make `save` fully asynchronous [#17](https://github.com/neocotic/qrious/issues/17) +* Add `saveSync` for synchronous saving [#17](https://github.com/neocotic/qrious/issues/17) +* Add [Grunt](http://gruntjs.com) build system [#18](https://github.com/neocotic/qrious/issues/18) +* Generate source map as part of build [#18](https://github.com/neocotic/qrious/issues/18) +* Improve developer documentation [#18](https://github.com/neocotic/qrious/issues/18) +* Add support for [Bower](https://bower.io) [#19](https://github.com/neocotic/qrious/issues/19) * Many small fixes and tweaks ## Version 1.0.3, 2011.12.19 -* [#3](https://github.com/neocotic/qr.js/issues/3): Rename `QRCode` to `qr` -* [#3](https://github.com/neocotic/qr.js/issues/3): Remove all deprecated methods -* [#4](https://github.com/neocotic/qr.js/issues/4): Reformat code and add additional, along with some original, code comments -* [#6](https://github.com/neocotic/qr.js/issues/6): Add support for [Node.js][], [CommonJS][] and [Ender][] -* [#6](https://github.com/neocotic/qr.js/issues/6): Add optional `callback` functionality to API methods -* [#7](https://github.com/neocotic/qr.js/issues/7): Allow `data` arguments to be an object or string value -* [#8](https://github.com/neocotic/qr.js/issues/8): Add `VERSION` property to the API -* [#8](https://github.com/neocotic/qr.js/issues/8): Add `toDataURL`, `save` and `noConflict` methods to the API -* Now distributed under the [MIT License][] +* Rename `QRCode` to `qr` [#3](https://github.com/neocotic/qrious/issues/3) +* Remove all deprecated methods [#3](https://github.com/neocotic/qrious/issues/3) +* Reformat code and add additional, along with some original, code comments [#4](https://github.com/neocotic/qrious/issues/4) +* Add support for [Node.js](https://nodejs.org), [CommonJS](http://www.commonjs.org) and [Ender](http://enderjs.com) [#6](https://github.com/neocotic/qrious/issues/6) +* Add optional `callback` functionality to API methods [#6](https://github.com/neocotic/qrious/issues/6) +* Allow `data` arguments to be an object or string value [#7](https://github.com/neocotic/qrious/issues/7) +* Add `VERSION` property to the API [#8](https://github.com/neocotic/qrious/issues/8) +* Add `toDataURL`, `save` and `noConflict` methods to the API [#8](https://github.com/neocotic/qrious/issues/8) +* Now distributed under the MIT license ## Version 1.0.2, 2011.08.31 -* [#1](https://github.com/neocotic/qr.js/issues/1): Deprecate `generateCanvas` and `generateImage` and replaced with `canvas` and `image` respectively +* Deprecate `generateCanvas` and `generateImage` and replaced with `canvas` and `image` respectively [#1](https://github.com/neocotic/qrious/issues/1) ## Version 1.0.1, 2011.08.12 * Allow customisation of colours used when rendering - -[bower]: http://bower.io -[commonjs]: http://commonjs.org -[ender]: http://ender.no.de -[gpl license]: http://www.gnu.org/licenses/ -[grunt]: http://gruntjs.com -[mit license]: http://en.wikipedia.org/wiki/MIT_License -[node.js]: http://nodejs.org diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index de239d8..ef2b8a5 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,59 +1,29 @@ # Contributing -Here are some guidelines that we'd like contributors to follow so that we can have a chance of -keeping things right. - -## Getting Starting - -* Make sure you have a [GitHub account](https://github.com/signup/free) -* Submit a ticket for your issue if one does not already exist - * Clearly describe the issue including steps to reproduce when it is a bug - * Include the earliest version that you know has the issue -* Fork the repository on GitHub -* Read the `INSTALL.md` file - -## Making Changes - -* Create a topic branch from where you want to base your work - * This is usually the master branch - * Only target release branches if you are certain your fix must be on that branch - * To quickly create a topic branch based on master; - `git branch fix/master/my_contribution master` then checkout the new branch with - `git checkout fix/master/my_contribution` - * Avoid working directly on the `master` branch -* Make commits of logical units -* Check for unnecessary whitespace with `git diff --check` before committing -* Make sure your commit messages are in the proper format -* Avoid updating the distributable file or annotated source code documentation +If you have any questions about [QRious](https://github.com/neocotic/qrious) please feel free to +[raise an issue](https://github.com/neocotic/qrious/issues/new). -``` -(#99999) Make the example in CONTRIBUTING imperative and concrete +Please [search existing issues](https://github.com/neocotic/qrious/issues) for the same feature and/or issue before +raising a new issue. Commenting on an existing issue is usually preferred over raising duplicate issues. -Without this patch applied the example commit message in the CONTRIBUTING document is not a -concrete example. This is a problem because the contributor is left to imagine what the commit -message should look like based on a description rather than an example. This patch fixes the -problem by making the example concrete and imperative. +Please ensure that all files conform to the coding standards, using the same coding style as the rest of the code base. +This can be done easily via command-line: -The first line is a real life imperative statement with a ticket number from our issue tracker. The -body describes the behavior without the patch, why this is a problem, and how the patch fixes the -problem when applied. +``` bash +# install/update package dependencies +$ npm install +# run test suite +$ npm test ``` -* Make sure you have added the necessary tests for your changes -* Run *all* the tests to assure nothing else was accidentally broken - -## Submitting Changes +Feel free to make use of the `demo.html` to test your changes locally before committing and rebuild the distribution +files. This can be done using the following command: -* Ensure you added your details to `AUTHORS.md` in the correct format - `Joe Bloggs ` -* Push your changes to a topic branch in your fork of the repository -* Submit a pull request to neocotic's repository -* Update your issue to mark that you have submitted code and are ready for it to be reviewed - * Include a link to the pull request in the issue +``` bash +$ npm run build +``` -# Additional Resources +All pull requests should be made to the `develop` branch. -* [qr.js repository](https://github.com/neocotic/qr.js) -* [Issue tracker](https://github.com/neocotic/qr.js/issues) -* [General GitHub documentation](http://help.github.com) -* [GitHub pull request documentation](http://help.github.com/send-pull-requests) +Don't forget to add your details to the list of [AUTHORS.md](https://github.com/neocotic/qrious/blob/master/AUTHORS.md) +if you want your contribution to be recognized by others. diff --git a/Gruntfile.js b/Gruntfile.js index bb87b6d..d66f240 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -1,63 +1,162 @@ -module.exports = function(grunt) { +/* + * QRious + * Copyright (C) 2016 Alasdair Mercer + * Copyright (C) 2010 Tom Zerucha + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ - 'use strict'; +module.exports = function(grunt) { + var babel = require('rollup-plugin-babel') + var nodeResolve = require('rollup-plugin-node-resolve') + var uglify = require('rollup-plugin-uglify') - // Configuration - // ------------- + var bannerLarge = [ + '/*', + ' * QRious v<%= pkg.version %>', + ' * Copyright (C) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>', + ' * Copyright (C) 2010 Tom Zerucha', + ' *', + ' * This program is free software: you can redistribute it and/or modify', + ' * it under the terms of the GNU General Public License as published by', + ' * the Free Software Foundation, either version 3 of the License, or', + ' * (at your option) any later version.', + ' *', + ' * This program is distributed in the hope that it will be useful,', + ' * but WITHOUT ANY WARRANTY; without even the implied warranty of', + ' * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the', + ' * GNU General Public License for more details.', + ' *', + ' * You should have received a copy of the GNU General Public License', + ' * along with this program. If not, see .', + ' */' + ].join('\n') + var bannerSmall = [ + '/*! QRious v<%= pkg.version %> | (C) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %> | GPL v3 License', + 'Based on jsqrencode | (C) 2010 tz@execpc.com | GPL v3 License', + '*/' + ].join('\n') grunt.initConfig({ - pkg: grunt.file.readJSON('package.json'), - docco: { - all: { - options: { - output: 'docs' - }, - src: 'qr.js' - } + clean: { + build: [ 'dist' ] }, - jshint: { - all: [ - 'Gruntfile.js', - 'qr.js' - ], - options: { - jshintrc: '.jshintrc' - } + eslint: { + target: [ 'src/**/*.js' ] }, - uglify: { - all: { + rollup: { + cjs: { + options: { + format: 'cjs', + sourceMap: true, + sourceMapRelativePaths: true, + banner: bannerLarge, + plugins: function() { + return [ + babel({ + exclude: './node_modules/**', + presets: [ 'es2015-rollup' ], + babelrc: false + }), + nodeResolve({ + browser: true, + jsnext: true, + skip: [ 'canvas' ] + }) + ] + } + }, files: { - 'qr.min.js': 'qr.js' + 'dist/cjs/qrious.js': 'src/runtime/node.js' + } + }, + umdDevelopment: { + options: { + format: 'umd', + moduleId: 'qrious', + moduleName: 'QRious', + sourceMap: true, + sourceMapRelativePaths: true, + banner: bannerLarge, + plugins: function() { + return [ + babel({ + exclude: './node_modules/**', + presets: [ 'es2015-rollup' ], + babelrc: false + }), + nodeResolve({ + main: true, + jsnext: true + }) + ] + } }, + files: { + 'dist/umd/qrious.js': 'src/runtime/browser.js' + } + }, + umdProduction: { options: { - banner: ( - '/*! <%= pkg.name %> v<%= pkg.version %> | (c) <%= grunt.template.today("yyyy") %>' + - ' <%= pkg.author.name %> | GPL v3 License\n' + - 'jsqrencode | (c) 2010 tz@execpc.com | GPL v3 License\n' + - '*/' - ), - report: 'min', + format: 'umd', + moduleId: 'qrious', + moduleName: 'QRious', sourceMap: true, - sourceMapName: 'qr.min.map' + sourceMapRelativePaths: true, + banner: bannerSmall, + plugins: function() { + return [ + babel({ + exclude: './node_modules/**', + presets: [ 'es2015-rollup' ], + babelrc: false + }), + nodeResolve({ + browser: true, + jsnext: true + }), + uglify({ + output: { + comments: function(node, comment) { + return comment.type === 'comment2' && /^\!/.test(comment.value) + } + } + }) + ] + } + }, + files: { + 'dist/umd/qrious.min.js': 'src/runtime/browser.js' } } - } - - }); - - // Tasks - // ----- + }, - grunt.loadNpmTasks('grunt-contrib-jshint'); - grunt.loadNpmTasks('grunt-contrib-uglify'); - grunt.loadNpmTasks('grunt-docco'); + watch: { + all: { + files: [ 'src/**/*.js' ], + tasks: [ 'build' ] + } + } + }) - grunt.registerTask('default', [ 'test' ]); - grunt.registerTask('dist', [ 'test', 'uglify', 'docco' ]); - grunt.registerTask('test', [ 'jshint' ]); + require('load-grunt-tasks')(grunt) -}; + grunt.registerTask('default', [ 'build' ]) + grunt.registerTask('build', [ 'eslint', 'clean', 'rollup' ]) + grunt.registerTask('test', [ 'eslint' ]) +} diff --git a/INSTALL.md b/INSTALL.md deleted file mode 100644 index d793d2b..0000000 --- a/INSTALL.md +++ /dev/null @@ -1,46 +0,0 @@ -This document is only relevant for those that want to contribute to the [qr.js][] open source -project (we love you guys!). If you are only interested in installing the tool look at `README.md`. - -## Build Requirements - -In order to build [qr.js][], you need to have the following install [git][] 1.7+ and [node.js][] -0.8+ (which includes [npm][]). - -### Canvas Support - -[qr.js][] heavily depends on [node-canvas][] to support the HTML5 canvas element in the [node.js][] -environment. Unfortunately, this library is dependant on [Cairo][], which is not managed by -[npm][]. Before you are able to build [qr.js][] (and it's dependencies), you must have [Cairo][] -installed. Please see their wiki on steps on how to do this on various platforms: - -https://github.com/LearnBoost/node-canvas/wiki/_pages - -## Building - -Follow these steps to build [qr.js][]; - -1. Clone a copy of the main [qr.js git repository](https://github.com/neocotic/qr.js) by running - `git clone git://github.com/neocotic/qr.js.git` -2. `cd` to the repository directory -3. Ensure you have all of the dependencies by entering `npm install` -4. Ensure you can run [Grunt][] by running `npm install -g grunt-cli` -5. To run the full test suite enter `grunt test` - * **Pro Tip:** You can easily run step 5 by just entering `grunt` -6. To update the optimized distributable file and documentation enter `grunt dist` - * Outputs to documentation to the `docs` directory - -## Important - -If you're planning on contributing to [qr.js][] please do **NOT** update the distributable file or -documentation (step 6) when submitting a pull request. We will not accept pull requests when these -files have been changed as we do this ourselves when finalizing a release. - -Read the `CONTRIBUTING.md` file for more information about submitting pull requests. - -[cairo]: http://cairographics.org -[git]: http://git-scm.com -[grunt]: http://gruntjs.com -[node.js]: http://nodejs.org -[node-canvas]: https://github.com/LearnBoost/node-canvas -[npm]: http://npmjs.org -[qr.js]: http://neocotic.com/qr.js diff --git a/LICENSE.md b/LICENSE.md index dec605d..7ac3863 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,4 +1,6 @@ -Copyright (C) 2015 Alasdair Mercer, http://neocotic.com +QRious +Copyright (C) 2016 Alasdair Mercer +Copyright (C) 2010 Tom Zerucha This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -7,8 +9,8 @@ the Free Software Foundation, either version 3 of the License, or This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License -along with this program. If not, see . +along with this program. If not, see . diff --git a/README.md b/README.md index 74ec9a1..3f2c226 100644 --- a/README.md +++ b/README.md @@ -1,30 +1,61 @@ - __ - __ _ __ /\_\ ____ - /'__`\/\`'__\ \/\ \ /',__\ - /\ \L\ \ \ \/__ \ \ \/\__, `\ - \ \___, \ \_\\_\_\ \ \/\____/ - \/___/\ \/_//_/\ \_\ \/___/ - \ \_\ \ \____/ - \/_/ \/___/ - -[qr.js][] is a pure JavaScript library for [QR code][] generation using canvas. + .oooooo. ooooooooo. o8o + d8P' `Y8b `888 `Y88. `"' + 888 888 888 .d88' oooo .ooooo. oooo oooo .oooo.o + 888 888 888ooo88P' `888 d88' `88b `888 `888 d88( "8 + 888 888 888`88b. 888 888 888 888 888 `"Y88b. + `88b d88b 888 `88b. 888 888 888 888 888 o. )88b + `Y8bood8P'Ybd' o888o o888o o888o `Y8bod8P' `V88V"V8P' 8""888P' + +[QRious](https://github.com/neocotic/qrious) is a pure JavaScript library for generating QR codes using HTML5 canvas. + +[![Build Status](https://img.shields.io/travis/neocotic/qrious/develop.svg?style=flat-square)](https://travis-ci.org/neocotic/qrious) +[![Dependency Status](https://img.shields.io/david/neocotic/qrious.svg?style=flat-square)](https://david-dm.org/neocotic/qrious) +[![Dev Dependency Status](https://img.shields.io/david/dev/neocotic/qrious.svg?style=flat-square)](https://david-dm.org/neocotic/qrious#info=devDependencies) +[![License](https://img.shields.io/npm/l/qrious.svg?style=flat-square)](https://github.com/neocotic/qrious/blob/master/LICENSE.md) +[![Release](https://img.shields.io/npm/v/qrious.svg?style=flat-square)](https://www.npmjs.com/package/qrious) * [Install](#install) * [Examples](#examples) * [API](#api) -* [Canvas Support](#canvas-support) +* [Migrating from v1](#migrating-from-v1) * [Bugs](#bugs) -* [Questions](#questions) +* [Contributors](#contributors) +* [License](#license) ## Install Install using the package manager for your desired environment(s): ``` bash -# for node.js: -$ npm install qr-js -# OR; for the browser: -$ bower install qr-js +$ npm install --save qrious +# OR: +$ bower install --save qrious +``` + +You'll need to have at least [Node.js](https://nodejs.org) installed and you'll only need [Bower](https://bower.io) if +you want to install that way instead of using `npm`. + +If you want to simply download the file to be used in the browser you can find them below: + +* [Development Version](https://github.com/neocotic/qrious/blob/master/dist/umd/qrious.js) +* [Production Version](https://github.com/neocotic/qrious/blob/master/dist/umd/qrious.min.js) + +### Node.js Dependencies + +If you plan on using QRious in the browser then you're good to go! + +However, if you plan on using it on a server using Node.js, then you'll find that QRious depends heavily on [node-canvas](https://github.com/Automattic/node-canvas) +to provide HTML5 canvas support, however, since his library is entirely dependant on [Cairo](http://cairographics.org) +being installed as an external dependency, QRious only has this marked as an `optionalDependency`. That said; it won't +work without it on Node.js. Sorry. Please see their wiki on steps on how to do this on various platforms: + +https://github.com/LearnBoost/node-canvas/wiki/_pages + +If you are planning on installing QRious through `npm` for use in the browser, then you can avoid unnecessarily +installing the `canvas` dependency by using the following: + +``` bash +$ npm install --save --no-optional qrious ``` ## Examples @@ -32,259 +63,156 @@ $ bower install qr-js In the browser: ``` html + - - + + + ``` -In [node.js][]: +In Node.js: ``` javascript -var qr = require('qr-js'); +const express = require('express') +const QRious = require('qrious') + +const app = express() -qr.saveSync('http://neocotic.com/qr.js', 'qrcode.png'); +app.get('/qr', (req, res) => { + const qr = new QRious({ value: 'https://github.com/neocotic/qrious' }) + + res.end(new Buffer(qr.toDataURL(), 'base64')) +}) + +app.listen(3000) ``` +Open up `demo.html` in your browser to play around a bit. + ## API -### Standard Data - -The following configuration data options are recognised by all of the core API methods (all of -which are optional): - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PropertyDescriptionDefault
backgroundBackground colour to be used#fff
canvas<canvas> element in which the QR code should be renderedCreates a new element
foregroundForeground colour to be used#000
levelECC (error correction capacity) level to be appliedL
sizeModule size of the generated QR code4
valueValue to be encoded in the generated QR code""
- -### `canvas([data|value])` -Renders a QR code in an HTML5 `` element for a given value. +Simply create an instance of `QRious` and you've done most of the work. You can control many aspects of the QR code +using the following fields on your instance: + +| Field | Type | Description | Default | +| ---------- | ------ | -------------------------------------------------- | ------------- | +| background | String | Background color of the QR code | `"white"` | +| foreground | String | Foreground color of the QR code | `"black"` | +| level | String | Error correction level of the QR code (L, M, Q, H) | `"L"` | +| mime | String | MIME type used to render the image for the QR code | `"image/png"` | +| size | Number | Size of the QR code (pixels) | `100` | +| value | String | Value encoded within the QR code | `""` | ``` javascript -// Render the QR code on a newly created canvas element -var canvas = qr.canvas('http://neocotic.com/qr.js'); -// Re-render the QR code on an existing element -qr.canvas({ - canvas: canvas, - value: 'https://github.com/neocotic/qr.js' -}); +const qr = new QRious() +qr.background = '#000' +qr.foreground = '#fff' +qr.level = 'H' +qr.size = 500 +qr.value = 'https://github.com/neocotic/qrious' ``` -### `image([data|value])` -Renders a QR code in an HTML `` element for a given value. +These can also be passed as options to the constructor itself: ``` javascript -// Render the QR code on a newly created img element -var img = qr.image('http://neocotic.com/qr.js'); -// Re-render the QR code on an existing element -qr.image({ - image: img, - value: 'https://github.com/neocotic/qr.js' -}); +const qr = new QRious({ + background: '#000', + foreground: '#fff', + level: 'H', + size: 500, + value: 'https://github.com/neocotic/qrious' +}) ``` -#### Additional Data -As well as the [Standard Data](#standard-data), this method also accepts the following additional -data options: - - - - - - - - - - - - - - - - - -
PropertyDescriptionDefault
image<img> element in which the QR code should be renderedCreates a new element
mimeMIME type to process the QR code imageimage/png
- -### `save([data|value][, path], callback)` -Saves a QR code, which has been rendered for a given value, to the user's file system. +You can also pass in an `element` option to the constructor which can be used to generate the QR code using an existing +DOM element. `element` must either be a `` element or an `` element which can then be accessed via the +`canvas` or `image` fields on the instance respectively. An element will be created for whichever one isn't provided or +for both if no `element` is specified, which means that they can be appeneded to the document at a later time. ``` javascript -// Render a QR code to a PNG file -qr.save('http://neocotic.com/qr.js', 'qr.png', function(err) { - if (err) throw err; - - // ... -}); -// Render a QR code to a JPEG file -qr.save({ - mime: 'image/jpeg', - path: 'qr.jpg', - value: 'https://github.com/neocotic/qr.js' -}, function(err) { - if (err) throw err; - - // ... -}); +const qr = new QRious({ + element: document.querySelector('canvas'), + value: 'https://github.com/neocotic/qrious' +}) + +qr.canvas.parentNode.appendChild(qr.image) ``` -**Note:** Currently, in the browser, this just does it's best to force a download prompt. We will -try to improve on this in the future. - -#### Additional Data -As well as the [Standard Data](#standard-data), this method also accepts the following additional -data options: - - - - - - - - - - - - - - - - - -
PropertyDescriptionDefault
mimeMIME type to process the QR code imageimage/png
pathPath to which the QR code should be saved
Ignored in browsers
Required if not specified as an argument
- -### `saveSync([data|value][, path])` -Synchronous [`save(3)`](#savedatavalue-path-callback). - -### `toDataURL([data|value])` -Returns a data URL for rendered QR code. This is a convenient shorthand for dealing with the native -`HTMLCanvasElement.prototype.toDataURL` function. +A reference to the `QRious` instance is also stored on both of the elements for convenience. ``` javascript -console.log(qr.toDataURL('http://neocotic.com/qr.js')); // "data:image/png;base64,iVBORw0KGgoAAAA..." -console.log(qr.toDataURL({ - mime: 'image/jpeg', - value: 'https://github.com/neocotic/qr.js' -})); // "data:image/jpeg;base64,/9j/4AAQSkZJRg..." +const canvas = document.querySelector('canvas') +const qr = new QRious({ + element: canvas, + value: 'https://github.com/neocotic/qrious' +}) + +console.log(qr === canvas.qrious) +//=> true ``` -#### Additional Data -As well as the [Standard Data](#standard-data), this method also accepts the following additional -data options: - - - - - - - - - - - - -
PropertyDescriptionDefault
mimeMIME type to process the QR code imageimage/png
- -### Miscellaneous +### `toDataURL([mime])` -#### `noConflict()` -Returns `qr` in a no-conflict state, reallocating the `qr` global variable name to its previous -owner, where possible. +Generates a base64 encoded data URI for the QR code. If you don't specify a MIME type, it will default to the one +passed to the constructor as an option or the default value for the `mime` option. -This is really just intended for use within a browser. - -``` html - - - +``` javascript +const qr = new QRious({ + value: 'https://github.com/neocotic/qrious' +}) + +console.log(qr.toDataURL()) +//=> "data:image/png;base64,iVBOR...AIpqDnseH86KAAAAAElFTkSuQmCC" +console.log(qr.toDataURL('image/jpeg')) +//=> "data:image/jpeg;base64,/9j/...xqAqIqgKFAAAAAq3RRQAUUUUAf/Z" ``` -#### `VERSION` -The current version of `qr`. +### `VERSION` + +The current version of `QRious`. ``` javascript -console.log(qr.VERSION); // "1.1.4" +console.log(QRious.VERSION) +//=> "2.0.0" ``` -## Canvas Support +## Migrating from v1 -For browser users; their browser must support the HTML5 canvas element or the API will throw an -error immediately. +If you've been using v1 (`qr`) then you can find details about what's changed and a guide on how to migrate to v2 +(`Qrious`) below: -For [node.js][] users; [qr.js][] heavily depends on [node-canvas][] to support the HTML5 canvas -element in the [node.js][] environment. Unfortunately, this library is dependant on [Cairo][], -which is not managed by [npm][]. Before you are able to install [qr.js][] (and it's dependencies), -you must have [Cairo][] installed. Please see their wiki on steps on how to do this on various -platforms: +https://github.com/neocotic/qrious/wiki/Migrating-from-v1 -https://github.com/LearnBoost/node-canvas/wiki/_pages +You can also find the code and documentation for the v1 below: -## Bugs +https://github.com/neocotic/qrious/tree/1.1.4 -If you have any problems with this library or would like to see the changes currently in -development you can do so here; +## Bugs -https://github.com/neocotic/qr.js/issues +If you have any problems with QRious or would like to see changes currently in development you can do so +[here](https://github.com/neocotic/qrious/issues). -## Questions? +## Contributors -Take a look at `docs/qr.html` to get a better understanding of what the code is doing. +If you want to contribute, you're a legend! Information on how you can do so can be found in +[CONTRIBUTING.md](https://github.com/neocotic/qrious/blob/master/CONTRIBUTING.md). We want your suggestions and pull +requests! -If that doesn't help, feel free to follow me on Twitter, [@neocotic][]. +A list of QRious contributors can be found in [AUTHORS.md](https://github.com/neocotic/qrious/blob/master/AUTHORS.md). -However, if you want more information or examples of using this library please visit the project's -homepage; +## License -http://neocotic.com/qr.js +Copyright (c) 2016 Alasdair Mercer -[@neocotic]: https://twitter.com/neocotic -[cairo]: http://cairographics.org -[node.js]: http://nodejs.org -[node-canvas]: https://github.com/LearnBoost/node-canvas -[npm]: http://npmjs.org -[qr.js]: http://neocotic.com/qr.js -[qr code]: http://en.wikipedia.org/wiki/QR_code +See [LICENSE.md](https://github.com/neocotic/qrious/blob/master/LICENSE.md) for more information on our MIT license. diff --git a/bower.json b/bower.json index 60ed237..e3f9488 100644 --- a/bower.json +++ b/bower.json @@ -1,8 +1,8 @@ { - "name": "qr-js", - "version": "1.1.4", + "name": "qrious", + "version": "2.0.0", "description": "Library for QR code generation using canvas", - "homepage": "http://neocotic.com/qr.js", + "homepage": "https://github.com/neocotic/qrious", "authors": [ { "name": "Alasdair Mercer", @@ -20,19 +20,18 @@ ], "repository": { "type": "git", - "url": "https://github.com/neocotic/qr.js.git" + "url": "https://github.com/neocotic/qrious.git" }, - "main": "qr.min.js", + "main": "dist/umd/qrious.js", "ignore": [ - "**/.*", - "docs", + "src/", + ".*", "AUTHORS.md", "CHANGES.md", "CONTRIBUTING.md", + "demo.html", "Gruntfile.js", - "INSTALL.md", - "README.md", - "bower.json", - "package.json" + "package.json", + "README.md" ] } diff --git a/demo.html b/demo.html new file mode 100644 index 0000000..576807a --- /dev/null +++ b/demo.html @@ -0,0 +1,175 @@ + + + + + + + + + QRious Demo + + + + +
+
+ + +
+ + + + + + + + + +
+
+
+ + + + + diff --git a/dist/cjs/qrious.js b/dist/cjs/qrious.js new file mode 100644 index 0000000..7e9153f --- /dev/null +++ b/dist/cjs/qrious.js @@ -0,0 +1,2172 @@ +/* + * QRious v2.0.0 + * Copyright (C) 2016 Alasdair Mercer + * Copyright (C) 2010 Tom Zerucha + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +'use strict'; + +function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } + +var Canvas = require('canvas'); +var Canvas__default = _interopDefault(Canvas); + +var classCallCheck = function (instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } +}; + +var createClass = function () { + function defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + if ("value" in descriptor) descriptor.writable = true; + Object.defineProperty(target, descriptor.key, descriptor); + } + } + + return function (Constructor, protoProps, staticProps) { + if (protoProps) defineProperties(Constructor.prototype, protoProps); + if (staticProps) defineProperties(Constructor, staticProps); + return Constructor; + }; +}(); + +var inherits = function (subClass, superClass) { + if (typeof superClass !== "function" && superClass !== null) { + throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); + } + + subClass.prototype = Object.create(superClass && superClass.prototype, { + constructor: { + value: subClass, + enumerable: false, + writable: true, + configurable: true + } + }); + if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; +}; + +var possibleConstructorReturn = function (self, call) { + if (!self) { + throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + } + + return call && (typeof call === "object" || typeof call === "function") ? call : self; +}; + +/* + * QRious + * Copyright (C) 2016 Alasdair Mercer + * Copyright (C) 2010 Tom Zerucha + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * Contains utility methods that are useful throughout the library. + * + * @public + */ + +var Utilities = function () { + function Utilities() { + classCallCheck(this, Utilities); + } + + createClass(Utilities, null, [{ + key: 'privatize', + + + /** + * Copies all properties from the source object to the target object, however, all property + * names on the target will be prefixed with an underscore, used to indicate that they are private. + * + * @param {Object} target - the object to which the private fields are to be copied + * @param {Object} source - the object from which the fields are to be copied + * @return {Object} A reference to the target object. + * @public + * @static + */ + value: function privatize(target, source) { + for (var key in source) { + if (source.hasOwnProperty(key)) { + target['_' + key] = source[key]; + } + } + + return target; + } + + /** + * Sets the specified value on a given field on the object provided. + * + * If value is null, the specified default value will be used instead. + * + * An optional transformer can be specified which will be used to transform the value (or default value) + * before it is assigned to the field. + * + * @param {Object} object - the object whose field is to be set with value + * @param {String} fieldName - the field to be set with value + * @param {*} value - the value to be set on the named field + * @param {*} [defaultValue] - the value to be used if value is null + * @param {Function} [transformer] - a function used to transform the value before it is assigned to the named field + * @return {Boolean} true if the value of the field has changed as a result of the assignment; otherwise + * false. + * @public + * @static + */ + + }, { + key: 'setter', + value: function setter(object, fieldName, value, defaultValue, transformer) { + var oldValue = object[fieldName]; + var newValue = value != null ? value : defaultValue; + if (typeof transformer === 'function') { + newValue = transformer(newValue); + } + + object[fieldName] = newValue; + + return newValue !== oldValue; + } + + /** + * Throws an error indicating that the a given method on a specific class has not been implemented. + * + * @param {String} className - the name of the class on which the method has not been implemented + * @param {String} methodName - the name of the method which has not been implemented + * @throws {Error} The error describing the class method which has not been implemented. + * @public + * @static + */ + + }, { + key: 'throwUnimplemented', + value: function throwUnimplemented(className, methodName) { + throw new Error('"' + methodName + '" method must be implemented on the ' + className + ' class'); + } + + /** + * Transforms the specified string to upper case while remaining null-safe. + * + * @param {String} string - the string to be transformed to upper case + * @return {String} string transformed to upper case if string is not null. + * @public + * @static + */ + + }, { + key: 'toUpperCase', + value: function toUpperCase(string) { + return string != null && string.toUpperCase(); + } + }]); + return Utilities; +}(); + +/** + * Defines a service contract that must be met by all implementations. + * + * @public + */ + +var Service = function () { + function Service() { + classCallCheck(this, Service); + } + + createClass(Service, [{ + key: 'getName', + + + /** + * Returns the name of this {@link Service}. + * + * @return {String} The service name. + * @public + */ + value: function getName() { + Utilities.throwUnimplemented('Service', 'getName'); + } + }]); + return Service; +}(); + +/** + * A service for working with elements. + * + * @public + * @extends Service + */ + +var ElementService = function (_Service) { + inherits(ElementService, _Service); + + function ElementService() { + classCallCheck(this, ElementService); + return possibleConstructorReturn(this, Object.getPrototypeOf(ElementService).apply(this, arguments)); + } + + createClass(ElementService, [{ + key: 'createCanvas', + + + /** + * Creates an instance of a canvas element. + * + * @return {*} The newly created canvas element. + * @public + */ + value: function createCanvas() { + Utilities.throwUnimplemented('ElementService', 'createCanvas'); + } + + /** + * Creates an instance of a image element. + * + * @return {*} The newly created image element. + * @public + */ + + }, { + key: 'createImage', + value: function createImage() { + Utilities.throwUnimplemented('ElementService', 'createImage'); + } + + /** + * @override + */ + + }, { + key: 'getName', + value: function getName() { + return 'element'; + } + + /** + * Returns whether the specified element is a canvas. + * + * @param {*} element - the element to be checked + * @return {Boolean} true if element is a canvas; otherwise false. + * @public + */ + + }, { + key: 'isCanvas', + value: function isCanvas(element) { + Utilities.throwUnimplemented('ElementService', 'isCanvas'); + } + + /** + * Returns whether the specified element is an image. + * + * @param {*} element - the element to be checked + * @return {Boolean} true if element is an image; otherwise false. + * @public + */ + + }, { + key: 'isImage', + value: function isImage(element) { + Utilities.throwUnimplemented('ElementService', 'isImage'); + } + }]); + return ElementService; +}(Service); + +/** + * An implementation of {@link ElementService} intended for use within a Node.js environment but is only supported when + * the canvas module has also been depended on. + * + * @public + * @extends ElementService + */ + +var NodeElementService = function (_ElementService) { + inherits(NodeElementService, _ElementService); + + function NodeElementService() { + classCallCheck(this, NodeElementService); + return possibleConstructorReturn(this, Object.getPrototypeOf(NodeElementService).apply(this, arguments)); + } + + createClass(NodeElementService, [{ + key: 'createCanvas', + + + /** + * @override + */ + value: function createCanvas() { + return new Canvas__default(); + } + + /** + * @override + */ + + }, { + key: 'createImage', + value: function createImage() { + return new Canvas.Image(); + } + + /** + * @override + */ + + }, { + key: 'isCanvas', + value: function isCanvas(element) { + return element instanceof Canvas__default; + } + + /** + * @override + */ + + }, { + key: 'isImage', + value: function isImage(element) { + return element instanceof Canvas.Image; + } + }], [{ + key: 'isSupported', + + + /** + * @override + */ + value: function isSupported() { + return Canvas__default != null; + } + }]); + return NodeElementService; +}(ElementService); + +/** + * Responsible for rendering a QR code {@link Frame} on a specific type of element. + * + * A renderer may be dependant on the rendering of another element, so ordering of their execution is important. + * + * @public + */ + +var Renderer = function () { + + /** + * Creates a new instance of {@link Renderer} for the qrious instance provided. + * + * @param {QRious} qrious - the {@link QRious} instance to be used + * @public + */ + + function Renderer(qrious) { + classCallCheck(this, Renderer); + + /** + * The {@link QRious} instance. + * + * @protected + * @type {QRious} + */ + this.qrious = qrious; + } + + /** + * Draws the specified QR code frame on the underlying element. + * + * Implementations of {@link Renderer} must override this method with their own specific logic. + * + * @param {Frame} frame - the {@link Frame} to be drawn + * @protected + */ + + + createClass(Renderer, [{ + key: 'draw', + value: function draw(frame) { + Utilities.throwUnimplemented('Renderer', 'draw'); + } + + /** + * Calculates the size (in pixel units) to represent an individual module within the QR code based on the + * frame provided. + * + * The returned value will be at least one, even in cases where the size of the QR code does not fit its contents. + * This is done so that the inevitable clipping is handled more gracefully since this way at least something is + * displayed instead of just a blank space filled by the background color. + * + * @param {Frame} frame - the {@link Frame} from which the module size is to be derived + * @return {Number} The pixel size for each module in the QR code which will be no less than one. + * @protected + */ + + }, { + key: 'getModuleSize', + value: function getModuleSize(frame) { + var pixels = Math.floor(this.qrious.size / frame.width); + + return Math.max(1, pixels); + } + + /** + * Calculates the offset/padding (in pixel units) to be inserted before the QR code based on the frame + * provided. + * + * The returned value will be zero if there is no available offset or if the size of the QR code does not fit its + * contents. It will never be a negative value. This is done so that the inevitable clipping appears more naturally + * and it is not clipped from all directions. + * + * @param {Frame} frame - the {@link Frame} from which the offset is to be derived + * @return {Number} The pixel offset for the QR code which will be no less than zero. + * @protected + */ + + }, { + key: 'getOffset', + value: function getOffset(frame) { + var moduleSize = this.getModuleSize(frame); + var offset = Math.floor((this.qrious.size - moduleSize * frame.width) / 2); + + return Math.max(0, offset); + } + + /** + * Renders a QR code on the underlying element based on the frame provided. + * + * @param {Frame} frame - the {@link Frame} to be rendered + * @public + */ + + }, { + key: 'render', + value: function render(frame) { + this.resize(); + this.reset(); + this.draw(frame); + } + + /** + * Resets the underlying element, effectively clearing any previously rendered QR code. + * + * Implementations of {@link Renderer} must override this method with their own specific logic. + * + * @protected + */ + + }, { + key: 'reset', + value: function reset() { + Utilities.throwUnimplemented('Renderer', 'reset'); + } + + /** + * Ensures that the size of the underlying element matches that defined on the associated {@link QRious} instance. + * + * Implementations of {@link Renderer} must override this method with their own specific logic. + * + * @protected + */ + + }, { + key: 'resize', + value: function resize() { + Utilities.throwUnimplemented('Renderer', 'resize'); + } + }]); + return Renderer; +}(); + +/** + * An implementation of {@link Renderer} for working with canvas elements. + * + * @public + * @extends Renderer + */ + +var CanvasRenderer = function (_Renderer) { + inherits(CanvasRenderer, _Renderer); + + function CanvasRenderer() { + classCallCheck(this, CanvasRenderer); + return possibleConstructorReturn(this, Object.getPrototypeOf(CanvasRenderer).apply(this, arguments)); + } + + createClass(CanvasRenderer, [{ + key: 'draw', + + + /** + * @override + */ + value: function draw(frame) { + var qrious = this.qrious; + var moduleSize = this.getModuleSize(frame); + var offset = this.getOffset(frame); + var context = qrious.canvas.getContext('2d'); + + context.fillStyle = qrious.foreground; + + for (var i = 0; i < frame.width; i++) { + for (var j = 0; j < frame.width; j++) { + if (frame.buffer[j * frame.width + i]) { + context.fillRect(moduleSize * i + offset, moduleSize * j + offset, moduleSize, moduleSize); + } + } + } + } + + /** + * @override + */ + + }, { + key: 'reset', + value: function reset() { + var qrious = this.qrious; + var context = qrious.canvas.getContext('2d'); + + context.lineWidth = 1; + context.clearRect(0, 0, qrious.size, qrious.size); + context.fillStyle = qrious.background; + context.fillRect(0, 0, qrious.size, qrious.size); + } + + /** + * @override + */ + + }, { + key: 'resize', + value: function resize() { + var qrious = this.qrious; + var canvas = qrious.canvas; + + canvas.width = qrious.size; + canvas.height = qrious.size; + } + }]); + return CanvasRenderer; +}(Renderer); + +/* + * QRious + * Copyright (C) 2016 Alasdair Mercer + * Copyright (C) 2010 Tom Zerucha + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* eslint no-multi-spaces: 0 */ + +/** + * Contains alignment pattern information. + * + * @public + */ + +var Alignment = function () { + function Alignment() { + classCallCheck(this, Alignment); + } + + createClass(Alignment, null, [{ + key: "BLOCK", + + + /** + * Returns the alignment pattern block. + * + * @return {Number[]} The alignment pattern block. + * @public + * @static + */ + get: function get() { + return [0, 11, 15, 19, 23, 27, 31, 16, 18, 20, 22, 24, 26, 28, 20, 22, 24, 24, 26, 28, 28, 22, 24, 24, 26, 26, 28, 28, 24, 24, 26, 26, 26, 28, 28, 24, 26, 26, 26, 28, 28]; + } + }]); + return Alignment; +}(); + +/* + * QRious + * Copyright (C) 2016 Alasdair Mercer + * Copyright (C) 2010 Tom Zerucha + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* eslint no-multi-spaces: 0 */ + +/** + * Contains error correction information. + * + * @public + */ + +var ErrorCorrection = function () { + function ErrorCorrection() { + classCallCheck(this, ErrorCorrection); + } + + createClass(ErrorCorrection, null, [{ + key: "BLOCKS", + + + /** + * Returns the error correction blocks. + * + * There are four elements per version. The first two indicate the number of blocks, then the data width, and finally + * the ECC width. + * + * @return {Number[]} The ECC blocks. + * @public + * @static + */ + get: function get() { + return [1, 0, 19, 7, 1, 0, 16, 10, 1, 0, 13, 13, 1, 0, 9, 17, 1, 0, 34, 10, 1, 0, 28, 16, 1, 0, 22, 22, 1, 0, 16, 28, 1, 0, 55, 15, 1, 0, 44, 26, 2, 0, 17, 18, 2, 0, 13, 22, 1, 0, 80, 20, 2, 0, 32, 18, 2, 0, 24, 26, 4, 0, 9, 16, 1, 0, 108, 26, 2, 0, 43, 24, 2, 2, 15, 18, 2, 2, 11, 22, 2, 0, 68, 18, 4, 0, 27, 16, 4, 0, 19, 24, 4, 0, 15, 28, 2, 0, 78, 20, 4, 0, 31, 18, 2, 4, 14, 18, 4, 1, 13, 26, 2, 0, 97, 24, 2, 2, 38, 22, 4, 2, 18, 22, 4, 2, 14, 26, 2, 0, 116, 30, 3, 2, 36, 22, 4, 4, 16, 20, 4, 4, 12, 24, 2, 2, 68, 18, 4, 1, 43, 26, 6, 2, 19, 24, 6, 2, 15, 28, 4, 0, 81, 20, 1, 4, 50, 30, 4, 4, 22, 28, 3, 8, 12, 24, 2, 2, 92, 24, 6, 2, 36, 22, 4, 6, 20, 26, 7, 4, 14, 28, 4, 0, 107, 26, 8, 1, 37, 22, 8, 4, 20, 24, 12, 4, 11, 22, 3, 1, 115, 30, 4, 5, 40, 24, 11, 5, 16, 20, 11, 5, 12, 24, 5, 1, 87, 22, 5, 5, 41, 24, 5, 7, 24, 30, 11, 7, 12, 24, 5, 1, 98, 24, 7, 3, 45, 28, 15, 2, 19, 24, 3, 13, 15, 30, 1, 5, 107, 28, 10, 1, 46, 28, 1, 15, 22, 28, 2, 17, 14, 28, 5, 1, 120, 30, 9, 4, 43, 26, 17, 1, 22, 28, 2, 19, 14, 28, 3, 4, 113, 28, 3, 11, 44, 26, 17, 4, 21, 26, 9, 16, 13, 26, 3, 5, 107, 28, 3, 13, 41, 26, 15, 5, 24, 30, 15, 10, 15, 28, 4, 4, 116, 28, 17, 0, 42, 26, 17, 6, 22, 28, 19, 6, 16, 30, 2, 7, 111, 28, 17, 0, 46, 28, 7, 16, 24, 30, 34, 0, 13, 24, 4, 5, 121, 30, 4, 14, 47, 28, 11, 14, 24, 30, 16, 14, 15, 30, 6, 4, 117, 30, 6, 14, 45, 28, 11, 16, 24, 30, 30, 2, 16, 30, 8, 4, 106, 26, 8, 13, 47, 28, 7, 22, 24, 30, 22, 13, 15, 30, 10, 2, 114, 28, 19, 4, 46, 28, 28, 6, 22, 28, 33, 4, 16, 30, 8, 4, 122, 30, 22, 3, 45, 28, 8, 26, 23, 30, 12, 28, 15, 30, 3, 10, 117, 30, 3, 23, 45, 28, 4, 31, 24, 30, 11, 31, 15, 30, 7, 7, 116, 30, 21, 7, 45, 28, 1, 37, 23, 30, 19, 26, 15, 30, 5, 10, 115, 30, 19, 10, 47, 28, 15, 25, 24, 30, 23, 25, 15, 30, 13, 3, 115, 30, 2, 29, 46, 28, 42, 1, 24, 30, 23, 28, 15, 30, 17, 0, 115, 30, 10, 23, 46, 28, 10, 35, 24, 30, 19, 35, 15, 30, 17, 1, 115, 30, 14, 21, 46, 28, 29, 19, 24, 30, 11, 46, 15, 30, 13, 6, 115, 30, 14, 23, 46, 28, 44, 7, 24, 30, 59, 1, 16, 30, 12, 7, 121, 30, 12, 26, 47, 28, 39, 14, 24, 30, 22, 41, 15, 30, 6, 14, 121, 30, 6, 34, 47, 28, 46, 10, 24, 30, 2, 64, 15, 30, 17, 4, 122, 30, 29, 14, 46, 28, 49, 10, 24, 30, 24, 46, 15, 30, 4, 18, 122, 30, 13, 32, 46, 28, 48, 14, 24, 30, 42, 32, 15, 30, 20, 4, 117, 30, 40, 7, 47, 28, 43, 22, 24, 30, 10, 67, 15, 30, 19, 6, 118, 30, 18, 31, 47, 28, 34, 34, 24, 30, 20, 61, 15, 30]; + } + + /** + * Returns the final format bits with mask (level << 3 | mask). + * + * @return {Number[]} The final format bits. + * @public + * @static + */ + + }, { + key: "FINAL_FORMAT", + get: function get() { + return [ + // L + 0x77c4, 0x72f3, 0x7daa, 0x789d, 0x662f, 0x6318, 0x6c41, 0x6976, + // M + 0x5412, 0x5125, 0x5e7c, 0x5b4b, 0x45f9, 0x40ce, 0x4f97, 0x4aa0, + // Q + 0x355f, 0x3068, 0x3f31, 0x3a06, 0x24b4, 0x2183, 0x2eda, 0x2bed, + // H + 0x1689, 0x13be, 0x1ce7, 0x19d0, 0x0762, 0x0255, 0x0d0c, 0x083b]; + } + + /** + * Returns a map of human-readable ECC levels. + * + * @return {Object} A ECC level mapping. + * @public + * @static + */ + + }, { + key: "LEVELS", + get: function get() { + return { + L: 1, + M: 2, + Q: 3, + H: 4 + }; + } + }]); + return ErrorCorrection; +}(); + +/* + * QRious + * Copyright (C) 2016 Alasdair Mercer + * Copyright (C) 2010 Tom Zerucha + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * Contains Galois field information. + * + * @public + */ + +var Galois = function () { + function Galois() { + classCallCheck(this, Galois); + } + + createClass(Galois, null, [{ + key: "EXPONENT", + + + /** + * Returns the Galois field exponent table. + * + * @return {Number[]} The Galois field exponent table. + * @public + * @static + */ + get: function get() { + return [0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1d, 0x3a, 0x74, 0xe8, 0xcd, 0x87, 0x13, 0x26, 0x4c, 0x98, 0x2d, 0x5a, 0xb4, 0x75, 0xea, 0xc9, 0x8f, 0x03, 0x06, 0x0c, 0x18, 0x30, 0x60, 0xc0, 0x9d, 0x27, 0x4e, 0x9c, 0x25, 0x4a, 0x94, 0x35, 0x6a, 0xd4, 0xb5, 0x77, 0xee, 0xc1, 0x9f, 0x23, 0x46, 0x8c, 0x05, 0x0a, 0x14, 0x28, 0x50, 0xa0, 0x5d, 0xba, 0x69, 0xd2, 0xb9, 0x6f, 0xde, 0xa1, 0x5f, 0xbe, 0x61, 0xc2, 0x99, 0x2f, 0x5e, 0xbc, 0x65, 0xca, 0x89, 0x0f, 0x1e, 0x3c, 0x78, 0xf0, 0xfd, 0xe7, 0xd3, 0xbb, 0x6b, 0xd6, 0xb1, 0x7f, 0xfe, 0xe1, 0xdf, 0xa3, 0x5b, 0xb6, 0x71, 0xe2, 0xd9, 0xaf, 0x43, 0x86, 0x11, 0x22, 0x44, 0x88, 0x0d, 0x1a, 0x34, 0x68, 0xd0, 0xbd, 0x67, 0xce, 0x81, 0x1f, 0x3e, 0x7c, 0xf8, 0xed, 0xc7, 0x93, 0x3b, 0x76, 0xec, 0xc5, 0x97, 0x33, 0x66, 0xcc, 0x85, 0x17, 0x2e, 0x5c, 0xb8, 0x6d, 0xda, 0xa9, 0x4f, 0x9e, 0x21, 0x42, 0x84, 0x15, 0x2a, 0x54, 0xa8, 0x4d, 0x9a, 0x29, 0x52, 0xa4, 0x55, 0xaa, 0x49, 0x92, 0x39, 0x72, 0xe4, 0xd5, 0xb7, 0x73, 0xe6, 0xd1, 0xbf, 0x63, 0xc6, 0x91, 0x3f, 0x7e, 0xfc, 0xe5, 0xd7, 0xb3, 0x7b, 0xf6, 0xf1, 0xff, 0xe3, 0xdb, 0xab, 0x4b, 0x96, 0x31, 0x62, 0xc4, 0x95, 0x37, 0x6e, 0xdc, 0xa5, 0x57, 0xae, 0x41, 0x82, 0x19, 0x32, 0x64, 0xc8, 0x8d, 0x07, 0x0e, 0x1c, 0x38, 0x70, 0xe0, 0xdd, 0xa7, 0x53, 0xa6, 0x51, 0xa2, 0x59, 0xb2, 0x79, 0xf2, 0xf9, 0xef, 0xc3, 0x9b, 0x2b, 0x56, 0xac, 0x45, 0x8a, 0x09, 0x12, 0x24, 0x48, 0x90, 0x3d, 0x7a, 0xf4, 0xf5, 0xf7, 0xf3, 0xfb, 0xeb, 0xcb, 0x8b, 0x0b, 0x16, 0x2c, 0x58, 0xb0, 0x7d, 0xfa, 0xe9, 0xcf, 0x83, 0x1b, 0x36, 0x6c, 0xd8, 0xad, 0x47, 0x8e, 0x00]; + } + + /** + * Returns the Galois field log table. + * + * @return {Number[]} The Galois field log table. + * @public + * @static + */ + + }, { + key: "LOG", + get: function get() { + return [0xff, 0x00, 0x01, 0x19, 0x02, 0x32, 0x1a, 0xc6, 0x03, 0xdf, 0x33, 0xee, 0x1b, 0x68, 0xc7, 0x4b, 0x04, 0x64, 0xe0, 0x0e, 0x34, 0x8d, 0xef, 0x81, 0x1c, 0xc1, 0x69, 0xf8, 0xc8, 0x08, 0x4c, 0x71, 0x05, 0x8a, 0x65, 0x2f, 0xe1, 0x24, 0x0f, 0x21, 0x35, 0x93, 0x8e, 0xda, 0xf0, 0x12, 0x82, 0x45, 0x1d, 0xb5, 0xc2, 0x7d, 0x6a, 0x27, 0xf9, 0xb9, 0xc9, 0x9a, 0x09, 0x78, 0x4d, 0xe4, 0x72, 0xa6, 0x06, 0xbf, 0x8b, 0x62, 0x66, 0xdd, 0x30, 0xfd, 0xe2, 0x98, 0x25, 0xb3, 0x10, 0x91, 0x22, 0x88, 0x36, 0xd0, 0x94, 0xce, 0x8f, 0x96, 0xdb, 0xbd, 0xf1, 0xd2, 0x13, 0x5c, 0x83, 0x38, 0x46, 0x40, 0x1e, 0x42, 0xb6, 0xa3, 0xc3, 0x48, 0x7e, 0x6e, 0x6b, 0x3a, 0x28, 0x54, 0xfa, 0x85, 0xba, 0x3d, 0xca, 0x5e, 0x9b, 0x9f, 0x0a, 0x15, 0x79, 0x2b, 0x4e, 0xd4, 0xe5, 0xac, 0x73, 0xf3, 0xa7, 0x57, 0x07, 0x70, 0xc0, 0xf7, 0x8c, 0x80, 0x63, 0x0d, 0x67, 0x4a, 0xde, 0xed, 0x31, 0xc5, 0xfe, 0x18, 0xe3, 0xa5, 0x99, 0x77, 0x26, 0xb8, 0xb4, 0x7c, 0x11, 0x44, 0x92, 0xd9, 0x23, 0x20, 0x89, 0x2e, 0x37, 0x3f, 0xd1, 0x5b, 0x95, 0xbc, 0xcf, 0xcd, 0x90, 0x87, 0x97, 0xb2, 0xdc, 0xfc, 0xbe, 0x61, 0xf2, 0x56, 0xd3, 0xab, 0x14, 0x2a, 0x5d, 0x9e, 0x84, 0x3c, 0x39, 0x53, 0x47, 0x6d, 0x41, 0xa2, 0x1f, 0x2d, 0x43, 0xd8, 0xb7, 0x7b, 0xa4, 0x76, 0xc4, 0x17, 0x49, 0xec, 0x7f, 0x0c, 0x6f, 0xf6, 0x6c, 0xa1, 0x3b, 0x52, 0x29, 0x9d, 0x55, 0xaa, 0xfb, 0x60, 0x86, 0xb1, 0xbb, 0xcc, 0x3e, 0x5a, 0xcb, 0x59, 0x5f, 0xb0, 0x9c, 0xa9, 0xa0, 0x51, 0x0b, 0xf5, 0x16, 0xeb, 0x7a, 0x75, 0x2c, 0xd7, 0x4f, 0xae, 0xd5, 0xe9, 0xe6, 0xe7, 0xad, 0xe8, 0x74, 0xd6, 0xf4, 0xea, 0xa8, 0x50, 0x58, 0xaf]; + } + }]); + return Galois; +}(); + +/* + * QRious + * Copyright (C) 2016 Alasdair Mercer + * Copyright (C) 2010 Tom Zerucha + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * Contains version pattern information. + * + * @public + */ + +var Version = function () { + function Version() { + classCallCheck(this, Version); + } + + createClass(Version, null, [{ + key: "BLOCK", + + + /** + * Returns the version pattern block. + * + * @return {Number[]} The version pattern block. + * @public + * @static + */ + get: function get() { + return [0xc94, 0x5bc, 0xa99, 0x4d3, 0xbf6, 0x762, 0x847, 0x60d, 0x928, 0xb78, 0x45d, 0xa17, 0x532, 0x9a6, 0x683, 0x8c9, 0x7ec, 0xec4, 0x1e1, 0xfab, 0x08e, 0xc1a, 0x33f, 0xd75, 0x250, 0x9d5, 0x6f0, 0x8ba, 0x79f, 0xb0b, 0x42e, 0xa64, 0x541, 0xc69]; + } + }]); + return Version; +}(); + +/** + * Generates information for a QR code frame based on a specific value to be encoded. + * + * @public + */ + +var Frame = function () { + createClass(Frame, null, [{ + key: '_createArray', + value: function _createArray(length) { + var array = []; + + for (var i = 0; i < length; i++) { + array[i] = 0; + } + + return array; + } + }, { + key: '_getMaskBit', + value: function _getMaskBit(x, y) { + var bit = void 0; + + if (x > y) { + bit = x; + x = y; + y = bit; + } + + bit = y; + bit += y * y; + bit >>= 1; + bit += x; + + return bit; + } + }, { + key: '_modN', + value: function _modN(x) { + while (x >= 255) { + x -= 255; + x = (x >> 8) + (x & 255); + } + + return x; + } + + // *Badness* coefficients. + + }, { + key: 'N1', + get: function get() { + return 3; + } + }, { + key: 'N2', + get: function get() { + return 3; + } + }, { + key: 'N3', + get: function get() { + return 40; + } + }, { + key: 'N4', + get: function get() { + return 10; + } + + /** + * Creates an instance of {@link Frame} based on the options provided. + * + * @param {Frame~Options} options - the options to be used + * @public + */ + + }]); + + function Frame(options) { + classCallCheck(this, Frame); + + this._badness = []; + this._level = ErrorCorrection.LEVELS[options.level]; + this._polynomial = []; + this._value = options.value; + this._valueLength = this._value.length; + this._version = 0; + this._stringBuffer = this._value.slice(0); + + var dataBlock = void 0; + var eccBlock = void 0; + var neccBlock1 = void 0; + var neccBlock2 = void 0; + + while (this._version < 40) { + this._version++; + + var index = (this._level - 1) * 4 + (this._version - 1) * 16; + + neccBlock1 = ErrorCorrection.BLOCKS[index++]; + neccBlock2 = ErrorCorrection.BLOCKS[index++]; + dataBlock = ErrorCorrection.BLOCKS[index++]; + eccBlock = ErrorCorrection.BLOCKS[index]; + + index = dataBlock * (neccBlock1 + neccBlock2) + neccBlock2 - 3 + (this._version <= 9); + + if (this._valueLength <= index) { + break; + } + } + + this._dataBlock = dataBlock; + this._eccBlock = eccBlock; + this._neccBlock1 = neccBlock1; + this._neccBlock2 = neccBlock2; + + /** + * The data width is based on version. + * + * @public + * @type {Number} + */ + // FIXME: Ensure that it fits instead of being truncated. + this.width = 17 + 4 * this._version; + + /** + * The image buffer. + * + * @public + * @type {Number[]} + */ + this.buffer = Frame._createArray(this.width * this.width); + + this._ecc = Frame._createArray(this._dataBlock + (this._dataBlock + this._eccBlock) * (this._neccBlock1 + this._neccBlock2) + this._neccBlock2); + this._mask = Frame._createArray((this.width * (this.width + 1) + 1) / 2); + + this._insertFinders(); + this._insertAlignments(); + + // Insert single foreground cell. + this.buffer[8 + this.width * (this.width - 8)] = 1; + + this._insertTimingGap(); + this._reverseMask(); + this._insertTimingRowAndColumn(); + this._insertVersion(); + this._syncMask(); + this._convertBitStream(this._stringBuffer.length); + this._calculatePolynomial(); + this._appendEccToData(); + this._interleaveBlocks(); + this._pack(); + this._finish(); + } + + createClass(Frame, [{ + key: '_addAlignment', + value: function _addAlignment(x, y) { + this.buffer[x + this.width * y] = 1; + + for (var i = -2; i < 2; i++) { + this.buffer[x + i + this.width * (y - 2)] = 1; + this.buffer[x - 2 + this.width * (y + i + 1)] = 1; + this.buffer[x + 2 + this.width * (y + i)] = 1; + this.buffer[x + i + 1 + this.width * (y + 2)] = 1; + } + + for (var _i = 0; _i < 2; _i++) { + this._setMask(x - 1, y + _i); + this._setMask(x + 1, y - _i); + this._setMask(x - _i, y - 1); + this._setMask(x + _i, y + 1); + } + } + }, { + key: '_appendData', + value: function _appendData(data, dataLength, ecc, eccLength) { + for (var i = 0; i < eccLength; i++) { + this._stringBuffer[ecc + i] = 0; + } + + for (var _i2 = 0; _i2 < dataLength; _i2++) { + var bit = Galois.LOG[this._stringBuffer[data + _i2] ^ this._stringBuffer[ecc]]; + + if (bit !== 255) { + for (var j = 1; j < eccLength; j++) { + this._stringBuffer[ecc + j - 1] = this._stringBuffer[ecc + j] ^ Galois.EXPONENT[Frame._modN(bit + this._polynomial[eccLength - j])]; + } + } else { + for (var _j = ecc; _j < ecc + eccLength; _j++) { + this._stringBuffer[_j] = this._stringBuffer[_j + 1]; + } + } + + this._stringBuffer[ecc + eccLength - 1] = bit === 255 ? 0 : Galois.EXPONENT[Frame._modN(bit + this._polynomial[0])]; + } + } + }, { + key: '_appendEccToData', + value: function _appendEccToData() { + var data = 0; + var ecc = this._calculateMaxLength(); + + for (var i = 0; i < this._neccBlock1; i++) { + this._appendData(data, this._dataBlock, ecc, this._eccBlock); + + data += this._dataBlock; + ecc += this._eccBlock; + } + + for (var _i3 = 0; _i3 < this._neccBlock2; _i3++) { + this._appendData(data, this._dataBlock + 1, ecc, this._eccBlock); + + data += this._dataBlock + 1; + ecc += this._eccBlock; + } + } + }, { + key: '_applyMask', + value: function _applyMask(mask) { + var width = this.width; + + switch (mask) { + case 0: + for (var y = 0; y < width; y++) { + for (var x = 0; x < width; x++) { + if (!(x + y & 1) && !this._isMasked(x, y)) { + this.buffer[x + y * width] ^= 1; + } + } + } + + break; + case 1: + for (var _y = 0; _y < width; _y++) { + for (var _x = 0; _x < width; _x++) { + if (!(_y & 1) && !this._isMasked(_x, _y)) { + this.buffer[_x + _y * width] ^= 1; + } + } + } + + break; + case 2: + for (var _y2 = 0; _y2 < width; _y2++) { + for (var r3x = 0, _x2 = 0; _x2 < width; _x2++, r3x++) { + if (r3x === 3) { + r3x = 0; + } + + if (!r3x && !this._isMasked(_x2, _y2)) { + this.buffer[_x2 + _y2 * width] ^= 1; + } + } + } + + break; + case 3: + for (var r3y = 0, _y3 = 0; _y3 < width; _y3++, r3y++) { + if (r3y === 3) { + r3y = 0; + } + + for (var _r3x = r3y, _x3 = 0; _x3 < width; _x3++, _r3x++) { + if (_r3x === 3) { + _r3x = 0; + } + + if (!_r3x && !this._isMasked(_x3, _y3)) { + this.buffer[_x3 + _y3 * width] ^= 1; + } + } + } + + break; + case 4: + for (var _y4 = 0; _y4 < width; _y4++) { + for (var _r3x2 = 0, _r3y = _y4 >> 1 & 1, _x4 = 0; _x4 < width; _x4++, _r3x2++) { + if (_r3x2 === 3) { + _r3x2 = 0; + _r3y = !_r3y; + } + + if (!_r3y && !this._isMasked(_x4, _y4)) { + this.buffer[_x4 + _y4 * width] ^= 1; + } + } + } + + break; + case 5: + for (var _r3y2 = 0, _y5 = 0; _y5 < width; _y5++, _r3y2++) { + if (_r3y2 === 3) { + _r3y2 = 0; + } + + for (var _r3x3 = 0, _x5 = 0; _x5 < width; _x5++, _r3x3++) { + if (_r3x3 === 3) { + _r3x3 = 0; + } + + if (!((_x5 & _y5 & 1) + !(!_r3x3 | !_r3y2)) && !this._isMasked(_x5, _y5)) { + this.buffer[_x5 + _y5 * width] ^= 1; + } + } + } + + break; + case 6: + for (var _r3y3 = 0, _y6 = 0; _y6 < width; _y6++, _r3y3++) { + if (_r3y3 === 3) { + _r3y3 = 0; + } + + for (var _r3x4 = 0, _x6 = 0; _x6 < width; _x6++, _r3x4++) { + if (_r3x4 === 3) { + _r3x4 = 0; + } + + if (!(_x6 & _y6 & 1 + (_r3x4 && _r3x4 === _r3y3) & 1) && !this._isMasked(_x6, _y6)) { + this.buffer[_x6 + _y6 * width] ^= 1; + } + } + } + + break; + case 7: + for (var _r3y4 = 0, _y7 = 0; _y7 < width; _y7++, _r3y4++) { + if (_r3y4 === 3) { + _r3y4 = 0; + } + + for (var _r3x5 = 0, _x7 = 0; _x7 < width; _x7++, _r3x5++) { + if (_r3x5 === 3) { + _r3x5 = 0; + } + + if (!((_r3x5 && _r3x5 === _r3y4) + (_x7 + _y7 & 1) & 1) && !this._isMasked(_x7, _y7)) { + this.buffer[_x7 + _y7 * width] ^= 1; + } + } + } + + break; + } + } + }, { + key: '_calculateMaxLength', + value: function _calculateMaxLength() { + return this._dataBlock * (this._neccBlock1 + this._neccBlock2) + this._neccBlock2; + } + }, { + key: '_calculatePolynomial', + value: function _calculatePolynomial() { + this._polynomial[0] = 1; + + for (var i = 0; i < this._eccBlock; i++) { + this._polynomial[i + 1] = 1; + + for (var j = i; j > 0; j--) { + this._polynomial[j] = this._polynomial[j] ? this._polynomial[j - 1] ^ Galois.EXPONENT[Frame._modN(Galois.LOG[this._polynomial[j]] + i)] : this._polynomial[j - 1]; + } + + this._polynomial[0] = Galois.EXPONENT[Frame._modN(Galois.LOG[this._polynomial[0]] + i)]; + } + + // Use logs for generator polynomial to save calculation step. + for (var _i4 = 0; _i4 <= this._eccBlock; _i4++) { + this._polynomial[_i4] = Galois.LOG[this._polynomial[_i4]]; + } + } + }, { + key: '_checkBadness', + value: function _checkBadness() { + var bad = 0; + var width = this.width; + + // Blocks of same colour. + for (var y = 0; y < width - 1; y++) { + for (var x = 0; x < width - 1; x++) { + // All foreground colour. + if (this.buffer[x + width * y] && this.buffer[x + 1 + width * y] && this.buffer[x + width * (y + 1)] && this.buffer[x + 1 + width * (y + 1)] || + // All background colour. + !(this.buffer[x + width * y] || this.buffer[x + 1 + width * y] || this.buffer[x + width * (y + 1)] || this.buffer[x + 1 + width * (y + 1)])) { + bad += Frame.N2; + } + } + } + + var bw = 0; + + // X runs. + for (var _y8 = 0; _y8 < width; _y8++) { + var h = 0; + + this._badness[0] = 0; + + for (var b = 0, _x8 = 0; _x8 < width; _x8++) { + var b1 = this.buffer[_x8 + width * _y8]; + + if (b === b1) { + this._badness[h]++; + } else { + this._badness[++h] = 1; + } + + b = b1; + bw += b ? 1 : -1; + } + + bad += this._getBadness(h); + } + + if (bw < 0) { + bw = -bw; + } + + var count = 0; + var big = bw; + big += big << 2; + big <<= 1; + + while (big > width * width) { + big -= width * width; + count++; + } + + bad += count * Frame.N4; + + // Y runs. + for (var _x9 = 0; _x9 < width; _x9++) { + var _h = 0; + + this._badness[0] = 0; + + for (var _b = 0, _y9 = 0; _y9 < width; _y9++) { + var _b2 = this.buffer[_x9 + width * _y9]; + + if (_b === _b2) { + this._badness[_h]++; + } else { + this._badness[++_h] = 1; + } + + _b = _b2; + } + + bad += this._getBadness(_h); + } + + return bad; + } + }, { + key: '_convertBitStream', + value: function _convertBitStream(length) { + // Convert string to bit stream. 8-bit data to QR-coded 8-bit data (numeric, alphanum, or kanji + // not supported). + + for (var i = 0; i < length; i++) { + this._ecc[i] = this._stringBuffer.charCodeAt(i); + } + + this._stringBuffer = this._ecc.slice(0); + + var maxLength = this._calculateMaxLength(); + + if (length >= maxLength - 2) { + length = maxLength - 2; + + if (this._version > 9) { + length--; + } + } + + // Shift and re-pack to insert length prefix. + var index = length; + + if (this._version > 9) { + this._stringBuffer[index + 2] = 0; + this._stringBuffer[index + 3] = 0; + + while (index--) { + var bit = this._stringBuffer[index]; + + this._stringBuffer[index + 3] |= 255 & bit << 4; + this._stringBuffer[index + 2] = bit >> 4; + } + + this._stringBuffer[2] |= 255 & length << 4; + this._stringBuffer[1] = length >> 4; + this._stringBuffer[0] = 0x40 | length >> 12; + } else { + this._stringBuffer[index + 1] = 0; + this._stringBuffer[index + 2] = 0; + + while (index--) { + var _bit = this._stringBuffer[index]; + + this._stringBuffer[index + 2] |= 255 & _bit << 4; + this._stringBuffer[index + 1] = _bit >> 4; + } + + this._stringBuffer[1] |= 255 & length << 4; + this._stringBuffer[0] = 0x40 | length >> 4; + } + + // Fill to end with pad pattern. + index = length + 3 - (this._version < 10); + + while (index < maxLength) { + this._stringBuffer[index++] = 0xec; + this._stringBuffer[index++] = 0x11; + } + } + }, { + key: '_getBadness', + value: function _getBadness(length) { + var badRuns = 0; + + for (var i = 0; i <= length; i++) { + if (this._badness[i] >= 5) { + badRuns += Frame.N1 + this._badness[i] - 5; + } + } + + // FBFFFBF as in finder. + for (var _i5 = 3; _i5 < length - 1; _i5 += 2) { + if (this._badness[_i5 - 2] === this._badness[_i5 + 2] && this._badness[_i5 + 2] === this._badness[_i5 - 1] && this._badness[_i5 - 1] === this._badness[_i5 + 1] && this._badness[_i5 - 1] * 3 === this._badness[_i5] && ( + // Background around the foreground pattern? Not part of the specs. + this._badness[_i5 - 3] === 0 || _i5 + 3 > length || this._badness[_i5 - 3] * 3 >= this._badness[_i5] * 4 || this._badness[_i5 + 3] * 3 >= this._badness[_i5] * 4)) { + badRuns += Frame.N3; + } + } + + return badRuns; + } + }, { + key: '_finish', + value: function _finish() { + // Save pre-mask copy of frame. + this._stringBuffer = this.buffer.slice(0); + + var bit = 0; + var i = void 0; + var mask = 30000; + + /* + * Using for instead of while since in original Arduino code if an early mask was "good enough" it wouldn't try for + * a better one since they get more complex and take longer. + */ + for (i = 0; i < 8; i++) { + // Returns foreground-background imbalance. + this._applyMask(i); + + var currentMask = this._checkBadness(); + + // Is current mask better than previous best? + if (currentMask < mask) { + mask = currentMask; + bit = i; + } + + // Don't increment "i" to a void redoing mask. + if (bit === 7) { + break; + } + + // Reset for next pass. + this.buffer = this._stringBuffer.slice(0); + } + + // Redo best mask as none were "good enough" (i.e. last wasn't bit). + if (bit !== i) { + this._applyMask(bit); + } + + // Add in final mask/ECC level bytes. + mask = ErrorCorrection.FINAL_FORMAT[bit + (this._level - 1 << 3)]; + + // Low byte. + for (i = 0; i < 8; i++, mask >>= 1) { + if (mask & 1) { + this.buffer[this.width - 1 - i + this.width * 8] = 1; + + if (i < 6) { + this.buffer[8 + this.width * i] = 1; + } else { + this.buffer[8 + this.width * (i + 1)] = 1; + } + } + } + + // High byte. + for (i = 0; i < 7; i++, mask >>= 1) { + if (mask & 1) { + this.buffer[8 + this.width * (this.width - 7 + i)] = 1; + + if (i) { + this.buffer[6 - i + this.width * 8] = 1; + } else { + this.buffer[7 + this.width * 8] = 1; + } + } + } + } + }, { + key: '_interleaveBlocks', + value: function _interleaveBlocks() { + var maxLength = this._calculateMaxLength(); + var i = void 0; + var k = 0; + + for (i = 0; i < this._dataBlock; i++) { + for (var j = 0; j < this._neccBlock1; j++) { + this._ecc[k++] = this._stringBuffer[i + j * this._dataBlock]; + } + + for (var _j2 = 0; _j2 < this._neccBlock2; _j2++) { + this._ecc[k++] = this._stringBuffer[this._neccBlock1 * this._dataBlock + i + _j2 * (this._dataBlock + 1)]; + } + } + + for (var _j3 = 0; _j3 < this._neccBlock2; _j3++) { + this._ecc[k++] = this._stringBuffer[this._neccBlock1 * this._dataBlock + i + _j3 * (this._dataBlock + 1)]; + } + + for (i = 0; i < this._eccBlock; i++) { + for (var _j4 = 0; _j4 < this._neccBlock1 + this._neccBlock2; _j4++) { + this._ecc[k++] = this._stringBuffer[maxLength + i + _j4 * this._eccBlock]; + } + } + + this._stringBuffer = this._ecc; + } + }, { + key: '_insertAlignments', + value: function _insertAlignments() { + var width = this.width; + + if (this._version > 1) { + var i = Alignment.BLOCK[this._version]; + var y = width - 7; + + for (;;) { + var x = width - 7; + + while (x > i - 3) { + this._addAlignment(x, y); + + if (x < i) { + break; + } + + x -= i; + } + + if (y <= i + 9) { + break; + } + + y -= i; + + this._addAlignment(6, y); + this._addAlignment(y, 6); + } + } + } + }, { + key: '_insertFinders', + value: function _insertFinders() { + var width = this.width; + + for (var i = 0; i < 3; i++) { + var j = 0; + var y = 0; + + if (i === 1) { + j = width - 7; + } + if (i === 2) { + y = width - 7; + } + + this.buffer[y + 3 + width * (j + 3)] = 1; + + for (var x = 0; x < 6; x++) { + this.buffer[y + x + width * j] = 1; + this.buffer[y + width * (j + x + 1)] = 1; + this.buffer[y + 6 + width * (j + x)] = 1; + this.buffer[y + x + 1 + width * (j + 6)] = 1; + } + + for (var _x10 = 1; _x10 < 5; _x10++) { + this._setMask(y + _x10, j + 1); + this._setMask(y + 1, j + _x10 + 1); + this._setMask(y + 5, j + _x10); + this._setMask(y + _x10 + 1, j + 5); + } + + for (var _x11 = 2; _x11 < 4; _x11++) { + this.buffer[y + _x11 + width * (j + 2)] = 1; + this.buffer[y + 2 + width * (j + _x11 + 1)] = 1; + this.buffer[y + 4 + width * (j + _x11)] = 1; + this.buffer[y + _x11 + 1 + width * (j + 4)] = 1; + } + } + } + }, { + key: '_insertTimingGap', + value: function _insertTimingGap() { + var width = this.width; + + for (var y = 0; y < 7; y++) { + this._setMask(7, y); + this._setMask(width - 8, y); + this._setMask(7, y + width - 7); + } + + for (var x = 0; x < 8; x++) { + this._setMask(x, 7); + this._setMask(x + width - 8, 7); + this._setMask(x, width - 8); + } + } + }, { + key: '_insertTimingRowAndColumn', + value: function _insertTimingRowAndColumn() { + var width = this.width; + + for (var x = 0; x < width - 14; x++) { + if (x & 1) { + this._setMask(8 + x, 6); + this._setMask(6, 8 + x); + } else { + this.buffer[8 + x + width * 6] = 1; + this.buffer[6 + width * (8 + x)] = 1; + } + } + } + }, { + key: '_insertVersion', + value: function _insertVersion() { + var width = this.width; + + if (this._version > 6) { + var i = Version.BLOCK[this._version - 7]; + var j = 17; + + for (var x = 0; x < 6; x++) { + for (var y = 0; y < 3; y++, j--) { + if (1 & (j > 11 ? this._version >> j - 12 : i >> j)) { + this.buffer[5 - x + width * (2 - y + width - 11)] = 1; + this.buffer[2 - y + width - 11 + width * (5 - x)] = 1; + } else { + this._setMask(5 - x, 2 - y + width - 11); + this._setMask(2 - y + width - 11, 5 - x); + } + } + } + } + } + }, { + key: '_isMasked', + value: function _isMasked(x, y) { + var bit = Frame._getMaskBit(x, y); + + return this._mask[bit] === 1; + } + }, { + key: '_pack', + value: function _pack() { + var x = this.width - 1; + var y = this.width - 1; + var k = 1; + var v = 1; + + // Interleaved data and ECC codes. + var length = (this._dataBlock + this._eccBlock) * (this._neccBlock1 + this._neccBlock2) + this._neccBlock2; + + for (var i = 0; i < length; i++) { + var bit = this._stringBuffer[i]; + + for (var j = 0; j < 8; j++, bit <<= 1) { + if (0x80 & bit) { + this.buffer[x + this.width * y] = 1; + } + + // Find next fill position. + do { + if (v) { + x--; + } else { + x++; + + if (k) { + if (y !== 0) { + y--; + } else { + x -= 2; + k = !k; + + if (x === 6) { + x--; + y = 9; + } + } + } else if (y !== this.width - 1) { + y++; + } else { + x -= 2; + k = !k; + + if (x === 6) { + x--; + y -= 8; + } + } + } + + v = !v; + } while (this._isMasked(x, y)); + } + } + } + }, { + key: '_reverseMask', + value: function _reverseMask() { + var width = this.width; + + for (var x = 0; x < 9; x++) { + this._setMask(x, 8); + } + + for (var _x12 = 0; _x12 < 8; _x12++) { + this._setMask(_x12 + width - 8, 8); + this._setMask(8, _x12); + } + + for (var y = 0; y < 7; y++) { + this._setMask(8, y + width - 7); + } + } + }, { + key: '_setMask', + value: function _setMask(x, y) { + var bit = Frame._getMaskBit(x, y); + + this._mask[bit] = 1; + } + }, { + key: '_syncMask', + value: function _syncMask() { + var width = this.width; + + for (var y = 0; y < width; y++) { + for (var x = 0; x <= y; x++) { + if (this.buffer[x + width * y]) { + this._setMask(x, y); + } + } + } + } + }]); + return Frame; +}(); + +/** + * An implementation of {@link Renderer} for working with img elements. + * + * This depends on {@link CanvasRenderer} being executed first as this implementation simply applies the data URL from + * the rendered canvas element as the src for the img element being rendered. + * + * @public + * @extends Renderer + */ + +var ImageRenderer = function (_Renderer) { + inherits(ImageRenderer, _Renderer); + + function ImageRenderer() { + classCallCheck(this, ImageRenderer); + return possibleConstructorReturn(this, Object.getPrototypeOf(ImageRenderer).apply(this, arguments)); + } + + createClass(ImageRenderer, [{ + key: 'draw', + + + /** + * @override + */ + value: function draw() { + var qrious = this.qrious; + + qrious.image.src = qrious.toDataURL(); + } + + /** + * @override + */ + + }, { + key: 'reset', + value: function reset() { + var qrious = this.qrious; + + qrious.image.src = ''; + } + + /** + * @override + */ + + }, { + key: 'resize', + value: function resize() { + var qrious = this.qrious; + var image = qrious.image; + + image.width = qrious.size; + image.height = qrious.size; + } + }]); + return ImageRenderer; +}(Renderer); + +/* + * QRious + * Copyright (C) 2016 Alasdair Mercer + * Copyright (C) 2010 Tom Zerucha + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * A basic manager for {@link Service} implementations that are mapped to simple names. + * + * @public + */ + +var ServiceManager = function () { + + /** + * Creates a new instance of {@link ServiceManager}. + * + * @public + */ + + function ServiceManager() { + classCallCheck(this, ServiceManager); + + this._services = {}; + } + + /** + * Returns the {@link Service} being managed with the specified name. + * + * @param {String} name - the name of the {@link Service} to be returned + * @return {Service} The {@link Service} is being managed with name. + * @throws {Error} If no {@link Service} is being managed with name. + * @public + */ + + + createClass(ServiceManager, [{ + key: "getService", + value: function getService(name) { + var service = this._services[name]; + if (!service) { + throw new Error("Service is not being managed with name: " + name); + } + + return service; + } + + /** + * Sets the {@link Service} implementation to be managed for the specified name to the + * service provided. + * + * @param {String} name - the name of the {@link Service} to be managed with name + * @param {Service} service - the {@link Service} implementation to be managed + * @throws {Error} If a {@link Service} is already being managed with the same name. + * @public + */ + + }, { + key: "setService", + value: function setService(name, service) { + if (this._services[name]) { + throw new Error("Service is already managed with name: " + name); + } + + if (service) { + this._services[name] = service; + } + } + }]); + return ServiceManager; +}(); + +/** + * Enables configuration of a QR code generator which uses HTML5 canvas for rendering. + * + * @public + */ + +var QRious = function () { + createClass(QRious, null, [{ + key: 'use', + + + /** + * Configures the service provided to be used by all {@link QRious} instances. + * + * @param {Service} service - the {@link Service} to be configured + * @throws {Error} If a {@link Service} has already been configured with the same name. + * @public + * @static + */ + value: function use(service) { + QRious._serviceManager.setService(service.getName(), service); + } + }, { + key: '_parseOptions', + value: function _parseOptions(options) { + options = Object.assign({}, QRious.DEFAULTS, options); + options.level = Utilities.toUpperCase(options.level); + options.size = Math.abs(options.size); + + return options; + } + + /** + * Creates a new instance of {@link QRious} based on the options provided. + * + * @param {QRious~Options} [options] - the options to be used + * @public + */ + + }, { + key: 'DEFAULTS', + + + /** + * Returns the default options for {@link QRious}. + * + * @return {QRious~Options} The default options. + * @public + * @static + */ + get: function get() { + return { + background: 'white', + foreground: 'black', + level: 'L', + mime: 'image/png', + size: 100, + value: '' + }; + } + + /** + * Returns the current version of {@link QRious}. + * + * @return {String} The current version. + * @public + * @static + */ + + }, { + key: 'VERSION', + get: function get() { + return '2.0.0'; + } + }]); + + function QRious(options) { + classCallCheck(this, QRious); + + options = QRious._parseOptions(options); + + Utilities.privatize(this, options); + + var element = this._element; + var elementService = QRious._serviceManager.getService('element'); + + /** + * The canvas being used to render the QR code for this {@link QRious}. + * + * @public + * @type {*} + */ + this.canvas = element && elementService.isCanvas(element) ? element : elementService.createCanvas(); + this.canvas.qrious = this; + + /** + * The img to contain the rendered QR code for this {@link QRious}. + * + * @public + * @type {*} + */ + this.image = element && elementService.isImage(element) ? element : elementService.createImage(); + this.image.qrious = this; + + this._renderers = [new CanvasRenderer(this), new ImageRenderer(this)]; + + this.update(); + } + + /** + * Returns the image data URI for the generated QR code using the mime provided. + * + * @param {String} [mime] - the MIME type for the image + * @return {String} The image data URI for the QR code. + * @public + */ + + + createClass(QRious, [{ + key: 'toDataURL', + value: function toDataURL(mime) { + return this.canvas.toDataURL(mime || this.mime); + } + + /** + * Updates this {@link QRious} by generating a new {@link Frame} and re-rendering the QR code. + * + * @protected + */ + + }, { + key: 'update', + value: function update() { + var frame = new Frame({ + level: this.level, + value: this.value + }); + + this._renderers.forEach(function (renderer) { + return renderer.render(frame); + }); + } + + /** + * Returns the background color for the QR code. + * + * @return {String} The background color. + * @public + */ + + }, { + key: 'background', + get: function get() { + return this._background; + } + + /** + * Sets the background color for the QR code to background. + * + * @param {String} [background="white"] - the background color to be set + * @public + */ + , + set: function set(background) { + var changed = Utilities.setter(this, '_background', background, QRious.DEFAULTS.background); + + if (changed) { + this.update(); + } + } + + /** + * Returns the foreground color for the QR code. + * + * @return {String} The foreground color. + * @public + */ + + }, { + key: 'foreground', + get: function get() { + return this._foreground; + } + + /** + * Sets the foreground color for the QR code to foreground. + * + * @param {String} [foreground="black"] - the foreground color to be set + * @public + */ + , + set: function set(foreground) { + var changed = Utilities.setter(this, '_foreground', foreground, QRious.DEFAULTS.foreground); + + if (changed) { + this.update(); + } + } + + /** + * Returns the error correction level for the QR code. + * + * @return {String} The ECC level. + * @public + */ + + }, { + key: 'level', + get: function get() { + return this._level; + } + + /** + * Sets the error correction level for the QR code to level. + * + * level will be transformed to upper case to aid mapping to known ECC level blocks. + * + * @param {String} [level="L"] - the ECC level to be set + * @public + */ + , + set: function set(level) { + var changed = Utilities.setter(this, '_level', level, QRious.DEFAULTS.level, Utilities.toUpperCase); + + if (changed) { + this.update(); + } + } + + /** + * Returns the MIME type for the image rendered for the QR code. + * + * @return {String} The image MIME type. + * @public + */ + + }, { + key: 'mime', + get: function get() { + return this._mime; + } + + /** + * Sets the MIME type for the image rendered for the QR code to mime. + * + * @param {String} [mime="image/png"] - the image MIME type to be set + * @public + */ + , + set: function set(mime) { + var changed = Utilities.setter(this, '_mime', mime, QRious.DEFAULTS.mime); + + if (changed) { + this.update(); + } + } + + /** + * Returns the size of the QR code. + * + * @return {Number} The size in pixels. + * @public + */ + + }, { + key: 'size', + get: function get() { + return this._size; + } + + /** + * Sets the size of the QR code to size. + * + * size will be transformed to ensure that it is always an absolute positive numbers (e.g. + * -100 would become 100). + * + * @param {Number} [size=100] - the size in pixels to be set + * @public + */ + , + set: function set(size) { + var changed = Utilities.setter(this, '_size', size, QRious.DEFAULTS.size, Math.abs); + + if (changed) { + this.update(); + } + } + + /** + * Returns the value of the QR code. + * + * @return {String} The value. + * @public + */ + + }, { + key: 'value', + get: function get() { + return this._value; + } + + /** + * Sets the value of the QR code to value. + * + * @param {String} [value=""] - the value to be set + * @public + */ + , + set: function set(value) { + var changed = Utilities.setter(this, '_value', value, QRious.DEFAULTS.value); + + if (changed) { + this.update(); + } + } + }]); + return QRious; +}(); + +QRious._serviceManager = new ServiceManager(); + +QRious.use(new NodeElementService()); + +module.exports = QRious; +//# sourceMappingURL=qrious.js.map \ No newline at end of file diff --git a/dist/cjs/qrious.js.map b/dist/cjs/qrious.js.map new file mode 100644 index 0000000..2d3c86b --- /dev/null +++ b/dist/cjs/qrious.js.map @@ -0,0 +1 @@ +{"version":3,"file":null,"sources":["../../../../../../\u0000babelHelpers","../../src/util/Utilities.js","../../src/service/Service.js","../../src/service/element/ElementService.js","../../src/service/element/NodeElementService.js","../../src/renderer/Renderer.js","../../src/renderer/CanvasRenderer.js","../../src/Alignment.js","../../src/ErrorCorrection.js","../../src/Galois.js","../../src/Version.js","../../src/Frame.js","../../src/renderer/ImageRenderer.js","../../src/service/ServiceManager.js","../../src/QRious.js","../../src/runtime/node.js"],"sourcesContent":["var babelHelpers = {};\nvar _typeof = typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\" ? function (obj) {\n return typeof obj;\n} : function (obj) {\n return obj && typeof Symbol === \"function\" && obj.constructor === Symbol ? \"symbol\" : typeof obj;\n};\n\nexport var jsx = function () {\n var REACT_ELEMENT_TYPE = typeof Symbol === \"function\" && Symbol.for && Symbol.for(\"react.element\") || 0xeac7;\n return function createRawReactElement(type, props, key, children) {\n var defaultProps = type && type.defaultProps;\n var childrenLength = arguments.length - 3;\n\n if (!props && childrenLength !== 0) {\n props = {};\n }\n\n if (props && defaultProps) {\n for (var propName in defaultProps) {\n if (props[propName] === void 0) {\n props[propName] = defaultProps[propName];\n }\n }\n } else if (!props) {\n props = defaultProps || {};\n }\n\n if (childrenLength === 1) {\n props.children = children;\n } else if (childrenLength > 1) {\n var childArray = Array(childrenLength);\n\n for (var i = 0; i < childrenLength; i++) {\n childArray[i] = arguments[i + 3];\n }\n\n props.children = childArray;\n }\n\n return {\n $$typeof: REACT_ELEMENT_TYPE,\n type: type,\n key: key === undefined ? null : '' + key,\n ref: null,\n props: props,\n _owner: null\n };\n };\n}();\n\nexport var asyncToGenerator = function (fn) {\n return function () {\n var gen = fn.apply(this, arguments);\n return new Promise(function (resolve, reject) {\n function step(key, arg) {\n try {\n var info = gen[key](arg);\n var value = info.value;\n } catch (error) {\n reject(error);\n return;\n }\n\n if (info.done) {\n resolve(value);\n } else {\n return Promise.resolve(value).then(function (value) {\n return step(\"next\", value);\n }, function (err) {\n return step(\"throw\", err);\n });\n }\n }\n\n return step(\"next\");\n });\n };\n};\n\nexport var classCallCheck = function (instance, Constructor) {\n if (!(instance instanceof Constructor)) {\n throw new TypeError(\"Cannot call a class as a function\");\n }\n};\n\nexport var createClass = function () {\n function defineProperties(target, props) {\n for (var i = 0; i < props.length; i++) {\n var descriptor = props[i];\n descriptor.enumerable = descriptor.enumerable || false;\n descriptor.configurable = true;\n if (\"value\" in descriptor) descriptor.writable = true;\n Object.defineProperty(target, descriptor.key, descriptor);\n }\n }\n\n return function (Constructor, protoProps, staticProps) {\n if (protoProps) defineProperties(Constructor.prototype, protoProps);\n if (staticProps) defineProperties(Constructor, staticProps);\n return Constructor;\n };\n}();\n\nexport var defineEnumerableProperties = function (obj, descs) {\n for (var key in descs) {\n var desc = descs[key];\n desc.configurable = desc.enumerable = true;\n if (\"value\" in desc) desc.writable = true;\n Object.defineProperty(obj, key, desc);\n }\n\n return obj;\n};\n\nexport var defaults = function (obj, defaults) {\n var keys = Object.getOwnPropertyNames(defaults);\n\n for (var i = 0; i < keys.length; i++) {\n var key = keys[i];\n var value = Object.getOwnPropertyDescriptor(defaults, key);\n\n if (value && value.configurable && obj[key] === undefined) {\n Object.defineProperty(obj, key, value);\n }\n }\n\n return obj;\n};\n\nexport var defineProperty = function (obj, key, value) {\n if (key in obj) {\n Object.defineProperty(obj, key, {\n value: value,\n enumerable: true,\n configurable: true,\n writable: true\n });\n } else {\n obj[key] = value;\n }\n\n return obj;\n};\n\nvar _extends = Object.assign || function (target) {\n for (var i = 1; i < arguments.length; i++) {\n var source = arguments[i];\n\n for (var key in source) {\n if (Object.prototype.hasOwnProperty.call(source, key)) {\n target[key] = source[key];\n }\n }\n }\n\n return target;\n};\n\nexport var get = function get(object, property, receiver) {\n if (object === null) object = Function.prototype;\n var desc = Object.getOwnPropertyDescriptor(object, property);\n\n if (desc === undefined) {\n var parent = Object.getPrototypeOf(object);\n\n if (parent === null) {\n return undefined;\n } else {\n return get(parent, property, receiver);\n }\n } else if (\"value\" in desc) {\n return desc.value;\n } else {\n var getter = desc.get;\n\n if (getter === undefined) {\n return undefined;\n }\n\n return getter.call(receiver);\n }\n};\n\nexport var inherits = function (subClass, superClass) {\n if (typeof superClass !== \"function\" && superClass !== null) {\n throw new TypeError(\"Super expression must either be null or a function, not \" + typeof superClass);\n }\n\n subClass.prototype = Object.create(superClass && superClass.prototype, {\n constructor: {\n value: subClass,\n enumerable: false,\n writable: true,\n configurable: true\n }\n });\n if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;\n};\n\nvar _instanceof = function (left, right) {\n if (right != null && typeof Symbol !== \"undefined\" && right[Symbol.hasInstance]) {\n return right[Symbol.hasInstance](left);\n } else {\n return left instanceof right;\n }\n};\n\nexport var interopRequireDefault = function (obj) {\n return obj && obj.__esModule ? obj : {\n default: obj\n };\n};\n\nexport var interopRequireWildcard = function (obj) {\n if (obj && obj.__esModule) {\n return obj;\n } else {\n var newObj = {};\n\n if (obj != null) {\n for (var key in obj) {\n if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key];\n }\n }\n\n newObj.default = obj;\n return newObj;\n }\n};\n\nexport var newArrowCheck = function (innerThis, boundThis) {\n if (innerThis !== boundThis) {\n throw new TypeError(\"Cannot instantiate an arrow function\");\n }\n};\n\nexport var objectDestructuringEmpty = function (obj) {\n if (obj == null) throw new TypeError(\"Cannot destructure undefined\");\n};\n\nexport var objectWithoutProperties = function (obj, keys) {\n var target = {};\n\n for (var i in obj) {\n if (keys.indexOf(i) >= 0) continue;\n if (!Object.prototype.hasOwnProperty.call(obj, i)) continue;\n target[i] = obj[i];\n }\n\n return target;\n};\n\nexport var possibleConstructorReturn = function (self, call) {\n if (!self) {\n throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\");\n }\n\n return call && (typeof call === \"object\" || typeof call === \"function\") ? call : self;\n};\n\nexport var selfGlobal = typeof global === \"undefined\" ? self : global;\n\nexport var set = function set(object, property, value, receiver) {\n var desc = Object.getOwnPropertyDescriptor(object, property);\n\n if (desc === undefined) {\n var parent = Object.getPrototypeOf(object);\n\n if (parent !== null) {\n set(parent, property, value, receiver);\n }\n } else if (\"value\" in desc && desc.writable) {\n desc.value = value;\n } else {\n var setter = desc.set;\n\n if (setter !== undefined) {\n setter.call(receiver, value);\n }\n }\n\n return value;\n};\n\nexport var slicedToArray = function () {\n function sliceIterator(arr, i) {\n var _arr = [];\n var _n = true;\n var _d = false;\n var _e = undefined;\n\n try {\n for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {\n _arr.push(_s.value);\n\n if (i && _arr.length === i) break;\n }\n } catch (err) {\n _d = true;\n _e = err;\n } finally {\n try {\n if (!_n && _i[\"return\"]) _i[\"return\"]();\n } finally {\n if (_d) throw _e;\n }\n }\n\n return _arr;\n }\n\n return function (arr, i) {\n if (Array.isArray(arr)) {\n return arr;\n } else if (Symbol.iterator in Object(arr)) {\n return sliceIterator(arr, i);\n } else {\n throw new TypeError(\"Invalid attempt to destructure non-iterable instance\");\n }\n };\n}();\n\nexport var slicedToArrayLoose = function (arr, i) {\n if (Array.isArray(arr)) {\n return arr;\n } else if (Symbol.iterator in Object(arr)) {\n var _arr = [];\n\n for (var _iterator = arr[Symbol.iterator](), _step; !(_step = _iterator.next()).done;) {\n _arr.push(_step.value);\n\n if (i && _arr.length === i) break;\n }\n\n return _arr;\n } else {\n throw new TypeError(\"Invalid attempt to destructure non-iterable instance\");\n }\n};\n\nexport var taggedTemplateLiteral = function (strings, raw) {\n return Object.freeze(Object.defineProperties(strings, {\n raw: {\n value: Object.freeze(raw)\n }\n }));\n};\n\nexport var taggedTemplateLiteralLoose = function (strings, raw) {\n strings.raw = raw;\n return strings;\n};\n\nexport var temporalRef = function (val, name, undef) {\n if (val === undef) {\n throw new ReferenceError(name + \" is not defined - temporal dead zone\");\n } else {\n return val;\n }\n};\n\nexport var temporalUndefined = {};\n\nexport var toArray = function (arr) {\n return Array.isArray(arr) ? arr : Array.from(arr);\n};\n\nexport var toConsumableArray = function (arr) {\n if (Array.isArray(arr)) {\n for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i];\n\n return arr2;\n } else {\n return Array.from(arr);\n }\n};\n\nbabelHelpers;\n\nexport { _typeof as typeof, _extends as extends, _instanceof as instanceof }","/*\n * QRious\n * Copyright (C) 2016 Alasdair Mercer\n * Copyright (C) 2010 Tom Zerucha\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see .\n */\n\n/**\n * Contains utility methods that are useful throughout the library.\n *\n * @public\n */\nclass Utilities {\n\n /**\n * Copies all properties from the source object to the target object, however, all property\n * names on the target will be prefixed with an underscore, used to indicate that they are private.\n *\n * @param {Object} target - the object to which the private fields are to be copied\n * @param {Object} source - the object from which the fields are to be copied\n * @return {Object} A reference to the target object.\n * @public\n * @static\n */\n static privatize(target, source) {\n for (let key in source) {\n if (source.hasOwnProperty(key)) {\n target[`_${key}`] = source[key]\n }\n }\n\n return target\n }\n\n /**\n * Sets the specified value on a given field on the object provided.\n *\n * If value is null, the specified default value will be used instead.\n *\n * An optional transformer can be specified which will be used to transform the value (or default value)\n * before it is assigned to the field.\n *\n * @param {Object} object - the object whose field is to be set with value\n * @param {String} fieldName - the field to be set with value\n * @param {*} value - the value to be set on the named field\n * @param {*} [defaultValue] - the value to be used if value is null\n * @param {Function} [transformer] - a function used to transform the value before it is assigned to the named field\n * @return {Boolean} true if the value of the field has changed as a result of the assignment; otherwise\n * false.\n * @public\n * @static\n */\n static setter(object, fieldName, value, defaultValue, transformer) {\n const oldValue = object[fieldName]\n let newValue = value != null ? value : defaultValue\n if (typeof transformer === 'function') {\n newValue = transformer(newValue)\n }\n\n object[fieldName] = newValue\n\n return newValue !== oldValue\n }\n\n /**\n * Throws an error indicating that the a given method on a specific class has not been implemented.\n *\n * @param {String} className - the name of the class on which the method has not been implemented\n * @param {String} methodName - the name of the method which has not been implemented\n * @throws {Error} The error describing the class method which has not been implemented.\n * @public\n * @static\n */\n static throwUnimplemented(className, methodName) {\n throw new Error(`\"${methodName}\" method must be implemented on the ${className} class`)\n }\n\n /**\n * Transforms the specified string to upper case while remaining null-safe.\n *\n * @param {String} string - the string to be transformed to upper case\n * @return {String} string transformed to upper case if string is not null.\n * @public\n * @static\n */\n static toUpperCase(string) {\n return string != null && string.toUpperCase()\n }\n}\n\nexport default Utilities\n","/*\n * QRious\n * Copyright (C) 2016 Alasdair Mercer\n * Copyright (C) 2010 Tom Zerucha\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see .\n */\n\nimport Utilities from '../util/Utilities'\n\n/**\n * Defines a service contract that must be met by all implementations.\n *\n * @public\n */\nclass Service {\n\n /**\n * Returns the name of this {@link Service}.\n *\n * @return {String} The service name.\n * @public\n */\n getName() {\n Utilities.throwUnimplemented('Service', 'getName')\n }\n}\n\nexport default Service\n","/*\n * QRious\n * Copyright (C) 2016 Alasdair Mercer\n * Copyright (C) 2010 Tom Zerucha\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see .\n */\n\nimport Service from '../Service'\nimport Utilities from '../../util/Utilities'\n\n/**\n * A service for working with elements.\n *\n * @public\n * @extends Service\n */\nclass ElementService extends Service {\n\n /**\n * Creates an instance of a canvas element.\n *\n * @return {*} The newly created canvas element.\n * @public\n */\n createCanvas() {\n Utilities.throwUnimplemented('ElementService', 'createCanvas')\n }\n\n /**\n * Creates an instance of a image element.\n *\n * @return {*} The newly created image element.\n * @public\n */\n createImage() {\n Utilities.throwUnimplemented('ElementService', 'createImage')\n }\n\n /**\n * @override\n */\n getName() {\n return 'element'\n }\n\n /**\n * Returns whether the specified element is a canvas.\n *\n * @param {*} element - the element to be checked\n * @return {Boolean} true if element is a canvas; otherwise false.\n * @public\n */\n isCanvas(element) {\n Utilities.throwUnimplemented('ElementService', 'isCanvas')\n }\n\n /**\n * Returns whether the specified element is an image.\n *\n * @param {*} element - the element to be checked\n * @return {Boolean} true if element is an image; otherwise false.\n * @public\n */\n isImage(element) {\n Utilities.throwUnimplemented('ElementService', 'isImage')\n }\n}\n\nexport default ElementService\n","/*\n * QRious\n * Copyright (C) 2016 Alasdair Mercer\n * Copyright (C) 2010 Tom Zerucha\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see .\n */\n\nimport Canvas, { Image } from 'canvas'\n\nimport ElementService from './ElementService'\n\n/**\n * An implementation of {@link ElementService} intended for use within a Node.js environment but is only supported when\n * the canvas module has also been depended on.\n *\n * @public\n * @extends ElementService\n */\nclass NodeElementService extends ElementService {\n\n /**\n * @override\n */\n static isSupported() {\n return Canvas != null\n }\n\n /**\n * @override\n */\n createCanvas() {\n return new Canvas()\n }\n\n /**\n * @override\n */\n createImage() {\n return new Image()\n }\n\n /**\n * @override\n */\n isCanvas(element) {\n return element instanceof Canvas\n }\n\n /**\n * @override\n */\n isImage(element) {\n return element instanceof Image\n }\n}\n\nexport default NodeElementService\n","/*\n * QRious\n * Copyright (C) 2016 Alasdair Mercer\n * Copyright (C) 2010 Tom Zerucha\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see .\n */\n\nimport Utilities from '../util/Utilities'\n\n/**\n * Responsible for rendering a QR code {@link Frame} on a specific type of element.\n *\n * A renderer may be dependant on the rendering of another element, so ordering of their execution is important.\n *\n * @public\n */\nclass Renderer {\n\n /**\n * Creates a new instance of {@link Renderer} for the qrious instance provided.\n *\n * @param {QRious} qrious - the {@link QRious} instance to be used\n * @public\n */\n constructor(qrious) {\n /**\n * The {@link QRious} instance.\n *\n * @protected\n * @type {QRious}\n */\n this.qrious = qrious\n }\n\n /**\n * Draws the specified QR code frame on the underlying element.\n *\n * Implementations of {@link Renderer} must override this method with their own specific logic.\n *\n * @param {Frame} frame - the {@link Frame} to be drawn\n * @protected\n */\n draw(frame) {\n Utilities.throwUnimplemented('Renderer', 'draw')\n }\n\n /**\n * Calculates the size (in pixel units) to represent an individual module within the QR code based on the\n * frame provided.\n *\n * The returned value will be at least one, even in cases where the size of the QR code does not fit its contents.\n * This is done so that the inevitable clipping is handled more gracefully since this way at least something is\n * displayed instead of just a blank space filled by the background color.\n *\n * @param {Frame} frame - the {@link Frame} from which the module size is to be derived\n * @return {Number} The pixel size for each module in the QR code which will be no less than one.\n * @protected\n */\n getModuleSize(frame) {\n const pixels = Math.floor(this.qrious.size / frame.width)\n\n return Math.max(1, pixels)\n }\n\n /**\n * Calculates the offset/padding (in pixel units) to be inserted before the QR code based on the frame\n * provided.\n *\n * The returned value will be zero if there is no available offset or if the size of the QR code does not fit its\n * contents. It will never be a negative value. This is done so that the inevitable clipping appears more naturally\n * and it is not clipped from all directions.\n *\n * @param {Frame} frame - the {@link Frame} from which the offset is to be derived\n * @return {Number} The pixel offset for the QR code which will be no less than zero.\n * @protected\n */\n getOffset(frame) {\n const moduleSize = this.getModuleSize(frame)\n const offset = Math.floor((this.qrious.size - moduleSize * frame.width) / 2)\n\n return Math.max(0, offset)\n }\n\n /**\n * Renders a QR code on the underlying element based on the frame provided.\n *\n * @param {Frame} frame - the {@link Frame} to be rendered\n * @public\n */\n render(frame) {\n this.resize()\n this.reset()\n this.draw(frame)\n }\n\n /**\n * Resets the underlying element, effectively clearing any previously rendered QR code.\n *\n * Implementations of {@link Renderer} must override this method with their own specific logic.\n *\n * @protected\n */\n reset() {\n Utilities.throwUnimplemented('Renderer', 'reset')\n }\n\n /**\n * Ensures that the size of the underlying element matches that defined on the associated {@link QRious} instance.\n *\n * Implementations of {@link Renderer} must override this method with their own specific logic.\n *\n * @protected\n */\n resize() {\n Utilities.throwUnimplemented('Renderer', 'resize')\n }\n}\n\nexport default Renderer\n","/*\n * QRious\n * Copyright (C) 2016 Alasdair Mercer\n * Copyright (C) 2010 Tom Zerucha\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see .\n */\n\nimport Renderer from './Renderer'\n\n/**\n * An implementation of {@link Renderer} for working with canvas elements.\n *\n * @public\n * @extends Renderer\n */\nclass CanvasRenderer extends Renderer {\n\n /**\n * @override\n */\n draw(frame) {\n const qrious = this.qrious\n const moduleSize = this.getModuleSize(frame)\n const offset = this.getOffset(frame)\n const context = qrious.canvas.getContext('2d')\n\n context.fillStyle = qrious.foreground\n\n for (let i = 0; i < frame.width; i++) {\n for (let j = 0; j < frame.width; j++) {\n if (frame.buffer[j * frame.width + i]) {\n context.fillRect(moduleSize * i + offset, moduleSize * j + offset, moduleSize, moduleSize)\n }\n }\n }\n }\n\n /**\n * @override\n */\n reset() {\n const qrious = this.qrious\n const context = qrious.canvas.getContext('2d')\n\n context.lineWidth = 1\n context.clearRect(0, 0, qrious.size, qrious.size)\n context.fillStyle = qrious.background\n context.fillRect(0, 0, qrious.size, qrious.size)\n }\n\n /**\n * @override\n */\n resize() {\n const qrious = this.qrious\n const canvas = qrious.canvas\n\n canvas.width = qrious.size\n canvas.height = qrious.size\n }\n}\n\nexport default CanvasRenderer\n","/*\n * QRious\n * Copyright (C) 2016 Alasdair Mercer\n * Copyright (C) 2010 Tom Zerucha\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see .\n */\n\n/* eslint no-multi-spaces: 0 */\n\n/**\n * Contains alignment pattern information.\n *\n * @public\n */\nclass Alignment {\n\n /**\n * Returns the alignment pattern block.\n *\n * @return {Number[]} The alignment pattern block.\n * @public\n * @static\n */\n static get BLOCK() {\n return [\n 0, 11, 15, 19, 23, 27, 31,\n 16, 18, 20, 22, 24, 26, 28, 20, 22, 24, 24, 26, 28, 28, 22, 24, 24,\n 26, 26, 28, 28, 24, 24, 26, 26, 26, 28, 28, 24, 26, 26, 26, 28, 28\n ]\n }\n}\n\nexport default Alignment\n","/*\n * QRious\n * Copyright (C) 2016 Alasdair Mercer\n * Copyright (C) 2010 Tom Zerucha\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see .\n */\n\n/* eslint no-multi-spaces: 0 */\n\n/**\n * Contains error correction information.\n *\n * @public\n */\nclass ErrorCorrection {\n\n /**\n * Returns the error correction blocks.\n *\n * There are four elements per version. The first two indicate the number of blocks, then the data width, and finally\n * the ECC width.\n *\n * @return {Number[]} The ECC blocks.\n * @public\n * @static\n */\n static get BLOCKS() {\n return [\n 1, 0, 19, 7, 1, 0, 16, 10, 1, 0, 13, 13, 1, 0, 9, 17,\n 1, 0, 34, 10, 1, 0, 28, 16, 1, 0, 22, 22, 1, 0, 16, 28,\n 1, 0, 55, 15, 1, 0, 44, 26, 2, 0, 17, 18, 2, 0, 13, 22,\n 1, 0, 80, 20, 2, 0, 32, 18, 2, 0, 24, 26, 4, 0, 9, 16,\n 1, 0, 108, 26, 2, 0, 43, 24, 2, 2, 15, 18, 2, 2, 11, 22,\n 2, 0, 68, 18, 4, 0, 27, 16, 4, 0, 19, 24, 4, 0, 15, 28,\n 2, 0, 78, 20, 4, 0, 31, 18, 2, 4, 14, 18, 4, 1, 13, 26,\n 2, 0, 97, 24, 2, 2, 38, 22, 4, 2, 18, 22, 4, 2, 14, 26,\n 2, 0, 116, 30, 3, 2, 36, 22, 4, 4, 16, 20, 4, 4, 12, 24,\n 2, 2, 68, 18, 4, 1, 43, 26, 6, 2, 19, 24, 6, 2, 15, 28,\n 4, 0, 81, 20, 1, 4, 50, 30, 4, 4, 22, 28, 3, 8, 12, 24,\n 2, 2, 92, 24, 6, 2, 36, 22, 4, 6, 20, 26, 7, 4, 14, 28,\n 4, 0, 107, 26, 8, 1, 37, 22, 8, 4, 20, 24, 12, 4, 11, 22,\n 3, 1, 115, 30, 4, 5, 40, 24, 11, 5, 16, 20, 11, 5, 12, 24,\n 5, 1, 87, 22, 5, 5, 41, 24, 5, 7, 24, 30, 11, 7, 12, 24,\n 5, 1, 98, 24, 7, 3, 45, 28, 15, 2, 19, 24, 3, 13, 15, 30,\n 1, 5, 107, 28, 10, 1, 46, 28, 1, 15, 22, 28, 2, 17, 14, 28,\n 5, 1, 120, 30, 9, 4, 43, 26, 17, 1, 22, 28, 2, 19, 14, 28,\n 3, 4, 113, 28, 3, 11, 44, 26, 17, 4, 21, 26, 9, 16, 13, 26,\n 3, 5, 107, 28, 3, 13, 41, 26, 15, 5, 24, 30, 15, 10, 15, 28,\n 4, 4, 116, 28, 17, 0, 42, 26, 17, 6, 22, 28, 19, 6, 16, 30,\n 2, 7, 111, 28, 17, 0, 46, 28, 7, 16, 24, 30, 34, 0, 13, 24,\n 4, 5, 121, 30, 4, 14, 47, 28, 11, 14, 24, 30, 16, 14, 15, 30,\n 6, 4, 117, 30, 6, 14, 45, 28, 11, 16, 24, 30, 30, 2, 16, 30,\n 8, 4, 106, 26, 8, 13, 47, 28, 7, 22, 24, 30, 22, 13, 15, 30,\n 10, 2, 114, 28, 19, 4, 46, 28, 28, 6, 22, 28, 33, 4, 16, 30,\n 8, 4, 122, 30, 22, 3, 45, 28, 8, 26, 23, 30, 12, 28, 15, 30,\n 3, 10, 117, 30, 3, 23, 45, 28, 4, 31, 24, 30, 11, 31, 15, 30,\n 7, 7, 116, 30, 21, 7, 45, 28, 1, 37, 23, 30, 19, 26, 15, 30,\n 5, 10, 115, 30, 19, 10, 47, 28, 15, 25, 24, 30, 23, 25, 15, 30,\n 13, 3, 115, 30, 2, 29, 46, 28, 42, 1, 24, 30, 23, 28, 15, 30,\n 17, 0, 115, 30, 10, 23, 46, 28, 10, 35, 24, 30, 19, 35, 15, 30,\n 17, 1, 115, 30, 14, 21, 46, 28, 29, 19, 24, 30, 11, 46, 15, 30,\n 13, 6, 115, 30, 14, 23, 46, 28, 44, 7, 24, 30, 59, 1, 16, 30,\n 12, 7, 121, 30, 12, 26, 47, 28, 39, 14, 24, 30, 22, 41, 15, 30,\n 6, 14, 121, 30, 6, 34, 47, 28, 46, 10, 24, 30, 2, 64, 15, 30,\n 17, 4, 122, 30, 29, 14, 46, 28, 49, 10, 24, 30, 24, 46, 15, 30,\n 4, 18, 122, 30, 13, 32, 46, 28, 48, 14, 24, 30, 42, 32, 15, 30,\n 20, 4, 117, 30, 40, 7, 47, 28, 43, 22, 24, 30, 10, 67, 15, 30,\n 19, 6, 118, 30, 18, 31, 47, 28, 34, 34, 24, 30, 20, 61, 15, 30\n ]\n }\n\n /**\n * Returns the final format bits with mask (level << 3 | mask).\n *\n * @return {Number[]} The final format bits.\n * @public\n * @static\n */\n static get FINAL_FORMAT() {\n return [\n // L\n 0x77c4, 0x72f3, 0x7daa, 0x789d, 0x662f, 0x6318, 0x6c41, 0x6976,\n // M\n 0x5412, 0x5125, 0x5e7c, 0x5b4b, 0x45f9, 0x40ce, 0x4f97, 0x4aa0,\n // Q\n 0x355f, 0x3068, 0x3f31, 0x3a06, 0x24b4, 0x2183, 0x2eda, 0x2bed,\n // H\n 0x1689, 0x13be, 0x1ce7, 0x19d0, 0x0762, 0x0255, 0x0d0c, 0x083b\n ]\n }\n\n /**\n * Returns a map of human-readable ECC levels.\n *\n * @return {Object} A ECC level mapping.\n * @public\n * @static\n */\n static get LEVELS() {\n return {\n L: 1,\n M: 2,\n Q: 3,\n H: 4\n }\n }\n}\n\nexport default ErrorCorrection\n","/*\n * QRious\n * Copyright (C) 2016 Alasdair Mercer\n * Copyright (C) 2010 Tom Zerucha\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see .\n */\n\n/**\n * Contains Galois field information.\n *\n * @public\n */\nclass Galois {\n\n /**\n * Returns the Galois field exponent table.\n *\n * @return {Number[]} The Galois field exponent table.\n * @public\n * @static\n */\n static get EXPONENT() {\n return [\n 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1d, 0x3a, 0x74, 0xe8, 0xcd, 0x87, 0x13, 0x26,\n 0x4c, 0x98, 0x2d, 0x5a, 0xb4, 0x75, 0xea, 0xc9, 0x8f, 0x03, 0x06, 0x0c, 0x18, 0x30, 0x60, 0xc0,\n 0x9d, 0x27, 0x4e, 0x9c, 0x25, 0x4a, 0x94, 0x35, 0x6a, 0xd4, 0xb5, 0x77, 0xee, 0xc1, 0x9f, 0x23,\n 0x46, 0x8c, 0x05, 0x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5, 0xf7, 0xf3, 0xfb, 0xeb, 0xcb, 0x8b, 0x0b, 0x16,\n 0x2c, 0x58, 0xb0, 0x7d, 0xfa, 0xe9, 0xcf, 0x83, 0x1b, 0x36, 0x6c, 0xd8, 0xad, 0x47, 0x8e, 0x00\n ]\n }\n\n /**\n * Returns the Galois field log table.\n *\n * @return {Number[]} The Galois field log table.\n * @public\n * @static\n */\n static get LOG() {\n return [\n 0xff, 0x00, 0x01, 0x19, 0x02, 0x32, 0x1a, 0xc6, 0x03, 0xdf, 0x33, 0xee, 0x1b, 0x68, 0xc7, 0x4b,\n 0x04, 0x64, 0xe0, 0x0e, 0x34, 0x8d, 0xef, 0x81, 0x1c, 0xc1, 0x69, 0xf8, 0xc8, 0x08, 0x4c, 0x71,\n 0x05, 0x8a, 0x65, 0x2f, 0xe1, 0x24, 0x0f, 0x21, 0x35, 0x93, 0x8e, 0xda, 0xf0, 0x12, 0x82, 0x45,\n 0x1d, 0xb5, 0xc2, 0x7d, 0x6a, 0x27, 0xf9, 0xb9, 0xc9, 0x9a, 0x09, 0x78, 0x4d, 0xe4, 0x72, 0xa6,\n 0x06, 0xbf, 0x8b, 0x62, 0x66, 0xdd, 0x30, 0xfd, 0xe2, 0x98, 0x25, 0xb3, 0x10, 0x91, 0x22, 0x88,\n 0x36, 0xd0, 0x94, 0xce, 0x8f, 0x96, 0xdb, 0xbd, 0xf1, 0xd2, 0x13, 0x5c, 0x83, 0x38, 0x46, 0x40,\n 0x1e, 0x42, 0xb6, 0xa3, 0xc3, 0x48, 0x7e, 0x6e, 0x6b, 0x3a, 0x28, 0x54, 0xfa, 0x85, 0xba, 0x3d,\n 0xca, 0x5e, 0x9b, 0x9f, 0x0a, 0x15, 0x79, 0x2b, 0x4e, 0xd4, 0xe5, 0xac, 0x73, 0xf3, 0xa7, 0x57,\n 0x07, 0x70, 0xc0, 0xf7, 0x8c, 0x80, 0x63, 0x0d, 0x67, 0x4a, 0xde, 0xed, 0x31, 0xc5, 0xfe, 0x18,\n 0xe3, 0xa5, 0x99, 0x77, 0x26, 0xb8, 0xb4, 0x7c, 0x11, 0x44, 0x92, 0xd9, 0x23, 0x20, 0x89, 0x2e,\n 0x37, 0x3f, 0xd1, 0x5b, 0x95, 0xbc, 0xcf, 0xcd, 0x90, 0x87, 0x97, 0xb2, 0xdc, 0xfc, 0xbe, 0x61,\n 0xf2, 0x56, 0xd3, 0xab, 0x14, 0x2a, 0x5d, 0x9e, 0x84, 0x3c, 0x39, 0x53, 0x47, 0x6d, 0x41, 0xa2,\n 0x1f, 0x2d, 0x43, 0xd8, 0xb7, 0x7b, 0xa4, 0x76, 0xc4, 0x17, 0x49, 0xec, 0x7f, 0x0c, 0x6f, 0xf6,\n 0x6c, 0xa1, 0x3b, 0x52, 0x29, 0x9d, 0x55, 0xaa, 0xfb, 0x60, 0x86, 0xb1, 0xbb, 0xcc, 0x3e, 0x5a,\n 0xcb, 0x59, 0x5f, 0xb0, 0x9c, 0xa9, 0xa0, 0x51, 0x0b, 0xf5, 0x16, 0xeb, 0x7a, 0x75, 0x2c, 0xd7,\n 0x4f, 0xae, 0xd5, 0xe9, 0xe6, 0xe7, 0xad, 0xe8, 0x74, 0xd6, 0xf4, 0xea, 0xa8, 0x50, 0x58, 0xaf\n ]\n }\n}\n\nexport default Galois\n","/*\n * QRious\n * Copyright (C) 2016 Alasdair Mercer\n * Copyright (C) 2010 Tom Zerucha\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see .\n */\n\n/**\n * Contains version pattern information.\n *\n * @public\n */\nclass Version {\n\n /**\n * Returns the version pattern block.\n *\n * @return {Number[]} The version pattern block.\n * @public\n * @static\n */\n static get BLOCK() {\n return [\n 0xc94, 0x5bc, 0xa99, 0x4d3, 0xbf6, 0x762, 0x847, 0x60d, 0x928, 0xb78, 0x45d, 0xa17, 0x532,\n 0x9a6, 0x683, 0x8c9, 0x7ec, 0xec4, 0x1e1, 0xfab, 0x08e, 0xc1a, 0x33f, 0xd75, 0x250, 0x9d5,\n 0x6f0, 0x8ba, 0x79f, 0xb0b, 0x42e, 0xa64, 0x541, 0xc69\n ]\n }\n}\n\nexport default Version\n","/*\n * QRious\n * Copyright (C) 2016 Alasdair Mercer\n * Copyright (C) 2010 Tom Zerucha\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see .\n */\n\nimport Alignment from './Alignment'\nimport ErrorCorrection from './ErrorCorrection'\nimport Galois from './Galois'\nimport Version from './Version'\n\n/**\n * Generates information for a QR code frame based on a specific value to be encoded.\n *\n * @public\n */\nclass Frame {\n\n static _createArray(length) {\n const array = []\n\n for (let i = 0; i < length; i++) {\n array[i] = 0\n }\n\n return array\n }\n\n static _getMaskBit(x, y) {\n let bit\n\n if (x > y) {\n bit = x\n x = y\n y = bit\n }\n\n bit = y\n bit += y * y\n bit >>= 1\n bit += x\n\n return bit\n }\n\n static _modN(x) {\n while (x >= 255) {\n x -= 255\n x = (x >> 8) + (x & 255)\n }\n\n return x\n }\n\n // *Badness* coefficients.\n static get N1() {\n return 3\n }\n static get N2() {\n return 3\n }\n static get N3() {\n return 40\n }\n static get N4() {\n return 10\n }\n\n /**\n * Creates an instance of {@link Frame} based on the options provided.\n *\n * @param {Frame~Options} options - the options to be used\n * @public\n */\n constructor(options) {\n this._badness = []\n this._level = ErrorCorrection.LEVELS[options.level]\n this._polynomial = []\n this._value = options.value\n this._valueLength = this._value.length\n this._version = 0\n this._stringBuffer = this._value.slice(0)\n\n let dataBlock\n let eccBlock\n let neccBlock1\n let neccBlock2\n\n while (this._version < 40) {\n this._version++\n\n let index = (this._level - 1) * 4 + (this._version - 1) * 16\n\n neccBlock1 = ErrorCorrection.BLOCKS[index++]\n neccBlock2 = ErrorCorrection.BLOCKS[index++]\n dataBlock = ErrorCorrection.BLOCKS[index++]\n eccBlock = ErrorCorrection.BLOCKS[index]\n\n index = dataBlock * (neccBlock1 + neccBlock2) + neccBlock2 - 3 + (this._version <= 9)\n\n if (this._valueLength <= index) {\n break\n }\n }\n\n this._dataBlock = dataBlock\n this._eccBlock = eccBlock\n this._neccBlock1 = neccBlock1\n this._neccBlock2 = neccBlock2\n\n /**\n * The data width is based on version.\n *\n * @public\n * @type {Number}\n */\n // FIXME: Ensure that it fits instead of being truncated.\n this.width = 17 + 4 * this._version\n\n /**\n * The image buffer.\n *\n * @public\n * @type {Number[]}\n */\n this.buffer = Frame._createArray(this.width * this.width)\n\n this._ecc = Frame._createArray(this._dataBlock + (this._dataBlock + this._eccBlock) * (this._neccBlock1 + this._neccBlock2) + this._neccBlock2)\n this._mask = Frame._createArray((this.width * (this.width + 1) + 1) / 2)\n\n this._insertFinders()\n this._insertAlignments()\n\n // Insert single foreground cell.\n this.buffer[8 + this.width * (this.width - 8)] = 1\n\n this._insertTimingGap()\n this._reverseMask()\n this._insertTimingRowAndColumn()\n this._insertVersion()\n this._syncMask()\n this._convertBitStream(this._stringBuffer.length)\n this._calculatePolynomial()\n this._appendEccToData()\n this._interleaveBlocks()\n this._pack()\n this._finish()\n }\n\n _addAlignment(x, y) {\n this.buffer[x + this.width * y] = 1\n\n for (let i = -2; i < 2; i++) {\n this.buffer[x + i + this.width * (y - 2)] = 1\n this.buffer[x - 2 + this.width * (y + i + 1)] = 1\n this.buffer[x + 2 + this.width * (y + i)] = 1\n this.buffer[x + i + 1 + this.width * (y + 2)] = 1\n }\n\n for (let i = 0; i < 2; i++) {\n this._setMask(x - 1, y + i)\n this._setMask(x + 1, y - i)\n this._setMask(x - i, y - 1)\n this._setMask(x + i, y + 1)\n }\n }\n\n _appendData(data, dataLength, ecc, eccLength) {\n for (let i = 0; i < eccLength; i++) {\n this._stringBuffer[ecc + i] = 0\n }\n\n for (let i = 0; i < dataLength; i++) {\n const bit = Galois.LOG[this._stringBuffer[data + i] ^ this._stringBuffer[ecc]]\n\n if (bit !== 255) {\n for (let j = 1; j < eccLength; j++) {\n this._stringBuffer[ecc + j - 1] = this._stringBuffer[ecc + j] ^ Galois.EXPONENT[Frame._modN(bit + this._polynomial[eccLength - j])]\n }\n } else {\n for (let j = ecc; j < ecc + eccLength; j++) {\n this._stringBuffer[j] = this._stringBuffer[j + 1]\n }\n }\n\n this._stringBuffer[ecc + eccLength - 1] = bit === 255 ? 0 : Galois.EXPONENT[Frame._modN(bit + this._polynomial[0])]\n }\n }\n\n _appendEccToData() {\n let data = 0\n let ecc = this._calculateMaxLength()\n\n for (let i = 0; i < this._neccBlock1; i++) {\n this._appendData(data, this._dataBlock, ecc, this._eccBlock)\n\n data += this._dataBlock\n ecc += this._eccBlock\n }\n\n for (let i = 0; i < this._neccBlock2; i++) {\n this._appendData(data, this._dataBlock + 1, ecc, this._eccBlock)\n\n data += this._dataBlock + 1\n ecc += this._eccBlock\n }\n }\n\n _applyMask(mask) {\n const width = this.width\n\n switch (mask) {\n case 0:\n for (let y = 0; y < width; y++) {\n for (let x = 0; x < width; x++) {\n if (!(x + y & 1) && !this._isMasked(x, y)) {\n this.buffer[x + y * width] ^= 1\n }\n }\n }\n\n break\n case 1:\n for (let y = 0; y < width; y++) {\n for (let x = 0; x < width; x++) {\n if (!(y & 1) && !this._isMasked(x, y)) {\n this.buffer[x + y * width] ^= 1\n }\n }\n }\n\n break\n case 2:\n for (let y = 0; y < width; y++) {\n for (let r3x = 0, x = 0; x < width; x++, r3x++) {\n if (r3x === 3) {\n r3x = 0\n }\n\n if (!r3x && !this._isMasked(x, y)) {\n this.buffer[x + y * width] ^= 1\n }\n }\n }\n\n break\n case 3:\n for (let r3y = 0, y = 0; y < width; y++, r3y++) {\n if (r3y === 3) {\n r3y = 0\n }\n\n for (let r3x = r3y, x = 0; x < width; x++, r3x++) {\n if (r3x === 3) {\n r3x = 0\n }\n\n if (!r3x && !this._isMasked(x, y)) {\n this.buffer[x + y * width] ^= 1\n }\n }\n }\n\n break\n case 4:\n for (let y = 0; y < width; y++) {\n for (let r3x = 0, r3y = y >> 1 & 1, x = 0; x < width; x++, r3x++) {\n if (r3x === 3) {\n r3x = 0\n r3y = !r3y\n }\n\n if (!r3y && !this._isMasked(x, y)) {\n this.buffer[x + y * width] ^= 1\n }\n }\n }\n\n break\n case 5:\n for (let r3y = 0, y = 0; y < width; y++, r3y++) {\n if (r3y === 3) {\n r3y = 0\n }\n\n for (let r3x = 0, x = 0; x < width; x++, r3x++) {\n if (r3x === 3) {\n r3x = 0\n }\n\n if (!((x & y & 1) + !(!r3x | !r3y)) && !this._isMasked(x, y)) {\n this.buffer[x + y * width] ^= 1\n }\n }\n }\n\n break\n case 6:\n for (let r3y = 0, y = 0; y < width; y++, r3y++) {\n if (r3y === 3) {\n r3y = 0\n }\n\n for (let r3x = 0, x = 0; x < width; x++, r3x++) {\n if (r3x === 3) {\n r3x = 0\n }\n\n if (!(x & y & 1 + (r3x && r3x === r3y) & 1) && !this._isMasked(x, y)) {\n this.buffer[x + y * width] ^= 1\n }\n }\n }\n\n break\n case 7:\n for (let r3y = 0, y = 0; y < width; y++, r3y++) {\n if (r3y === 3) {\n r3y = 0\n }\n\n for (let r3x = 0, x = 0; x < width; x++, r3x++) {\n if (r3x === 3) {\n r3x = 0\n }\n\n if (!((r3x && r3x === r3y) + (x + y & 1) & 1) && !this._isMasked(x, y)) {\n this.buffer[x + y * width] ^= 1\n }\n }\n }\n\n break\n }\n }\n\n _calculateMaxLength() {\n return this._dataBlock * (this._neccBlock1 + this._neccBlock2) + this._neccBlock2\n }\n\n _calculatePolynomial() {\n this._polynomial[0] = 1\n\n for (let i = 0; i < this._eccBlock; i++) {\n this._polynomial[i + 1] = 1\n\n for (let j = i; j > 0; j--) {\n this._polynomial[j] = this._polynomial[j] ? this._polynomial[j - 1] ^ Galois.EXPONENT[Frame._modN(Galois.LOG[this._polynomial[j]] + i)] : this._polynomial[j - 1]\n }\n\n this._polynomial[0] = Galois.EXPONENT[Frame._modN(Galois.LOG[this._polynomial[0]] + i)]\n }\n\n // Use logs for generator polynomial to save calculation step.\n for (let i = 0; i <= this._eccBlock; i++) {\n this._polynomial[i] = Galois.LOG[this._polynomial[i]]\n }\n }\n\n _checkBadness() {\n let bad = 0\n const width = this.width\n\n // Blocks of same colour.\n for (let y = 0; y < width - 1; y++) {\n for (let x = 0; x < width - 1; x++) {\n // All foreground colour.\n if (this.buffer[x + width * y] &&\n this.buffer[x + 1 + width * y] &&\n this.buffer[x + width * (y + 1)] &&\n this.buffer[x + 1 + width * (y + 1)] ||\n // All background colour.\n !(this.buffer[x + width * y] ||\n this.buffer[x + 1 + width * y] ||\n this.buffer[x + width * (y + 1)] ||\n this.buffer[x + 1 + width * (y + 1)])) {\n bad += Frame.N2\n }\n }\n }\n\n let bw = 0\n\n // X runs.\n for (let y = 0; y < width; y++) {\n let h = 0\n\n this._badness[0] = 0\n\n for (let b = 0, x = 0; x < width; x++) {\n let b1 = this.buffer[x + width * y]\n\n if (b === b1) {\n this._badness[h]++\n } else {\n this._badness[++h] = 1\n }\n\n b = b1\n bw += b ? 1 : -1\n }\n\n bad += this._getBadness(h)\n }\n\n if (bw < 0) {\n bw = -bw\n }\n\n let count = 0\n let big = bw\n big += big << 2\n big <<= 1\n\n while (big > width * width) {\n big -= width * width\n count++\n }\n\n bad += count * Frame.N4\n\n // Y runs.\n for (let x = 0; x < width; x++) {\n let h = 0\n\n this._badness[0] = 0\n\n for (let b = 0, y = 0; y < width; y++) {\n let b1 = this.buffer[x + width * y]\n\n if (b === b1) {\n this._badness[h]++\n } else {\n this._badness[++h] = 1\n }\n\n b = b1\n }\n\n bad += this._getBadness(h)\n }\n\n return bad\n }\n\n _convertBitStream(length) {\n // Convert string to bit stream. 8-bit data to QR-coded 8-bit data (numeric, alphanum, or kanji\n // not supported).\n\n for (let i = 0; i < length; i++) {\n this._ecc[i] = this._stringBuffer.charCodeAt(i)\n }\n\n this._stringBuffer = this._ecc.slice(0)\n\n const maxLength = this._calculateMaxLength()\n\n if (length >= maxLength - 2) {\n length = maxLength - 2\n\n if (this._version > 9) {\n length--\n }\n }\n\n // Shift and re-pack to insert length prefix.\n let index = length\n\n if (this._version > 9) {\n this._stringBuffer[index + 2] = 0\n this._stringBuffer[index + 3] = 0\n\n while (index--) {\n const bit = this._stringBuffer[index]\n\n this._stringBuffer[index + 3] |= 255 & bit << 4\n this._stringBuffer[index + 2] = bit >> 4\n }\n\n this._stringBuffer[2] |= 255 & length << 4\n this._stringBuffer[1] = length >> 4\n this._stringBuffer[0] = 0x40 | length >> 12\n } else {\n this._stringBuffer[index + 1] = 0\n this._stringBuffer[index + 2] = 0\n\n while (index--) {\n const bit = this._stringBuffer[index]\n\n this._stringBuffer[index + 2] |= 255 & bit << 4\n this._stringBuffer[index + 1] = bit >> 4\n }\n\n this._stringBuffer[1] |= 255 & length << 4\n this._stringBuffer[0] = 0x40 | length >> 4\n }\n\n // Fill to end with pad pattern.\n index = length + 3 - (this._version < 10)\n\n while (index < maxLength) {\n this._stringBuffer[index++] = 0xec\n this._stringBuffer[index++] = 0x11\n }\n }\n\n _getBadness(length) {\n let badRuns = 0\n\n for (let i = 0; i <= length; i++) {\n if (this._badness[i] >= 5) {\n badRuns += Frame.N1 + this._badness[i] - 5\n }\n }\n\n // FBFFFBF as in finder.\n for (let i = 3; i < length - 1; i += 2) {\n if (this._badness[i - 2] === this._badness[i + 2] &&\n this._badness[i + 2] === this._badness[i - 1] &&\n this._badness[i - 1] === this._badness[i + 1] &&\n this._badness[i - 1] * 3 === this._badness[i] &&\n // Background around the foreground pattern? Not part of the specs.\n (this._badness[i - 3] === 0 || i + 3 > length ||\n this._badness[i - 3] * 3 >= this._badness[i] * 4 ||\n this._badness[i + 3] * 3 >= this._badness[i] * 4)) {\n badRuns += Frame.N3\n }\n }\n\n return badRuns\n }\n\n _finish() {\n // Save pre-mask copy of frame.\n this._stringBuffer = this.buffer.slice(0)\n\n let bit = 0\n let i\n let mask = 30000\n\n /*\n * Using for instead of while since in original Arduino code if an early mask was \"good enough\" it wouldn't try for\n * a better one since they get more complex and take longer.\n */\n for (i = 0; i < 8; i++) {\n // Returns foreground-background imbalance.\n this._applyMask(i)\n\n const currentMask = this._checkBadness()\n\n // Is current mask better than previous best?\n if (currentMask < mask) {\n mask = currentMask\n bit = i\n }\n\n // Don't increment \"i\" to a void redoing mask.\n if (bit === 7) {\n break\n }\n\n // Reset for next pass.\n this.buffer = this._stringBuffer.slice(0)\n }\n\n // Redo best mask as none were \"good enough\" (i.e. last wasn't bit).\n if (bit !== i) {\n this._applyMask(bit)\n }\n\n // Add in final mask/ECC level bytes.\n mask = ErrorCorrection.FINAL_FORMAT[bit + (this._level - 1 << 3)]\n\n // Low byte.\n for (i = 0; i < 8; i++, mask >>= 1) {\n if (mask & 1) {\n this.buffer[this.width - 1 - i + this.width * 8] = 1\n\n if (i < 6) {\n this.buffer[8 + this.width * i] = 1\n } else {\n this.buffer[8 + this.width * (i + 1)] = 1\n }\n }\n }\n\n // High byte.\n for (i = 0; i < 7; i++, mask >>= 1) {\n if (mask & 1) {\n this.buffer[8 + this.width * (this.width - 7 + i)] = 1\n\n if (i) {\n this.buffer[6 - i + this.width * 8] = 1\n } else {\n this.buffer[7 + this.width * 8] = 1\n }\n }\n }\n }\n\n _interleaveBlocks() {\n const maxLength = this._calculateMaxLength()\n let i\n let k = 0\n\n for (i = 0; i < this._dataBlock; i++) {\n for (let j = 0; j < this._neccBlock1; j++) {\n this._ecc[k++] = this._stringBuffer[i + j * this._dataBlock]\n }\n\n for (let j = 0; j < this._neccBlock2; j++) {\n this._ecc[k++] = this._stringBuffer[this._neccBlock1 * this._dataBlock + i + j * (this._dataBlock + 1)]\n }\n }\n\n for (let j = 0; j < this._neccBlock2; j++) {\n this._ecc[k++] = this._stringBuffer[this._neccBlock1 * this._dataBlock + i + j * (this._dataBlock + 1)]\n }\n\n for (i = 0; i < this._eccBlock; i++) {\n for (let j = 0; j < this._neccBlock1 + this._neccBlock2; j++) {\n this._ecc[k++] = this._stringBuffer[maxLength + i + j * this._eccBlock]\n }\n }\n\n this._stringBuffer = this._ecc\n }\n\n _insertAlignments() {\n const width = this.width\n\n if (this._version > 1) {\n const i = Alignment.BLOCK[this._version]\n let y = width - 7\n\n for (;;) {\n let x = width - 7\n\n while (x > i - 3) {\n this._addAlignment(x, y)\n\n if (x < i) {\n break\n }\n\n x -= i\n }\n\n if (y <= i + 9) {\n break\n }\n\n y -= i\n\n this._addAlignment(6, y)\n this._addAlignment(y, 6)\n }\n }\n }\n\n _insertFinders() {\n const width = this.width\n\n for (let i = 0; i < 3; i++) {\n let j = 0\n let y = 0\n\n if (i === 1) {\n j = width - 7\n }\n if (i === 2) {\n y = width - 7\n }\n\n this.buffer[y + 3 + width * (j + 3)] = 1\n\n for (let x = 0; x < 6; x++) {\n this.buffer[y + x + width * j] = 1\n this.buffer[y + width * (j + x + 1)] = 1\n this.buffer[y + 6 + width * (j + x)] = 1\n this.buffer[y + x + 1 + width * (j + 6)] = 1\n }\n\n for (let x = 1; x < 5; x++) {\n this._setMask(y + x, j + 1)\n this._setMask(y + 1, j + x + 1)\n this._setMask(y + 5, j + x)\n this._setMask(y + x + 1, j + 5)\n }\n\n for (let x = 2; x < 4; x++) {\n this.buffer[y + x + width * (j + 2)] = 1\n this.buffer[y + 2 + width * (j + x + 1)] = 1\n this.buffer[y + 4 + width * (j + x)] = 1\n this.buffer[y + x + 1 + width * (j + 4)] = 1\n }\n }\n }\n\n _insertTimingGap() {\n const width = this.width\n\n for (let y = 0; y < 7; y++) {\n this._setMask(7, y)\n this._setMask(width - 8, y)\n this._setMask(7, y + width - 7)\n }\n\n for (let x = 0; x < 8; x++) {\n this._setMask(x, 7)\n this._setMask(x + width - 8, 7)\n this._setMask(x, width - 8)\n }\n }\n\n _insertTimingRowAndColumn() {\n const width = this.width\n\n for (let x = 0; x < width - 14; x++) {\n if (x & 1) {\n this._setMask(8 + x, 6)\n this._setMask(6, 8 + x)\n } else {\n this.buffer[8 + x + width * 6] = 1\n this.buffer[6 + width * (8 + x)] = 1\n }\n }\n }\n\n _insertVersion() {\n const width = this.width\n\n if (this._version > 6) {\n let i = Version.BLOCK[this._version - 7]\n let j = 17\n\n for (let x = 0; x < 6; x++) {\n for (let y = 0; y < 3; y++, j--) {\n if (1 & (j > 11 ? this._version >> j - 12 : i >> j)) {\n this.buffer[5 - x + width * (2 - y + width - 11)] = 1\n this.buffer[2 - y + width - 11 + width * (5 - x)] = 1\n } else {\n this._setMask(5 - x, 2 - y + width - 11)\n this._setMask(2 - y + width - 11, 5 - x)\n }\n }\n }\n }\n }\n\n _isMasked(x, y) {\n const bit = Frame._getMaskBit(x, y)\n\n return this._mask[bit] === 1\n }\n\n _pack() {\n let x = this.width - 1\n let y = this.width - 1\n let k = 1\n let v = 1\n\n // Interleaved data and ECC codes.\n const length = (this._dataBlock + this._eccBlock) * (this._neccBlock1 + this._neccBlock2) + this._neccBlock2\n\n for (let i = 0; i < length; i++) {\n let bit = this._stringBuffer[i]\n\n for (let j = 0; j < 8; j++, bit <<= 1) {\n if (0x80 & bit) {\n this.buffer[x + this.width * y] = 1\n }\n\n // Find next fill position.\n do {\n if (v) {\n x--\n } else {\n x++\n\n if (k) {\n if (y !== 0) {\n y--\n } else {\n x -= 2\n k = !k\n\n if (x === 6) {\n x--\n y = 9\n }\n }\n } else if (y !== this.width - 1) {\n y++\n } else {\n x -= 2\n k = !k\n\n if (x === 6) {\n x--\n y -= 8\n }\n }\n }\n\n v = !v\n } while (this._isMasked(x, y))\n }\n }\n }\n\n _reverseMask() {\n const width = this.width\n\n for (let x = 0; x < 9; x++) {\n this._setMask(x, 8)\n }\n\n for (let x = 0; x < 8; x++) {\n this._setMask(x + width - 8, 8)\n this._setMask(8, x)\n }\n\n for (let y = 0; y < 7; y++) {\n this._setMask(8, y + width - 7)\n }\n }\n\n _setMask(x, y) {\n const bit = Frame._getMaskBit(x, y)\n\n this._mask[bit] = 1\n }\n\n _syncMask() {\n const width = this.width\n\n for (let y = 0; y < width; y++) {\n for (let x = 0; x <= y; x++) {\n if (this.buffer[x + width * y]) {\n this._setMask(x, y)\n }\n }\n }\n }\n}\n\nexport default Frame\n\n/**\n * The options used by {@link Frame}.\n *\n * @typedef {Object} Frame~Options\n * @property {String} level - The ECC level to be used.\n * @property {String} value - The value to be encoded.\n */\n","/*\n * QRious\n * Copyright (C) 2016 Alasdair Mercer\n * Copyright (C) 2010 Tom Zerucha\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see .\n */\n\nimport Renderer from './Renderer'\n\n/**\n * An implementation of {@link Renderer} for working with img elements.\n *\n * This depends on {@link CanvasRenderer} being executed first as this implementation simply applies the data URL from\n * the rendered canvas element as the src for the img element being rendered.\n *\n * @public\n * @extends Renderer\n */\nclass ImageRenderer extends Renderer {\n\n /**\n * @override\n */\n draw() {\n const qrious = this.qrious\n\n qrious.image.src = qrious.toDataURL()\n }\n\n /**\n * @override\n */\n reset() {\n const qrious = this.qrious\n\n qrious.image.src = ''\n }\n\n /**\n * @override\n */\n resize() {\n const qrious = this.qrious\n const image = qrious.image\n\n image.width = qrious.size\n image.height = qrious.size\n }\n}\n\nexport default ImageRenderer\n","/*\n * QRious\n * Copyright (C) 2016 Alasdair Mercer\n * Copyright (C) 2010 Tom Zerucha\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see .\n */\n\n/**\n * A basic manager for {@link Service} implementations that are mapped to simple names.\n *\n * @public\n */\nclass ServiceManager {\n\n /**\n * Creates a new instance of {@link ServiceManager}.\n *\n * @public\n */\n constructor() {\n this._services = {}\n }\n\n /**\n * Returns the {@link Service} being managed with the specified name.\n *\n * @param {String} name - the name of the {@link Service} to be returned\n * @return {Service} The {@link Service} is being managed with name.\n * @throws {Error} If no {@link Service} is being managed with name.\n * @public\n */\n getService(name) {\n const service = this._services[name]\n if (!service) {\n throw new Error(`Service is not being managed with name: ${name}`)\n }\n\n return service\n }\n\n /**\n * Sets the {@link Service} implementation to be managed for the specified name to the\n * service provided.\n *\n * @param {String} name - the name of the {@link Service} to be managed with name\n * @param {Service} service - the {@link Service} implementation to be managed\n * @throws {Error} If a {@link Service} is already being managed with the same name.\n * @public\n */\n setService(name, service) {\n if (this._services[name]) {\n throw new Error(`Service is already managed with name: ${name}`)\n }\n\n if (service) {\n this._services[name] = service\n }\n }\n}\n\nexport default ServiceManager\n","/*\n * QRious\n * Copyright (C) 2016 Alasdair Mercer\n * Copyright (C) 2010 Tom Zerucha\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see .\n */\n\nimport CanvasRenderer from './renderer/CanvasRenderer'\nimport Frame from './Frame'\nimport ImageRenderer from './renderer/ImageRenderer'\nimport ServiceManager from './service/ServiceManager'\nimport Utilities from './util/Utilities'\n\n/**\n * Enables configuration of a QR code generator which uses HTML5 canvas for rendering.\n *\n * @public\n */\nclass QRious {\n\n /**\n * Returns the default options for {@link QRious}.\n *\n * @return {QRious~Options} The default options.\n * @public\n * @static\n */\n static get DEFAULTS() {\n return {\n background: 'white',\n foreground: 'black',\n level: 'L',\n mime: 'image/png',\n size: 100,\n value: ''\n }\n }\n\n /**\n * Returns the current version of {@link QRious}.\n *\n * @return {String} The current version.\n * @public\n * @static\n */\n static get VERSION() {\n return '2.0.0'\n }\n\n /**\n * Configures the service provided to be used by all {@link QRious} instances.\n *\n * @param {Service} service - the {@link Service} to be configured\n * @throws {Error} If a {@link Service} has already been configured with the same name.\n * @public\n * @static\n */\n static use(service) {\n QRious._serviceManager.setService(service.getName(), service)\n }\n\n static _parseOptions(options) {\n options = Object.assign({}, QRious.DEFAULTS, options)\n options.level = Utilities.toUpperCase(options.level)\n options.size = Math.abs(options.size)\n\n return options\n }\n\n /**\n * Creates a new instance of {@link QRious} based on the options provided.\n *\n * @param {QRious~Options} [options] - the options to be used\n * @public\n */\n constructor(options) {\n options = QRious._parseOptions(options)\n\n Utilities.privatize(this, options)\n\n let element = this._element\n let elementService = QRious._serviceManager.getService('element')\n\n /**\n * The canvas being used to render the QR code for this {@link QRious}.\n *\n * @public\n * @type {*}\n */\n this.canvas = element && elementService.isCanvas(element) ? element : elementService.createCanvas()\n this.canvas.qrious = this\n\n /**\n * The img to contain the rendered QR code for this {@link QRious}.\n *\n * @public\n * @type {*}\n */\n this.image = element && elementService.isImage(element) ? element : elementService.createImage()\n this.image.qrious = this\n\n this._renderers = [\n new CanvasRenderer(this),\n new ImageRenderer(this)\n ]\n\n this.update()\n }\n\n /**\n * Returns the image data URI for the generated QR code using the mime provided.\n *\n * @param {String} [mime] - the MIME type for the image\n * @return {String} The image data URI for the QR code.\n * @public\n */\n toDataURL(mime) {\n return this.canvas.toDataURL(mime || this.mime)\n }\n\n /**\n * Updates this {@link QRious} by generating a new {@link Frame} and re-rendering the QR code.\n *\n * @protected\n */\n update() {\n const frame = new Frame({\n level: this.level,\n value: this.value\n })\n\n this._renderers.forEach((renderer) => renderer.render(frame))\n }\n\n /**\n * Returns the background color for the QR code.\n *\n * @return {String} The background color.\n * @public\n */\n get background() {\n return this._background\n }\n\n /**\n * Sets the background color for the QR code to background.\n *\n * @param {String} [background=\"white\"] - the background color to be set\n * @public\n */\n set background(background) {\n const changed = Utilities.setter(this, '_background', background, QRious.DEFAULTS.background)\n\n if (changed) {\n this.update()\n }\n }\n\n /**\n * Returns the foreground color for the QR code.\n *\n * @return {String} The foreground color.\n * @public\n */\n get foreground() {\n return this._foreground\n }\n\n /**\n * Sets the foreground color for the QR code to foreground.\n *\n * @param {String} [foreground=\"black\"] - the foreground color to be set\n * @public\n */\n set foreground(foreground) {\n const changed = Utilities.setter(this, '_foreground', foreground, QRious.DEFAULTS.foreground)\n\n if (changed) {\n this.update()\n }\n }\n\n /**\n * Returns the error correction level for the QR code.\n *\n * @return {String} The ECC level.\n * @public\n */\n get level() {\n return this._level\n }\n\n /**\n * Sets the error correction level for the QR code to level.\n *\n * level will be transformed to upper case to aid mapping to known ECC level blocks.\n *\n * @param {String} [level=\"L\"] - the ECC level to be set\n * @public\n */\n set level(level) {\n const changed = Utilities.setter(this, '_level', level, QRious.DEFAULTS.level, Utilities.toUpperCase)\n\n if (changed) {\n this.update()\n }\n }\n\n /**\n * Returns the MIME type for the image rendered for the QR code.\n *\n * @return {String} The image MIME type.\n * @public\n */\n get mime() {\n return this._mime\n }\n\n /**\n * Sets the MIME type for the image rendered for the QR code to mime.\n *\n * @param {String} [mime=\"image/png\"] - the image MIME type to be set\n * @public\n */\n set mime(mime) {\n const changed = Utilities.setter(this, '_mime', mime, QRious.DEFAULTS.mime)\n\n if (changed) {\n this.update()\n }\n }\n\n /**\n * Returns the size of the QR code.\n *\n * @return {Number} The size in pixels.\n * @public\n */\n get size() {\n return this._size\n }\n\n /**\n * Sets the size of the QR code to size.\n *\n * size will be transformed to ensure that it is always an absolute positive numbers (e.g.\n * -100 would become 100).\n *\n * @param {Number} [size=100] - the size in pixels to be set\n * @public\n */\n set size(size) {\n const changed = Utilities.setter(this, '_size', size, QRious.DEFAULTS.size, Math.abs)\n\n if (changed) {\n this.update()\n }\n }\n\n /**\n * Returns the value of the QR code.\n *\n * @return {String} The value.\n * @public\n */\n get value() {\n return this._value\n }\n\n /**\n * Sets the value of the QR code to value.\n *\n * @param {String} [value=\"\"] - the value to be set\n * @public\n */\n set value(value) {\n const changed = Utilities.setter(this, '_value', value, QRious.DEFAULTS.value)\n\n if (changed) {\n this.update()\n }\n }\n}\n\nQRious._serviceManager = new ServiceManager()\n\nexport default QRious\n\n/**\n * The options used by {@link QRious}.\n *\n * @typedef {Object} QRious~Options\n * @property {String} [background=\"white\"] - The background color to be applied to the QR code.\n * @property {*} [element] - The element to be used to render the QR code which may either be an canvas or\n * img. The element(s) will be created if needed.\n * @property {String} [foreground=\"black\"] - The foreground color to be applied to the QR code.\n * @property {String} [level=\"L\"] - The error correction level to be applied to the QR code.\n * @property {String} [mime=\"image/png\"] - The MIME type to be used to render the image for the QR code.\n * @property {Number} [size=100] - The size of the QR code in pixels.\n * @property {String} [value=\"\"] - The value to be encoded within the QR code.\n */\n","/*\n * QRious\n * Copyright (C) 2016 Alasdair Mercer\n * Copyright (C) 2010 Tom Zerucha\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see .\n */\n\nimport NodeElementService from '../service/element/NodeElementService'\nimport QRious from '../QRious'\n\nQRious.use(new NodeElementService())\n\nexport default QRious\n"],"names":["Canvas","Image"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA+EO,IAAI,cAAc,GAAG,UAAU,QAAQ,EAAE,WAAW,EAAE;EAC3D,IAAI,CAAC,CAAC,QAAQ,YAAY,WAAW,CAAC,EAAE;IACtC,MAAM,IAAI,SAAS,CAAC,mCAAmC,CAAC,CAAC;GAC1D;CACF,CAAC;;AAEF,AAAO,IAAI,WAAW,GAAG,YAAY;EACnC,SAAS,gBAAgB,CAAC,MAAM,EAAE,KAAK,EAAE;IACvC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;MACrC,IAAI,UAAU,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;MAC1B,UAAU,CAAC,UAAU,GAAG,UAAU,CAAC,UAAU,IAAI,KAAK,CAAC;MACvD,UAAU,CAAC,YAAY,GAAG,IAAI,CAAC;MAC/B,IAAI,OAAO,IAAI,UAAU,EAAE,UAAU,CAAC,QAAQ,GAAG,IAAI,CAAC;MACtD,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,UAAU,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;KAC3D;GACF;;EAED,OAAO,UAAU,WAAW,EAAE,UAAU,EAAE,WAAW,EAAE;IACrD,IAAI,UAAU,EAAE,gBAAgB,CAAC,WAAW,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;IACpE,IAAI,WAAW,EAAE,gBAAgB,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;IAC5D,OAAO,WAAW,CAAC;GACpB,CAAC;CACH,EAAE,CAAC;;AAEJ,AAWA,AAeA,AAeA,AAcA,AAyBA,AAAO,IAAI,QAAQ,GAAG,UAAU,QAAQ,EAAE,UAAU,EAAE;EACpD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;;sBAWQ,OAAO;UACT,UAAU,UAAU,MAAV,CAAiB,IAAjB,EAAuB,QAAvB,EAAiC,KAAjC,EAAwC,OAAO,QAAP,CAAgB,KAAxD,EAA+D,UAAU,WAAzE,CAAhB;;UAEI,OAAJ,EAAa;aACN,MAAL;;;;;;;;;;;;;wBAUO;aACF,KAAK,KAAZ;;;;;;;;;;sBASO,MAAM;UACP,UAAU,UAAU,MAAV,CAAiB,IAAjB,EAAuB,OAAvB,EAAgC,IAAhC,EAAsC,OAAO,QAAP,CAAgB,IAAtD,CAAhB;;UAEI,OAAJ,EAAa;aACN,MAAL;;;;;;;;;;;;;wBAUO;aACF,KAAK,KAAZ;;;;;;;;;;;;;sBAYO,MAAM;UACP,UAAU,UAAU,MAAV,CAAiB,IAAjB,EAAuB,OAAvB,EAAgC,IAAhC,EAAsC,OAAO,QAAP,CAAgB,IAAtD,EAA4D,KAAK,GAAjE,CAAhB;;UAEI,OAAJ,EAAa;aACN,MAAL;;;;;;;;;;;;;wBAUQ;aACH,KAAK,MAAZ;;;;;;;;;;sBASQ,OAAO;UACT,UAAU,UAAU,MAAV,CAAiB,IAAjB,EAAuB,QAAvB,EAAiC,KAAjC,EAAwC,OAAO,QAAP,CAAgB,KAAxD,CAAhB;;UAEI,OAAJ,EAAa;aACN,MAAL;;;;;;;AAKN,OAAO,eAAP,GAAyB,IAAI,cAAJ,EAAzB,CAEA;;ACpRA,OAAO,GAAP,CAAW,IAAI,kBAAJ,EAAX,EAEA;;"} \ No newline at end of file diff --git a/dist/umd/qrious.js b/dist/umd/qrious.js new file mode 100644 index 0000000..78c102c --- /dev/null +++ b/dist/umd/qrious.js @@ -0,0 +1,2162 @@ +/* + * QRious v2.0.0 + * Copyright (C) 2016 Alasdair Mercer + * Copyright (C) 2010 Tom Zerucha + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : + typeof define === 'function' && define.amd ? define('qrious', factory) : + (global.QRious = factory()); +}(this, function () { 'use strict'; + + var classCallCheck = function (instance, Constructor) { + if (!(instance instanceof Constructor)) { + throw new TypeError("Cannot call a class as a function"); + } + }; + + var createClass = function () { + function defineProperties(target, props) { + for (var i = 0; i < props.length; i++) { + var descriptor = props[i]; + descriptor.enumerable = descriptor.enumerable || false; + descriptor.configurable = true; + if ("value" in descriptor) descriptor.writable = true; + Object.defineProperty(target, descriptor.key, descriptor); + } + } + + return function (Constructor, protoProps, staticProps) { + if (protoProps) defineProperties(Constructor.prototype, protoProps); + if (staticProps) defineProperties(Constructor, staticProps); + return Constructor; + }; + }(); + + var inherits = function (subClass, superClass) { + if (typeof superClass !== "function" && superClass !== null) { + throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); + } + + subClass.prototype = Object.create(superClass && superClass.prototype, { + constructor: { + value: subClass, + enumerable: false, + writable: true, + configurable: true + } + }); + if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; + }; + + var possibleConstructorReturn = function (self, call) { + if (!self) { + throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); + } + + return call && (typeof call === "object" || typeof call === "function") ? call : self; + }; + + /* + * QRious + * Copyright (C) 2016 Alasdair Mercer + * Copyright (C) 2010 Tom Zerucha + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + + /** + * Contains utility methods that are useful throughout the library. + * + * @public + */ + + var Utilities = function () { + function Utilities() { + classCallCheck(this, Utilities); + } + + createClass(Utilities, null, [{ + key: 'privatize', + + + /** + * Copies all properties from the source object to the target object, however, all property + * names on the target will be prefixed with an underscore, used to indicate that they are private. + * + * @param {Object} target - the object to which the private fields are to be copied + * @param {Object} source - the object from which the fields are to be copied + * @return {Object} A reference to the target object. + * @public + * @static + */ + value: function privatize(target, source) { + for (var key in source) { + if (source.hasOwnProperty(key)) { + target['_' + key] = source[key]; + } + } + + return target; + } + + /** + * Sets the specified value on a given field on the object provided. + * + * If value is null, the specified default value will be used instead. + * + * An optional transformer can be specified which will be used to transform the value (or default value) + * before it is assigned to the field. + * + * @param {Object} object - the object whose field is to be set with value + * @param {String} fieldName - the field to be set with value + * @param {*} value - the value to be set on the named field + * @param {*} [defaultValue] - the value to be used if value is null + * @param {Function} [transformer] - a function used to transform the value before it is assigned to the named field + * @return {Boolean} true if the value of the field has changed as a result of the assignment; otherwise + * false. + * @public + * @static + */ + + }, { + key: 'setter', + value: function setter(object, fieldName, value, defaultValue, transformer) { + var oldValue = object[fieldName]; + var newValue = value != null ? value : defaultValue; + if (typeof transformer === 'function') { + newValue = transformer(newValue); + } + + object[fieldName] = newValue; + + return newValue !== oldValue; + } + + /** + * Throws an error indicating that the a given method on a specific class has not been implemented. + * + * @param {String} className - the name of the class on which the method has not been implemented + * @param {String} methodName - the name of the method which has not been implemented + * @throws {Error} The error describing the class method which has not been implemented. + * @public + * @static + */ + + }, { + key: 'throwUnimplemented', + value: function throwUnimplemented(className, methodName) { + throw new Error('"' + methodName + '" method must be implemented on the ' + className + ' class'); + } + + /** + * Transforms the specified string to upper case while remaining null-safe. + * + * @param {String} string - the string to be transformed to upper case + * @return {String} string transformed to upper case if string is not null. + * @public + * @static + */ + + }, { + key: 'toUpperCase', + value: function toUpperCase(string) { + return string != null && string.toUpperCase(); + } + }]); + return Utilities; + }(); + + /** + * Defines a service contract that must be met by all implementations. + * + * @public + */ + + var Service = function () { + function Service() { + classCallCheck(this, Service); + } + + createClass(Service, [{ + key: 'getName', + + + /** + * Returns the name of this {@link Service}. + * + * @return {String} The service name. + * @public + */ + value: function getName() { + Utilities.throwUnimplemented('Service', 'getName'); + } + }]); + return Service; + }(); + + /** + * A service for working with elements. + * + * @public + * @extends Service + */ + + var ElementService = function (_Service) { + inherits(ElementService, _Service); + + function ElementService() { + classCallCheck(this, ElementService); + return possibleConstructorReturn(this, Object.getPrototypeOf(ElementService).apply(this, arguments)); + } + + createClass(ElementService, [{ + key: 'createCanvas', + + + /** + * Creates an instance of a canvas element. + * + * @return {*} The newly created canvas element. + * @public + */ + value: function createCanvas() { + Utilities.throwUnimplemented('ElementService', 'createCanvas'); + } + + /** + * Creates an instance of a image element. + * + * @return {*} The newly created image element. + * @public + */ + + }, { + key: 'createImage', + value: function createImage() { + Utilities.throwUnimplemented('ElementService', 'createImage'); + } + + /** + * @override + */ + + }, { + key: 'getName', + value: function getName() { + return 'element'; + } + + /** + * Returns whether the specified element is a canvas. + * + * @param {*} element - the element to be checked + * @return {Boolean} true if element is a canvas; otherwise false. + * @public + */ + + }, { + key: 'isCanvas', + value: function isCanvas(element) { + Utilities.throwUnimplemented('ElementService', 'isCanvas'); + } + + /** + * Returns whether the specified element is an image. + * + * @param {*} element - the element to be checked + * @return {Boolean} true if element is an image; otherwise false. + * @public + */ + + }, { + key: 'isImage', + value: function isImage(element) { + Utilities.throwUnimplemented('ElementService', 'isImage'); + } + }]); + return ElementService; + }(Service); + + /** + * An implementation of {@link ElementService} intended for use within a browser environment. + * + * @public + * @extends ElementService + */ + + var BrowserElementService = function (_ElementService) { + inherits(BrowserElementService, _ElementService); + + function BrowserElementService() { + classCallCheck(this, BrowserElementService); + return possibleConstructorReturn(this, Object.getPrototypeOf(BrowserElementService).apply(this, arguments)); + } + + createClass(BrowserElementService, [{ + key: 'createCanvas', + + + /** + * @override + */ + value: function createCanvas() { + return document.createElement('canvas'); + } + + /** + * @override + */ + + }, { + key: 'createImage', + value: function createImage() { + return document.createElement('img'); + } + + /** + * @override + */ + + }, { + key: 'isCanvas', + value: function isCanvas(element) { + return element instanceof HTMLCanvasElement; + } + + /** + * @override + */ + + }, { + key: 'isImage', + value: function isImage(element) { + return element instanceof HTMLImageElement; + } + }]); + return BrowserElementService; + }(ElementService); + + /** + * Responsible for rendering a QR code {@link Frame} on a specific type of element. + * + * A renderer may be dependant on the rendering of another element, so ordering of their execution is important. + * + * @public + */ + + var Renderer = function () { + + /** + * Creates a new instance of {@link Renderer} for the qrious instance provided. + * + * @param {QRious} qrious - the {@link QRious} instance to be used + * @public + */ + + function Renderer(qrious) { + classCallCheck(this, Renderer); + + /** + * The {@link QRious} instance. + * + * @protected + * @type {QRious} + */ + this.qrious = qrious; + } + + /** + * Draws the specified QR code frame on the underlying element. + * + * Implementations of {@link Renderer} must override this method with their own specific logic. + * + * @param {Frame} frame - the {@link Frame} to be drawn + * @protected + */ + + + createClass(Renderer, [{ + key: 'draw', + value: function draw(frame) { + Utilities.throwUnimplemented('Renderer', 'draw'); + } + + /** + * Calculates the size (in pixel units) to represent an individual module within the QR code based on the + * frame provided. + * + * The returned value will be at least one, even in cases where the size of the QR code does not fit its contents. + * This is done so that the inevitable clipping is handled more gracefully since this way at least something is + * displayed instead of just a blank space filled by the background color. + * + * @param {Frame} frame - the {@link Frame} from which the module size is to be derived + * @return {Number} The pixel size for each module in the QR code which will be no less than one. + * @protected + */ + + }, { + key: 'getModuleSize', + value: function getModuleSize(frame) { + var pixels = Math.floor(this.qrious.size / frame.width); + + return Math.max(1, pixels); + } + + /** + * Calculates the offset/padding (in pixel units) to be inserted before the QR code based on the frame + * provided. + * + * The returned value will be zero if there is no available offset or if the size of the QR code does not fit its + * contents. It will never be a negative value. This is done so that the inevitable clipping appears more naturally + * and it is not clipped from all directions. + * + * @param {Frame} frame - the {@link Frame} from which the offset is to be derived + * @return {Number} The pixel offset for the QR code which will be no less than zero. + * @protected + */ + + }, { + key: 'getOffset', + value: function getOffset(frame) { + var moduleSize = this.getModuleSize(frame); + var offset = Math.floor((this.qrious.size - moduleSize * frame.width) / 2); + + return Math.max(0, offset); + } + + /** + * Renders a QR code on the underlying element based on the frame provided. + * + * @param {Frame} frame - the {@link Frame} to be rendered + * @public + */ + + }, { + key: 'render', + value: function render(frame) { + this.resize(); + this.reset(); + this.draw(frame); + } + + /** + * Resets the underlying element, effectively clearing any previously rendered QR code. + * + * Implementations of {@link Renderer} must override this method with their own specific logic. + * + * @protected + */ + + }, { + key: 'reset', + value: function reset() { + Utilities.throwUnimplemented('Renderer', 'reset'); + } + + /** + * Ensures that the size of the underlying element matches that defined on the associated {@link QRious} instance. + * + * Implementations of {@link Renderer} must override this method with their own specific logic. + * + * @protected + */ + + }, { + key: 'resize', + value: function resize() { + Utilities.throwUnimplemented('Renderer', 'resize'); + } + }]); + return Renderer; + }(); + + /** + * An implementation of {@link Renderer} for working with canvas elements. + * + * @public + * @extends Renderer + */ + + var CanvasRenderer = function (_Renderer) { + inherits(CanvasRenderer, _Renderer); + + function CanvasRenderer() { + classCallCheck(this, CanvasRenderer); + return possibleConstructorReturn(this, Object.getPrototypeOf(CanvasRenderer).apply(this, arguments)); + } + + createClass(CanvasRenderer, [{ + key: 'draw', + + + /** + * @override + */ + value: function draw(frame) { + var qrious = this.qrious; + var moduleSize = this.getModuleSize(frame); + var offset = this.getOffset(frame); + var context = qrious.canvas.getContext('2d'); + + context.fillStyle = qrious.foreground; + + for (var i = 0; i < frame.width; i++) { + for (var j = 0; j < frame.width; j++) { + if (frame.buffer[j * frame.width + i]) { + context.fillRect(moduleSize * i + offset, moduleSize * j + offset, moduleSize, moduleSize); + } + } + } + } + + /** + * @override + */ + + }, { + key: 'reset', + value: function reset() { + var qrious = this.qrious; + var context = qrious.canvas.getContext('2d'); + + context.lineWidth = 1; + context.clearRect(0, 0, qrious.size, qrious.size); + context.fillStyle = qrious.background; + context.fillRect(0, 0, qrious.size, qrious.size); + } + + /** + * @override + */ + + }, { + key: 'resize', + value: function resize() { + var qrious = this.qrious; + var canvas = qrious.canvas; + + canvas.width = qrious.size; + canvas.height = qrious.size; + } + }]); + return CanvasRenderer; + }(Renderer); + + /* + * QRious + * Copyright (C) 2016 Alasdair Mercer + * Copyright (C) 2010 Tom Zerucha + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + + /* eslint no-multi-spaces: 0 */ + + /** + * Contains alignment pattern information. + * + * @public + */ + + var Alignment = function () { + function Alignment() { + classCallCheck(this, Alignment); + } + + createClass(Alignment, null, [{ + key: "BLOCK", + + + /** + * Returns the alignment pattern block. + * + * @return {Number[]} The alignment pattern block. + * @public + * @static + */ + get: function get() { + return [0, 11, 15, 19, 23, 27, 31, 16, 18, 20, 22, 24, 26, 28, 20, 22, 24, 24, 26, 28, 28, 22, 24, 24, 26, 26, 28, 28, 24, 24, 26, 26, 26, 28, 28, 24, 26, 26, 26, 28, 28]; + } + }]); + return Alignment; + }(); + + /* + * QRious + * Copyright (C) 2016 Alasdair Mercer + * Copyright (C) 2010 Tom Zerucha + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + + /* eslint no-multi-spaces: 0 */ + + /** + * Contains error correction information. + * + * @public + */ + + var ErrorCorrection = function () { + function ErrorCorrection() { + classCallCheck(this, ErrorCorrection); + } + + createClass(ErrorCorrection, null, [{ + key: "BLOCKS", + + + /** + * Returns the error correction blocks. + * + * There are four elements per version. The first two indicate the number of blocks, then the data width, and finally + * the ECC width. + * + * @return {Number[]} The ECC blocks. + * @public + * @static + */ + get: function get() { + return [1, 0, 19, 7, 1, 0, 16, 10, 1, 0, 13, 13, 1, 0, 9, 17, 1, 0, 34, 10, 1, 0, 28, 16, 1, 0, 22, 22, 1, 0, 16, 28, 1, 0, 55, 15, 1, 0, 44, 26, 2, 0, 17, 18, 2, 0, 13, 22, 1, 0, 80, 20, 2, 0, 32, 18, 2, 0, 24, 26, 4, 0, 9, 16, 1, 0, 108, 26, 2, 0, 43, 24, 2, 2, 15, 18, 2, 2, 11, 22, 2, 0, 68, 18, 4, 0, 27, 16, 4, 0, 19, 24, 4, 0, 15, 28, 2, 0, 78, 20, 4, 0, 31, 18, 2, 4, 14, 18, 4, 1, 13, 26, 2, 0, 97, 24, 2, 2, 38, 22, 4, 2, 18, 22, 4, 2, 14, 26, 2, 0, 116, 30, 3, 2, 36, 22, 4, 4, 16, 20, 4, 4, 12, 24, 2, 2, 68, 18, 4, 1, 43, 26, 6, 2, 19, 24, 6, 2, 15, 28, 4, 0, 81, 20, 1, 4, 50, 30, 4, 4, 22, 28, 3, 8, 12, 24, 2, 2, 92, 24, 6, 2, 36, 22, 4, 6, 20, 26, 7, 4, 14, 28, 4, 0, 107, 26, 8, 1, 37, 22, 8, 4, 20, 24, 12, 4, 11, 22, 3, 1, 115, 30, 4, 5, 40, 24, 11, 5, 16, 20, 11, 5, 12, 24, 5, 1, 87, 22, 5, 5, 41, 24, 5, 7, 24, 30, 11, 7, 12, 24, 5, 1, 98, 24, 7, 3, 45, 28, 15, 2, 19, 24, 3, 13, 15, 30, 1, 5, 107, 28, 10, 1, 46, 28, 1, 15, 22, 28, 2, 17, 14, 28, 5, 1, 120, 30, 9, 4, 43, 26, 17, 1, 22, 28, 2, 19, 14, 28, 3, 4, 113, 28, 3, 11, 44, 26, 17, 4, 21, 26, 9, 16, 13, 26, 3, 5, 107, 28, 3, 13, 41, 26, 15, 5, 24, 30, 15, 10, 15, 28, 4, 4, 116, 28, 17, 0, 42, 26, 17, 6, 22, 28, 19, 6, 16, 30, 2, 7, 111, 28, 17, 0, 46, 28, 7, 16, 24, 30, 34, 0, 13, 24, 4, 5, 121, 30, 4, 14, 47, 28, 11, 14, 24, 30, 16, 14, 15, 30, 6, 4, 117, 30, 6, 14, 45, 28, 11, 16, 24, 30, 30, 2, 16, 30, 8, 4, 106, 26, 8, 13, 47, 28, 7, 22, 24, 30, 22, 13, 15, 30, 10, 2, 114, 28, 19, 4, 46, 28, 28, 6, 22, 28, 33, 4, 16, 30, 8, 4, 122, 30, 22, 3, 45, 28, 8, 26, 23, 30, 12, 28, 15, 30, 3, 10, 117, 30, 3, 23, 45, 28, 4, 31, 24, 30, 11, 31, 15, 30, 7, 7, 116, 30, 21, 7, 45, 28, 1, 37, 23, 30, 19, 26, 15, 30, 5, 10, 115, 30, 19, 10, 47, 28, 15, 25, 24, 30, 23, 25, 15, 30, 13, 3, 115, 30, 2, 29, 46, 28, 42, 1, 24, 30, 23, 28, 15, 30, 17, 0, 115, 30, 10, 23, 46, 28, 10, 35, 24, 30, 19, 35, 15, 30, 17, 1, 115, 30, 14, 21, 46, 28, 29, 19, 24, 30, 11, 46, 15, 30, 13, 6, 115, 30, 14, 23, 46, 28, 44, 7, 24, 30, 59, 1, 16, 30, 12, 7, 121, 30, 12, 26, 47, 28, 39, 14, 24, 30, 22, 41, 15, 30, 6, 14, 121, 30, 6, 34, 47, 28, 46, 10, 24, 30, 2, 64, 15, 30, 17, 4, 122, 30, 29, 14, 46, 28, 49, 10, 24, 30, 24, 46, 15, 30, 4, 18, 122, 30, 13, 32, 46, 28, 48, 14, 24, 30, 42, 32, 15, 30, 20, 4, 117, 30, 40, 7, 47, 28, 43, 22, 24, 30, 10, 67, 15, 30, 19, 6, 118, 30, 18, 31, 47, 28, 34, 34, 24, 30, 20, 61, 15, 30]; + } + + /** + * Returns the final format bits with mask (level << 3 | mask). + * + * @return {Number[]} The final format bits. + * @public + * @static + */ + + }, { + key: "FINAL_FORMAT", + get: function get() { + return [ + // L + 0x77c4, 0x72f3, 0x7daa, 0x789d, 0x662f, 0x6318, 0x6c41, 0x6976, + // M + 0x5412, 0x5125, 0x5e7c, 0x5b4b, 0x45f9, 0x40ce, 0x4f97, 0x4aa0, + // Q + 0x355f, 0x3068, 0x3f31, 0x3a06, 0x24b4, 0x2183, 0x2eda, 0x2bed, + // H + 0x1689, 0x13be, 0x1ce7, 0x19d0, 0x0762, 0x0255, 0x0d0c, 0x083b]; + } + + /** + * Returns a map of human-readable ECC levels. + * + * @return {Object} A ECC level mapping. + * @public + * @static + */ + + }, { + key: "LEVELS", + get: function get() { + return { + L: 1, + M: 2, + Q: 3, + H: 4 + }; + } + }]); + return ErrorCorrection; + }(); + + /* + * QRious + * Copyright (C) 2016 Alasdair Mercer + * Copyright (C) 2010 Tom Zerucha + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + + /** + * Contains Galois field information. + * + * @public + */ + + var Galois = function () { + function Galois() { + classCallCheck(this, Galois); + } + + createClass(Galois, null, [{ + key: "EXPONENT", + + + /** + * Returns the Galois field exponent table. + * + * @return {Number[]} The Galois field exponent table. + * @public + * @static + */ + get: function get() { + return [0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1d, 0x3a, 0x74, 0xe8, 0xcd, 0x87, 0x13, 0x26, 0x4c, 0x98, 0x2d, 0x5a, 0xb4, 0x75, 0xea, 0xc9, 0x8f, 0x03, 0x06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 0xb2, 0x79, 0xf2, 0xf9, 0xef, 0xc3, 0x9b, 0x2b, 0x56, 0xac, 0x45, 0x8a, 0x09, 0x12, 0x24, 0x48, 0x90, 0x3d, 0x7a, 0xf4, 0xf5, 0xf7, 0xf3, 0xfb, 0xeb, 0xcb, 0x8b, 0x0b, 0x16, 0x2c, 0x58, 0xb0, 0x7d, 0xfa, 0xe9, 0xcf, 0x83, 0x1b, 0x36, 0x6c, 0xd8, 0xad, 0x47, 0x8e, 0x00]; + } + + /** + * Returns the Galois field log table. + * + * @return {Number[]} The Galois field log table. + * @public + * @static + */ + + }, { + key: "LOG", + get: function get() { + return [0xff, 0x00, 0x01, 0x19, 0x02, 0x32, 0x1a, 0xc6, 0x03, 0xdf, 0x33, 0xee, 0x1b, 0x68, 0xc7, 0x4b, 0x04, 0x64, 0xe0, 0x0e, 0x34, 0x8d, 0xef, 0x81, 0x1c, 0xc1, 0x69, 0xf8, 0xc8, 0x08, 0x4c, 0x71, 0x05, 0x8a, 0x65, 0x2f, 0xe1, 0x24, 0x0f, 0x21, 0x35, 0x93, 0x8e, 0xda, 0xf0, 0x12, 0x82, 0x45, 0x1d, 0xb5, 0xc2, 0x7d, 0x6a, 0x27, 0xf9, 0xb9, 0xc9, 0x9a, 0x09, 0x78, 0x4d, 0xe4, 0x72, 0xa6, 0x06, 0xbf, 0x8b, 0x62, 0x66, 0xdd, 0x30, 0xfd, 0xe2, 0x98, 0x25, 0xb3, 0x10, 0x91, 0x22, 0x88, 0x36, 0xd0, 0x94, 0xce, 0x8f, 0x96, 0xdb, 0xbd, 0xf1, 0xd2, 0x13, 0x5c, 0x83, 0x38, 0x46, 0x40, 0x1e, 0x42, 0xb6, 0xa3, 0xc3, 0x48, 0x7e, 0x6e, 0x6b, 0x3a, 0x28, 0x54, 0xfa, 0x85, 0xba, 0x3d, 0xca, 0x5e, 0x9b, 0x9f, 0x0a, 0x15, 0x79, 0x2b, 0x4e, 0xd4, 0xe5, 0xac, 0x73, 0xf3, 0xa7, 0x57, 0x07, 0x70, 0xc0, 0xf7, 0x8c, 0x80, 0x63, 0x0d, 0x67, 0x4a, 0xde, 0xed, 0x31, 0xc5, 0xfe, 0x18, 0xe3, 0xa5, 0x99, 0x77, 0x26, 0xb8, 0xb4, 0x7c, 0x11, 0x44, 0x92, 0xd9, 0x23, 0x20, 0x89, 0x2e, 0x37, 0x3f, 0xd1, 0x5b, 0x95, 0xbc, 0xcf, 0xcd, 0x90, 0x87, 0x97, 0xb2, 0xdc, 0xfc, 0xbe, 0x61, 0xf2, 0x56, 0xd3, 0xab, 0x14, 0x2a, 0x5d, 0x9e, 0x84, 0x3c, 0x39, 0x53, 0x47, 0x6d, 0x41, 0xa2, 0x1f, 0x2d, 0x43, 0xd8, 0xb7, 0x7b, 0xa4, 0x76, 0xc4, 0x17, 0x49, 0xec, 0x7f, 0x0c, 0x6f, 0xf6, 0x6c, 0xa1, 0x3b, 0x52, 0x29, 0x9d, 0x55, 0xaa, 0xfb, 0x60, 0x86, 0xb1, 0xbb, 0xcc, 0x3e, 0x5a, 0xcb, 0x59, 0x5f, 0xb0, 0x9c, 0xa9, 0xa0, 0x51, 0x0b, 0xf5, 0x16, 0xeb, 0x7a, 0x75, 0x2c, 0xd7, 0x4f, 0xae, 0xd5, 0xe9, 0xe6, 0xe7, 0xad, 0xe8, 0x74, 0xd6, 0xf4, 0xea, 0xa8, 0x50, 0x58, 0xaf]; + } + }]); + return Galois; + }(); + + /* + * QRious + * Copyright (C) 2016 Alasdair Mercer + * Copyright (C) 2010 Tom Zerucha + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + + /** + * Contains version pattern information. + * + * @public + */ + + var Version = function () { + function Version() { + classCallCheck(this, Version); + } + + createClass(Version, null, [{ + key: "BLOCK", + + + /** + * Returns the version pattern block. + * + * @return {Number[]} The version pattern block. + * @public + * @static + */ + get: function get() { + return [0xc94, 0x5bc, 0xa99, 0x4d3, 0xbf6, 0x762, 0x847, 0x60d, 0x928, 0xb78, 0x45d, 0xa17, 0x532, 0x9a6, 0x683, 0x8c9, 0x7ec, 0xec4, 0x1e1, 0xfab, 0x08e, 0xc1a, 0x33f, 0xd75, 0x250, 0x9d5, 0x6f0, 0x8ba, 0x79f, 0xb0b, 0x42e, 0xa64, 0x541, 0xc69]; + } + }]); + return Version; + }(); + + /** + * Generates information for a QR code frame based on a specific value to be encoded. + * + * @public + */ + + var Frame = function () { + createClass(Frame, null, [{ + key: '_createArray', + value: function _createArray(length) { + var array = []; + + for (var i = 0; i < length; i++) { + array[i] = 0; + } + + return array; + } + }, { + key: '_getMaskBit', + value: function _getMaskBit(x, y) { + var bit = void 0; + + if (x > y) { + bit = x; + x = y; + y = bit; + } + + bit = y; + bit += y * y; + bit >>= 1; + bit += x; + + return bit; + } + }, { + key: '_modN', + value: function _modN(x) { + while (x >= 255) { + x -= 255; + x = (x >> 8) + (x & 255); + } + + return x; + } + + // *Badness* coefficients. + + }, { + key: 'N1', + get: function get() { + return 3; + } + }, { + key: 'N2', + get: function get() { + return 3; + } + }, { + key: 'N3', + get: function get() { + return 40; + } + }, { + key: 'N4', + get: function get() { + return 10; + } + + /** + * Creates an instance of {@link Frame} based on the options provided. + * + * @param {Frame~Options} options - the options to be used + * @public + */ + + }]); + + function Frame(options) { + classCallCheck(this, Frame); + + this._badness = []; + this._level = ErrorCorrection.LEVELS[options.level]; + this._polynomial = []; + this._value = options.value; + this._valueLength = this._value.length; + this._version = 0; + this._stringBuffer = this._value.slice(0); + + var dataBlock = void 0; + var eccBlock = void 0; + var neccBlock1 = void 0; + var neccBlock2 = void 0; + + while (this._version < 40) { + this._version++; + + var index = (this._level - 1) * 4 + (this._version - 1) * 16; + + neccBlock1 = ErrorCorrection.BLOCKS[index++]; + neccBlock2 = ErrorCorrection.BLOCKS[index++]; + dataBlock = ErrorCorrection.BLOCKS[index++]; + eccBlock = ErrorCorrection.BLOCKS[index]; + + index = dataBlock * (neccBlock1 + neccBlock2) + neccBlock2 - 3 + (this._version <= 9); + + if (this._valueLength <= index) { + break; + } + } + + this._dataBlock = dataBlock; + this._eccBlock = eccBlock; + this._neccBlock1 = neccBlock1; + this._neccBlock2 = neccBlock2; + + /** + * The data width is based on version. + * + * @public + * @type {Number} + */ + // FIXME: Ensure that it fits instead of being truncated. + this.width = 17 + 4 * this._version; + + /** + * The image buffer. + * + * @public + * @type {Number[]} + */ + this.buffer = Frame._createArray(this.width * this.width); + + this._ecc = Frame._createArray(this._dataBlock + (this._dataBlock + this._eccBlock) * (this._neccBlock1 + this._neccBlock2) + this._neccBlock2); + this._mask = Frame._createArray((this.width * (this.width + 1) + 1) / 2); + + this._insertFinders(); + this._insertAlignments(); + + // Insert single foreground cell. + this.buffer[8 + this.width * (this.width - 8)] = 1; + + this._insertTimingGap(); + this._reverseMask(); + this._insertTimingRowAndColumn(); + this._insertVersion(); + this._syncMask(); + this._convertBitStream(this._stringBuffer.length); + this._calculatePolynomial(); + this._appendEccToData(); + this._interleaveBlocks(); + this._pack(); + this._finish(); + } + + createClass(Frame, [{ + key: '_addAlignment', + value: function _addAlignment(x, y) { + this.buffer[x + this.width * y] = 1; + + for (var i = -2; i < 2; i++) { + this.buffer[x + i + this.width * (y - 2)] = 1; + this.buffer[x - 2 + this.width * (y + i + 1)] = 1; + this.buffer[x + 2 + this.width * (y + i)] = 1; + this.buffer[x + i + 1 + this.width * (y + 2)] = 1; + } + + for (var _i = 0; _i < 2; _i++) { + this._setMask(x - 1, y + _i); + this._setMask(x + 1, y - _i); + this._setMask(x - _i, y - 1); + this._setMask(x + _i, y + 1); + } + } + }, { + key: '_appendData', + value: function _appendData(data, dataLength, ecc, eccLength) { + for (var i = 0; i < eccLength; i++) { + this._stringBuffer[ecc + i] = 0; + } + + for (var _i2 = 0; _i2 < dataLength; _i2++) { + var bit = Galois.LOG[this._stringBuffer[data + _i2] ^ this._stringBuffer[ecc]]; + + if (bit !== 255) { + for (var j = 1; j < eccLength; j++) { + this._stringBuffer[ecc + j - 1] = this._stringBuffer[ecc + j] ^ Galois.EXPONENT[Frame._modN(bit + this._polynomial[eccLength - j])]; + } + } else { + for (var _j = ecc; _j < ecc + eccLength; _j++) { + this._stringBuffer[_j] = this._stringBuffer[_j + 1]; + } + } + + this._stringBuffer[ecc + eccLength - 1] = bit === 255 ? 0 : Galois.EXPONENT[Frame._modN(bit + this._polynomial[0])]; + } + } + }, { + key: '_appendEccToData', + value: function _appendEccToData() { + var data = 0; + var ecc = this._calculateMaxLength(); + + for (var i = 0; i < this._neccBlock1; i++) { + this._appendData(data, this._dataBlock, ecc, this._eccBlock); + + data += this._dataBlock; + ecc += this._eccBlock; + } + + for (var _i3 = 0; _i3 < this._neccBlock2; _i3++) { + this._appendData(data, this._dataBlock + 1, ecc, this._eccBlock); + + data += this._dataBlock + 1; + ecc += this._eccBlock; + } + } + }, { + key: '_applyMask', + value: function _applyMask(mask) { + var width = this.width; + + switch (mask) { + case 0: + for (var y = 0; y < width; y++) { + for (var x = 0; x < width; x++) { + if (!(x + y & 1) && !this._isMasked(x, y)) { + this.buffer[x + y * width] ^= 1; + } + } + } + + break; + case 1: + for (var _y = 0; _y < width; _y++) { + for (var _x = 0; _x < width; _x++) { + if (!(_y & 1) && !this._isMasked(_x, _y)) { + this.buffer[_x + _y * width] ^= 1; + } + } + } + + break; + case 2: + for (var _y2 = 0; _y2 < width; _y2++) { + for (var r3x = 0, _x2 = 0; _x2 < width; _x2++, r3x++) { + if (r3x === 3) { + r3x = 0; + } + + if (!r3x && !this._isMasked(_x2, _y2)) { + this.buffer[_x2 + _y2 * width] ^= 1; + } + } + } + + break; + case 3: + for (var r3y = 0, _y3 = 0; _y3 < width; _y3++, r3y++) { + if (r3y === 3) { + r3y = 0; + } + + for (var _r3x = r3y, _x3 = 0; _x3 < width; _x3++, _r3x++) { + if (_r3x === 3) { + _r3x = 0; + } + + if (!_r3x && !this._isMasked(_x3, _y3)) { + this.buffer[_x3 + _y3 * width] ^= 1; + } + } + } + + break; + case 4: + for (var _y4 = 0; _y4 < width; _y4++) { + for (var _r3x2 = 0, _r3y = _y4 >> 1 & 1, _x4 = 0; _x4 < width; _x4++, _r3x2++) { + if (_r3x2 === 3) { + _r3x2 = 0; + _r3y = !_r3y; + } + + if (!_r3y && !this._isMasked(_x4, _y4)) { + this.buffer[_x4 + _y4 * width] ^= 1; + } + } + } + + break; + case 5: + for (var _r3y2 = 0, _y5 = 0; _y5 < width; _y5++, _r3y2++) { + if (_r3y2 === 3) { + _r3y2 = 0; + } + + for (var _r3x3 = 0, _x5 = 0; _x5 < width; _x5++, _r3x3++) { + if (_r3x3 === 3) { + _r3x3 = 0; + } + + if (!((_x5 & _y5 & 1) + !(!_r3x3 | !_r3y2)) && !this._isMasked(_x5, _y5)) { + this.buffer[_x5 + _y5 * width] ^= 1; + } + } + } + + break; + case 6: + for (var _r3y3 = 0, _y6 = 0; _y6 < width; _y6++, _r3y3++) { + if (_r3y3 === 3) { + _r3y3 = 0; + } + + for (var _r3x4 = 0, _x6 = 0; _x6 < width; _x6++, _r3x4++) { + if (_r3x4 === 3) { + _r3x4 = 0; + } + + if (!(_x6 & _y6 & 1 + (_r3x4 && _r3x4 === _r3y3) & 1) && !this._isMasked(_x6, _y6)) { + this.buffer[_x6 + _y6 * width] ^= 1; + } + } + } + + break; + case 7: + for (var _r3y4 = 0, _y7 = 0; _y7 < width; _y7++, _r3y4++) { + if (_r3y4 === 3) { + _r3y4 = 0; + } + + for (var _r3x5 = 0, _x7 = 0; _x7 < width; _x7++, _r3x5++) { + if (_r3x5 === 3) { + _r3x5 = 0; + } + + if (!((_r3x5 && _r3x5 === _r3y4) + (_x7 + _y7 & 1) & 1) && !this._isMasked(_x7, _y7)) { + this.buffer[_x7 + _y7 * width] ^= 1; + } + } + } + + break; + } + } + }, { + key: '_calculateMaxLength', + value: function _calculateMaxLength() { + return this._dataBlock * (this._neccBlock1 + this._neccBlock2) + this._neccBlock2; + } + }, { + key: '_calculatePolynomial', + value: function _calculatePolynomial() { + this._polynomial[0] = 1; + + for (var i = 0; i < this._eccBlock; i++) { + this._polynomial[i + 1] = 1; + + for (var j = i; j > 0; j--) { + this._polynomial[j] = this._polynomial[j] ? this._polynomial[j - 1] ^ Galois.EXPONENT[Frame._modN(Galois.LOG[this._polynomial[j]] + i)] : this._polynomial[j - 1]; + } + + this._polynomial[0] = Galois.EXPONENT[Frame._modN(Galois.LOG[this._polynomial[0]] + i)]; + } + + // Use logs for generator polynomial to save calculation step. + for (var _i4 = 0; _i4 <= this._eccBlock; _i4++) { + this._polynomial[_i4] = Galois.LOG[this._polynomial[_i4]]; + } + } + }, { + key: '_checkBadness', + value: function _checkBadness() { + var bad = 0; + var width = this.width; + + // Blocks of same colour. + for (var y = 0; y < width - 1; y++) { + for (var x = 0; x < width - 1; x++) { + // All foreground colour. + if (this.buffer[x + width * y] && this.buffer[x + 1 + width * y] && this.buffer[x + width * (y + 1)] && this.buffer[x + 1 + width * (y + 1)] || + // All background colour. + !(this.buffer[x + width * y] || this.buffer[x + 1 + width * y] || this.buffer[x + width * (y + 1)] || this.buffer[x + 1 + width * (y + 1)])) { + bad += Frame.N2; + } + } + } + + var bw = 0; + + // X runs. + for (var _y8 = 0; _y8 < width; _y8++) { + var h = 0; + + this._badness[0] = 0; + + for (var b = 0, _x8 = 0; _x8 < width; _x8++) { + var b1 = this.buffer[_x8 + width * _y8]; + + if (b === b1) { + this._badness[h]++; + } else { + this._badness[++h] = 1; + } + + b = b1; + bw += b ? 1 : -1; + } + + bad += this._getBadness(h); + } + + if (bw < 0) { + bw = -bw; + } + + var count = 0; + var big = bw; + big += big << 2; + big <<= 1; + + while (big > width * width) { + big -= width * width; + count++; + } + + bad += count * Frame.N4; + + // Y runs. + for (var _x9 = 0; _x9 < width; _x9++) { + var _h = 0; + + this._badness[0] = 0; + + for (var _b = 0, _y9 = 0; _y9 < width; _y9++) { + var _b2 = this.buffer[_x9 + width * _y9]; + + if (_b === _b2) { + this._badness[_h]++; + } else { + this._badness[++_h] = 1; + } + + _b = _b2; + } + + bad += this._getBadness(_h); + } + + return bad; + } + }, { + key: '_convertBitStream', + value: function _convertBitStream(length) { + // Convert string to bit stream. 8-bit data to QR-coded 8-bit data (numeric, alphanum, or kanji + // not supported). + + for (var i = 0; i < length; i++) { + this._ecc[i] = this._stringBuffer.charCodeAt(i); + } + + this._stringBuffer = this._ecc.slice(0); + + var maxLength = this._calculateMaxLength(); + + if (length >= maxLength - 2) { + length = maxLength - 2; + + if (this._version > 9) { + length--; + } + } + + // Shift and re-pack to insert length prefix. + var index = length; + + if (this._version > 9) { + this._stringBuffer[index + 2] = 0; + this._stringBuffer[index + 3] = 0; + + while (index--) { + var bit = this._stringBuffer[index]; + + this._stringBuffer[index + 3] |= 255 & bit << 4; + this._stringBuffer[index + 2] = bit >> 4; + } + + this._stringBuffer[2] |= 255 & length << 4; + this._stringBuffer[1] = length >> 4; + this._stringBuffer[0] = 0x40 | length >> 12; + } else { + this._stringBuffer[index + 1] = 0; + this._stringBuffer[index + 2] = 0; + + while (index--) { + var _bit = this._stringBuffer[index]; + + this._stringBuffer[index + 2] |= 255 & _bit << 4; + this._stringBuffer[index + 1] = _bit >> 4; + } + + this._stringBuffer[1] |= 255 & length << 4; + this._stringBuffer[0] = 0x40 | length >> 4; + } + + // Fill to end with pad pattern. + index = length + 3 - (this._version < 10); + + while (index < maxLength) { + this._stringBuffer[index++] = 0xec; + this._stringBuffer[index++] = 0x11; + } + } + }, { + key: '_getBadness', + value: function _getBadness(length) { + var badRuns = 0; + + for (var i = 0; i <= length; i++) { + if (this._badness[i] >= 5) { + badRuns += Frame.N1 + this._badness[i] - 5; + } + } + + // FBFFFBF as in finder. + for (var _i5 = 3; _i5 < length - 1; _i5 += 2) { + if (this._badness[_i5 - 2] === this._badness[_i5 + 2] && this._badness[_i5 + 2] === this._badness[_i5 - 1] && this._badness[_i5 - 1] === this._badness[_i5 + 1] && this._badness[_i5 - 1] * 3 === this._badness[_i5] && ( + // Background around the foreground pattern? Not part of the specs. + this._badness[_i5 - 3] === 0 || _i5 + 3 > length || this._badness[_i5 - 3] * 3 >= this._badness[_i5] * 4 || this._badness[_i5 + 3] * 3 >= this._badness[_i5] * 4)) { + badRuns += Frame.N3; + } + } + + return badRuns; + } + }, { + key: '_finish', + value: function _finish() { + // Save pre-mask copy of frame. + this._stringBuffer = this.buffer.slice(0); + + var bit = 0; + var i = void 0; + var mask = 30000; + + /* + * Using for instead of while since in original Arduino code if an early mask was "good enough" it wouldn't try for + * a better one since they get more complex and take longer. + */ + for (i = 0; i < 8; i++) { + // Returns foreground-background imbalance. + this._applyMask(i); + + var currentMask = this._checkBadness(); + + // Is current mask better than previous best? + if (currentMask < mask) { + mask = currentMask; + bit = i; + } + + // Don't increment "i" to a void redoing mask. + if (bit === 7) { + break; + } + + // Reset for next pass. + this.buffer = this._stringBuffer.slice(0); + } + + // Redo best mask as none were "good enough" (i.e. last wasn't bit). + if (bit !== i) { + this._applyMask(bit); + } + + // Add in final mask/ECC level bytes. + mask = ErrorCorrection.FINAL_FORMAT[bit + (this._level - 1 << 3)]; + + // Low byte. + for (i = 0; i < 8; i++, mask >>= 1) { + if (mask & 1) { + this.buffer[this.width - 1 - i + this.width * 8] = 1; + + if (i < 6) { + this.buffer[8 + this.width * i] = 1; + } else { + this.buffer[8 + this.width * (i + 1)] = 1; + } + } + } + + // High byte. + for (i = 0; i < 7; i++, mask >>= 1) { + if (mask & 1) { + this.buffer[8 + this.width * (this.width - 7 + i)] = 1; + + if (i) { + this.buffer[6 - i + this.width * 8] = 1; + } else { + this.buffer[7 + this.width * 8] = 1; + } + } + } + } + }, { + key: '_interleaveBlocks', + value: function _interleaveBlocks() { + var maxLength = this._calculateMaxLength(); + var i = void 0; + var k = 0; + + for (i = 0; i < this._dataBlock; i++) { + for (var j = 0; j < this._neccBlock1; j++) { + this._ecc[k++] = this._stringBuffer[i + j * this._dataBlock]; + } + + for (var _j2 = 0; _j2 < this._neccBlock2; _j2++) { + this._ecc[k++] = this._stringBuffer[this._neccBlock1 * this._dataBlock + i + _j2 * (this._dataBlock + 1)]; + } + } + + for (var _j3 = 0; _j3 < this._neccBlock2; _j3++) { + this._ecc[k++] = this._stringBuffer[this._neccBlock1 * this._dataBlock + i + _j3 * (this._dataBlock + 1)]; + } + + for (i = 0; i < this._eccBlock; i++) { + for (var _j4 = 0; _j4 < this._neccBlock1 + this._neccBlock2; _j4++) { + this._ecc[k++] = this._stringBuffer[maxLength + i + _j4 * this._eccBlock]; + } + } + + this._stringBuffer = this._ecc; + } + }, { + key: '_insertAlignments', + value: function _insertAlignments() { + var width = this.width; + + if (this._version > 1) { + var i = Alignment.BLOCK[this._version]; + var y = width - 7; + + for (;;) { + var x = width - 7; + + while (x > i - 3) { + this._addAlignment(x, y); + + if (x < i) { + break; + } + + x -= i; + } + + if (y <= i + 9) { + break; + } + + y -= i; + + this._addAlignment(6, y); + this._addAlignment(y, 6); + } + } + } + }, { + key: '_insertFinders', + value: function _insertFinders() { + var width = this.width; + + for (var i = 0; i < 3; i++) { + var j = 0; + var y = 0; + + if (i === 1) { + j = width - 7; + } + if (i === 2) { + y = width - 7; + } + + this.buffer[y + 3 + width * (j + 3)] = 1; + + for (var x = 0; x < 6; x++) { + this.buffer[y + x + width * j] = 1; + this.buffer[y + width * (j + x + 1)] = 1; + this.buffer[y + 6 + width * (j + x)] = 1; + this.buffer[y + x + 1 + width * (j + 6)] = 1; + } + + for (var _x10 = 1; _x10 < 5; _x10++) { + this._setMask(y + _x10, j + 1); + this._setMask(y + 1, j + _x10 + 1); + this._setMask(y + 5, j + _x10); + this._setMask(y + _x10 + 1, j + 5); + } + + for (var _x11 = 2; _x11 < 4; _x11++) { + this.buffer[y + _x11 + width * (j + 2)] = 1; + this.buffer[y + 2 + width * (j + _x11 + 1)] = 1; + this.buffer[y + 4 + width * (j + _x11)] = 1; + this.buffer[y + _x11 + 1 + width * (j + 4)] = 1; + } + } + } + }, { + key: '_insertTimingGap', + value: function _insertTimingGap() { + var width = this.width; + + for (var y = 0; y < 7; y++) { + this._setMask(7, y); + this._setMask(width - 8, y); + this._setMask(7, y + width - 7); + } + + for (var x = 0; x < 8; x++) { + this._setMask(x, 7); + this._setMask(x + width - 8, 7); + this._setMask(x, width - 8); + } + } + }, { + key: '_insertTimingRowAndColumn', + value: function _insertTimingRowAndColumn() { + var width = this.width; + + for (var x = 0; x < width - 14; x++) { + if (x & 1) { + this._setMask(8 + x, 6); + this._setMask(6, 8 + x); + } else { + this.buffer[8 + x + width * 6] = 1; + this.buffer[6 + width * (8 + x)] = 1; + } + } + } + }, { + key: '_insertVersion', + value: function _insertVersion() { + var width = this.width; + + if (this._version > 6) { + var i = Version.BLOCK[this._version - 7]; + var j = 17; + + for (var x = 0; x < 6; x++) { + for (var y = 0; y < 3; y++, j--) { + if (1 & (j > 11 ? this._version >> j - 12 : i >> j)) { + this.buffer[5 - x + width * (2 - y + width - 11)] = 1; + this.buffer[2 - y + width - 11 + width * (5 - x)] = 1; + } else { + this._setMask(5 - x, 2 - y + width - 11); + this._setMask(2 - y + width - 11, 5 - x); + } + } + } + } + } + }, { + key: '_isMasked', + value: function _isMasked(x, y) { + var bit = Frame._getMaskBit(x, y); + + return this._mask[bit] === 1; + } + }, { + key: '_pack', + value: function _pack() { + var x = this.width - 1; + var y = this.width - 1; + var k = 1; + var v = 1; + + // Interleaved data and ECC codes. + var length = (this._dataBlock + this._eccBlock) * (this._neccBlock1 + this._neccBlock2) + this._neccBlock2; + + for (var i = 0; i < length; i++) { + var bit = this._stringBuffer[i]; + + for (var j = 0; j < 8; j++, bit <<= 1) { + if (0x80 & bit) { + this.buffer[x + this.width * y] = 1; + } + + // Find next fill position. + do { + if (v) { + x--; + } else { + x++; + + if (k) { + if (y !== 0) { + y--; + } else { + x -= 2; + k = !k; + + if (x === 6) { + x--; + y = 9; + } + } + } else if (y !== this.width - 1) { + y++; + } else { + x -= 2; + k = !k; + + if (x === 6) { + x--; + y -= 8; + } + } + } + + v = !v; + } while (this._isMasked(x, y)); + } + } + } + }, { + key: '_reverseMask', + value: function _reverseMask() { + var width = this.width; + + for (var x = 0; x < 9; x++) { + this._setMask(x, 8); + } + + for (var _x12 = 0; _x12 < 8; _x12++) { + this._setMask(_x12 + width - 8, 8); + this._setMask(8, _x12); + } + + for (var y = 0; y < 7; y++) { + this._setMask(8, y + width - 7); + } + } + }, { + key: '_setMask', + value: function _setMask(x, y) { + var bit = Frame._getMaskBit(x, y); + + this._mask[bit] = 1; + } + }, { + key: '_syncMask', + value: function _syncMask() { + var width = this.width; + + for (var y = 0; y < width; y++) { + for (var x = 0; x <= y; x++) { + if (this.buffer[x + width * y]) { + this._setMask(x, y); + } + } + } + } + }]); + return Frame; + }(); + + /** + * An implementation of {@link Renderer} for working with img elements. + * + * This depends on {@link CanvasRenderer} being executed first as this implementation simply applies the data URL from + * the rendered canvas element as the src for the img element being rendered. + * + * @public + * @extends Renderer + */ + + var ImageRenderer = function (_Renderer) { + inherits(ImageRenderer, _Renderer); + + function ImageRenderer() { + classCallCheck(this, ImageRenderer); + return possibleConstructorReturn(this, Object.getPrototypeOf(ImageRenderer).apply(this, arguments)); + } + + createClass(ImageRenderer, [{ + key: 'draw', + + + /** + * @override + */ + value: function draw() { + var qrious = this.qrious; + + qrious.image.src = qrious.toDataURL(); + } + + /** + * @override + */ + + }, { + key: 'reset', + value: function reset() { + var qrious = this.qrious; + + qrious.image.src = ''; + } + + /** + * @override + */ + + }, { + key: 'resize', + value: function resize() { + var qrious = this.qrious; + var image = qrious.image; + + image.width = qrious.size; + image.height = qrious.size; + } + }]); + return ImageRenderer; + }(Renderer); + + /* + * QRious + * Copyright (C) 2016 Alasdair Mercer + * Copyright (C) 2010 Tom Zerucha + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + + /** + * A basic manager for {@link Service} implementations that are mapped to simple names. + * + * @public + */ + + var ServiceManager = function () { + + /** + * Creates a new instance of {@link ServiceManager}. + * + * @public + */ + + function ServiceManager() { + classCallCheck(this, ServiceManager); + + this._services = {}; + } + + /** + * Returns the {@link Service} being managed with the specified name. + * + * @param {String} name - the name of the {@link Service} to be returned + * @return {Service} The {@link Service} is being managed with name. + * @throws {Error} If no {@link Service} is being managed with name. + * @public + */ + + + createClass(ServiceManager, [{ + key: "getService", + value: function getService(name) { + var service = this._services[name]; + if (!service) { + throw new Error("Service is not being managed with name: " + name); + } + + return service; + } + + /** + * Sets the {@link Service} implementation to be managed for the specified name to the + * service provided. + * + * @param {String} name - the name of the {@link Service} to be managed with name + * @param {Service} service - the {@link Service} implementation to be managed + * @throws {Error} If a {@link Service} is already being managed with the same name. + * @public + */ + + }, { + key: "setService", + value: function setService(name, service) { + if (this._services[name]) { + throw new Error("Service is already managed with name: " + name); + } + + if (service) { + this._services[name] = service; + } + } + }]); + return ServiceManager; + }(); + + /** + * Enables configuration of a QR code generator which uses HTML5 canvas for rendering. + * + * @public + */ + + var QRious = function () { + createClass(QRious, null, [{ + key: 'use', + + + /** + * Configures the service provided to be used by all {@link QRious} instances. + * + * @param {Service} service - the {@link Service} to be configured + * @throws {Error} If a {@link Service} has already been configured with the same name. + * @public + * @static + */ + value: function use(service) { + QRious._serviceManager.setService(service.getName(), service); + } + }, { + key: '_parseOptions', + value: function _parseOptions(options) { + options = Object.assign({}, QRious.DEFAULTS, options); + options.level = Utilities.toUpperCase(options.level); + options.size = Math.abs(options.size); + + return options; + } + + /** + * Creates a new instance of {@link QRious} based on the options provided. + * + * @param {QRious~Options} [options] - the options to be used + * @public + */ + + }, { + key: 'DEFAULTS', + + + /** + * Returns the default options for {@link QRious}. + * + * @return {QRious~Options} The default options. + * @public + * @static + */ + get: function get() { + return { + background: 'white', + foreground: 'black', + level: 'L', + mime: 'image/png', + size: 100, + value: '' + }; + } + + /** + * Returns the current version of {@link QRious}. + * + * @return {String} The current version. + * @public + * @static + */ + + }, { + key: 'VERSION', + get: function get() { + return '2.0.0'; + } + }]); + + function QRious(options) { + classCallCheck(this, QRious); + + options = QRious._parseOptions(options); + + Utilities.privatize(this, options); + + var element = this._element; + var elementService = QRious._serviceManager.getService('element'); + + /** + * The canvas being used to render the QR code for this {@link QRious}. + * + * @public + * @type {*} + */ + this.canvas = element && elementService.isCanvas(element) ? element : elementService.createCanvas(); + this.canvas.qrious = this; + + /** + * The img to contain the rendered QR code for this {@link QRious}. + * + * @public + * @type {*} + */ + this.image = element && elementService.isImage(element) ? element : elementService.createImage(); + this.image.qrious = this; + + this._renderers = [new CanvasRenderer(this), new ImageRenderer(this)]; + + this.update(); + } + + /** + * Returns the image data URI for the generated QR code using the mime provided. + * + * @param {String} [mime] - the MIME type for the image + * @return {String} The image data URI for the QR code. + * @public + */ + + + createClass(QRious, [{ + key: 'toDataURL', + value: function toDataURL(mime) { + return this.canvas.toDataURL(mime || this.mime); + } + + /** + * Updates this {@link QRious} by generating a new {@link Frame} and re-rendering the QR code. + * + * @protected + */ + + }, { + key: 'update', + value: function update() { + var frame = new Frame({ + level: this.level, + value: this.value + }); + + this._renderers.forEach(function (renderer) { + return renderer.render(frame); + }); + } + + /** + * Returns the background color for the QR code. + * + * @return {String} The background color. + * @public + */ + + }, { + key: 'background', + get: function get() { + return this._background; + } + + /** + * Sets the background color for the QR code to background. + * + * @param {String} [background="white"] - the background color to be set + * @public + */ + , + set: function set(background) { + var changed = Utilities.setter(this, '_background', background, QRious.DEFAULTS.background); + + if (changed) { + this.update(); + } + } + + /** + * Returns the foreground color for the QR code. + * + * @return {String} The foreground color. + * @public + */ + + }, { + key: 'foreground', + get: function get() { + return this._foreground; + } + + /** + * Sets the foreground color for the QR code to foreground. + * + * @param {String} [foreground="black"] - the foreground color to be set + * @public + */ + , + set: function set(foreground) { + var changed = Utilities.setter(this, '_foreground', foreground, QRious.DEFAULTS.foreground); + + if (changed) { + this.update(); + } + } + + /** + * Returns the error correction level for the QR code. + * + * @return {String} The ECC level. + * @public + */ + + }, { + key: 'level', + get: function get() { + return this._level; + } + + /** + * Sets the error correction level for the QR code to level. + * + * level will be transformed to upper case to aid mapping to known ECC level blocks. + * + * @param {String} [level="L"] - the ECC level to be set + * @public + */ + , + set: function set(level) { + var changed = Utilities.setter(this, '_level', level, QRious.DEFAULTS.level, Utilities.toUpperCase); + + if (changed) { + this.update(); + } + } + + /** + * Returns the MIME type for the image rendered for the QR code. + * + * @return {String} The image MIME type. + * @public + */ + + }, { + key: 'mime', + get: function get() { + return this._mime; + } + + /** + * Sets the MIME type for the image rendered for the QR code to mime. + * + * @param {String} [mime="image/png"] - the image MIME type to be set + * @public + */ + , + set: function set(mime) { + var changed = Utilities.setter(this, '_mime', mime, QRious.DEFAULTS.mime); + + if (changed) { + this.update(); + } + } + + /** + * Returns the size of the QR code. + * + * @return {Number} The size in pixels. + * @public + */ + + }, { + key: 'size', + get: function get() { + return this._size; + } + + /** + * Sets the size of the QR code to size. + * + * size will be transformed to ensure that it is always an absolute positive numbers (e.g. + * -100 would become 100). + * + * @param {Number} [size=100] - the size in pixels to be set + * @public + */ + , + set: function set(size) { + var changed = Utilities.setter(this, '_size', size, QRious.DEFAULTS.size, Math.abs); + + if (changed) { + this.update(); + } + } + + /** + * Returns the value of the QR code. + * + * @return {String} The value. + * @public + */ + + }, { + key: 'value', + get: function get() { + return this._value; + } + + /** + * Sets the value of the QR code to value. + * + * @param {String} [value=""] - the value to be set + * @public + */ + , + set: function set(value) { + var changed = Utilities.setter(this, '_value', value, QRious.DEFAULTS.value); + + if (changed) { + this.update(); + } + } + }]); + return QRious; + }(); + + QRious._serviceManager = new ServiceManager(); + + QRious.use(new BrowserElementService()); + + return QRious; + +})); +//# sourceMappingURL=qrious.js.map \ No newline at end of file diff --git a/dist/umd/qrious.js.map b/dist/umd/qrious.js.map new file mode 100644 index 0000000..0cddc9d --- /dev/null +++ b/dist/umd/qrious.js.map @@ -0,0 +1 @@ +{"version":3,"file":null,"sources":["../../../../../../\u0000babelHelpers","../../src/util/Utilities.js","../../src/service/Service.js","../../src/service/element/ElementService.js","../../src/service/element/BrowserElementService.js","../../src/renderer/Renderer.js","../../src/renderer/CanvasRenderer.js","../../src/Alignment.js","../../src/ErrorCorrection.js","../../src/Galois.js","../../src/Version.js","../../src/Frame.js","../../src/renderer/ImageRenderer.js","../../src/service/ServiceManager.js","../../src/QRious.js","../../src/runtime/browser.js"],"sourcesContent":["var babelHelpers = {};\nvar _typeof = typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\" ? function (obj) {\n return typeof obj;\n} : function (obj) {\n return obj && typeof Symbol === \"function\" && obj.constructor === Symbol ? \"symbol\" : typeof obj;\n};\n\nexport var jsx = function () {\n var REACT_ELEMENT_TYPE = typeof Symbol === \"function\" && Symbol.for && Symbol.for(\"react.element\") || 0xeac7;\n return function createRawReactElement(type, props, key, children) {\n var defaultProps = type && type.defaultProps;\n var childrenLength = arguments.length - 3;\n\n if (!props && childrenLength !== 0) {\n props = {};\n }\n\n if (props && defaultProps) {\n for (var propName in defaultProps) {\n if (props[propName] === void 0) {\n props[propName] = defaultProps[propName];\n }\n }\n } else if (!props) {\n props = defaultProps || {};\n }\n\n if (childrenLength === 1) {\n props.children = children;\n } else if (childrenLength > 1) {\n var childArray = Array(childrenLength);\n\n for (var i = 0; i < childrenLength; i++) {\n childArray[i] = arguments[i + 3];\n }\n\n props.children = childArray;\n }\n\n return {\n $$typeof: REACT_ELEMENT_TYPE,\n type: type,\n key: key === undefined ? null : '' + key,\n ref: null,\n props: props,\n _owner: null\n };\n };\n}();\n\nexport var asyncToGenerator = function (fn) {\n return function () {\n var gen = fn.apply(this, arguments);\n return new Promise(function (resolve, reject) {\n function step(key, arg) {\n try {\n var info = gen[key](arg);\n var value = info.value;\n } catch (error) {\n reject(error);\n return;\n }\n\n if (info.done) {\n resolve(value);\n } else {\n return Promise.resolve(value).then(function (value) {\n return step(\"next\", value);\n }, function (err) {\n return step(\"throw\", err);\n });\n }\n }\n\n return step(\"next\");\n });\n };\n};\n\nexport var classCallCheck = function (instance, Constructor) {\n if (!(instance instanceof Constructor)) {\n throw new TypeError(\"Cannot call a class as a function\");\n }\n};\n\nexport var createClass = function () {\n function defineProperties(target, props) {\n for (var i = 0; i < props.length; i++) {\n var descriptor = props[i];\n descriptor.enumerable = descriptor.enumerable || false;\n descriptor.configurable = true;\n if (\"value\" in descriptor) descriptor.writable = true;\n Object.defineProperty(target, descriptor.key, descriptor);\n }\n }\n\n return function (Constructor, protoProps, staticProps) {\n if (protoProps) defineProperties(Constructor.prototype, protoProps);\n if (staticProps) defineProperties(Constructor, staticProps);\n return Constructor;\n };\n}();\n\nexport var defineEnumerableProperties = function (obj, descs) {\n for (var key in descs) {\n var desc = descs[key];\n desc.configurable = desc.enumerable = true;\n if (\"value\" in desc) desc.writable = true;\n Object.defineProperty(obj, key, desc);\n }\n\n return obj;\n};\n\nexport var defaults = function (obj, defaults) {\n var keys = Object.getOwnPropertyNames(defaults);\n\n for (var i = 0; i < keys.length; i++) {\n var key = keys[i];\n var value = Object.getOwnPropertyDescriptor(defaults, key);\n\n if (value && value.configurable && obj[key] === undefined) {\n Object.defineProperty(obj, key, value);\n }\n }\n\n return obj;\n};\n\nexport var defineProperty = function (obj, key, value) {\n if (key in obj) {\n Object.defineProperty(obj, key, {\n value: value,\n enumerable: true,\n configurable: true,\n writable: true\n });\n } else {\n obj[key] = value;\n }\n\n return obj;\n};\n\nvar _extends = Object.assign || function (target) {\n for (var i = 1; i < arguments.length; i++) {\n var source = arguments[i];\n\n for (var key in source) {\n if (Object.prototype.hasOwnProperty.call(source, key)) {\n target[key] = source[key];\n }\n }\n }\n\n return target;\n};\n\nexport var get = function get(object, property, receiver) {\n if (object === null) object = Function.prototype;\n var desc = Object.getOwnPropertyDescriptor(object, property);\n\n if (desc === undefined) {\n var parent = Object.getPrototypeOf(object);\n\n if (parent === null) {\n return undefined;\n } else {\n return get(parent, property, receiver);\n }\n } else if (\"value\" in desc) {\n return desc.value;\n } else {\n var getter = desc.get;\n\n if (getter === undefined) {\n return undefined;\n }\n\n return getter.call(receiver);\n }\n};\n\nexport var inherits = function (subClass, superClass) {\n if (typeof superClass !== \"function\" && superClass !== null) {\n throw new TypeError(\"Super expression must either be null or a function, not \" + typeof superClass);\n }\n\n subClass.prototype = Object.create(superClass && superClass.prototype, {\n constructor: {\n value: subClass,\n enumerable: false,\n writable: true,\n configurable: true\n }\n });\n if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;\n};\n\nvar _instanceof = function (left, right) {\n if (right != null && typeof Symbol !== \"undefined\" && right[Symbol.hasInstance]) {\n return right[Symbol.hasInstance](left);\n } else {\n return left instanceof right;\n }\n};\n\nexport var interopRequireDefault = function (obj) {\n return obj && obj.__esModule ? obj : {\n default: obj\n };\n};\n\nexport var interopRequireWildcard = function (obj) {\n if (obj && obj.__esModule) {\n return obj;\n } else {\n var newObj = {};\n\n if (obj != null) {\n for (var key in obj) {\n if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key];\n }\n }\n\n newObj.default = obj;\n return newObj;\n }\n};\n\nexport var newArrowCheck = function (innerThis, boundThis) {\n if (innerThis !== boundThis) {\n throw new TypeError(\"Cannot instantiate an arrow function\");\n }\n};\n\nexport var objectDestructuringEmpty = function (obj) {\n if (obj == null) throw new TypeError(\"Cannot destructure undefined\");\n};\n\nexport var objectWithoutProperties = function (obj, keys) {\n var target = {};\n\n for (var i in obj) {\n if (keys.indexOf(i) >= 0) continue;\n if (!Object.prototype.hasOwnProperty.call(obj, i)) continue;\n target[i] = obj[i];\n }\n\n return target;\n};\n\nexport var possibleConstructorReturn = function (self, call) {\n if (!self) {\n throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\");\n }\n\n return call && (typeof call === \"object\" || typeof call === \"function\") ? call : self;\n};\n\nexport var selfGlobal = typeof global === \"undefined\" ? self : global;\n\nexport var set = function set(object, property, value, receiver) {\n var desc = Object.getOwnPropertyDescriptor(object, property);\n\n if (desc === undefined) {\n var parent = Object.getPrototypeOf(object);\n\n if (parent !== null) {\n set(parent, property, value, receiver);\n }\n } else if (\"value\" in desc && desc.writable) {\n desc.value = value;\n } else {\n var setter = desc.set;\n\n if (setter !== undefined) {\n setter.call(receiver, value);\n }\n }\n\n return value;\n};\n\nexport var slicedToArray = function () {\n function sliceIterator(arr, i) {\n var _arr = [];\n var _n = true;\n var _d = false;\n var _e = undefined;\n\n try {\n for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {\n _arr.push(_s.value);\n\n if (i && _arr.length === i) break;\n }\n } catch (err) {\n _d = true;\n _e = err;\n } finally {\n try {\n if (!_n && _i[\"return\"]) _i[\"return\"]();\n } finally {\n if (_d) throw _e;\n }\n }\n\n return _arr;\n }\n\n return function (arr, i) {\n if (Array.isArray(arr)) {\n return arr;\n } else if (Symbol.iterator in Object(arr)) {\n return sliceIterator(arr, i);\n } else {\n throw new TypeError(\"Invalid attempt to destructure non-iterable instance\");\n }\n };\n}();\n\nexport var slicedToArrayLoose = function (arr, i) {\n if (Array.isArray(arr)) {\n return arr;\n } else if (Symbol.iterator in Object(arr)) {\n var _arr = [];\n\n for (var _iterator = arr[Symbol.iterator](), _step; !(_step = _iterator.next()).done;) {\n _arr.push(_step.value);\n\n if (i && _arr.length === i) break;\n }\n\n return _arr;\n } else {\n throw new TypeError(\"Invalid attempt to destructure non-iterable instance\");\n }\n};\n\nexport var taggedTemplateLiteral = function (strings, raw) {\n return Object.freeze(Object.defineProperties(strings, {\n raw: {\n value: Object.freeze(raw)\n }\n }));\n};\n\nexport var taggedTemplateLiteralLoose = function (strings, raw) {\n strings.raw = raw;\n return strings;\n};\n\nexport var temporalRef = function (val, name, undef) {\n if (val === undef) {\n throw new ReferenceError(name + \" is not defined - temporal dead zone\");\n } else {\n return val;\n }\n};\n\nexport var temporalUndefined = {};\n\nexport var toArray = function (arr) {\n return Array.isArray(arr) ? arr : Array.from(arr);\n};\n\nexport var toConsumableArray = function (arr) {\n if (Array.isArray(arr)) {\n for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i];\n\n return arr2;\n } else {\n return Array.from(arr);\n }\n};\n\nbabelHelpers;\n\nexport { _typeof as typeof, _extends as extends, _instanceof as instanceof }","/*\n * QRious\n * Copyright (C) 2016 Alasdair Mercer\n * Copyright (C) 2010 Tom Zerucha\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see .\n */\n\n/**\n * Contains utility methods that are useful throughout the library.\n *\n * @public\n */\nclass Utilities {\n\n /**\n * Copies all properties from the source object to the target object, however, all property\n * names on the target will be prefixed with an underscore, used to indicate that they are private.\n *\n * @param {Object} target - the object to which the private fields are to be copied\n * @param {Object} source - the object from which the fields are to be copied\n * @return {Object} A reference to the target object.\n * @public\n * @static\n */\n static privatize(target, source) {\n for (let key in source) {\n if (source.hasOwnProperty(key)) {\n target[`_${key}`] = source[key]\n }\n }\n\n return target\n }\n\n /**\n * Sets the specified value on a given field on the object provided.\n *\n * If value is null, the specified default value will be used instead.\n *\n * An optional transformer can be specified which will be used to transform the value (or default value)\n * before it is assigned to the field.\n *\n * @param {Object} object - the object whose field is to be set with value\n * @param {String} fieldName - the field to be set with value\n * @param {*} value - the value to be set on the named field\n * @param {*} [defaultValue] - the value to be used if value is null\n * @param {Function} [transformer] - a function used to transform the value before it is assigned to the named field\n * @return {Boolean} true if the value of the field has changed as a result of the assignment; otherwise\n * false.\n * @public\n * @static\n */\n static setter(object, fieldName, value, defaultValue, transformer) {\n const oldValue = object[fieldName]\n let newValue = value != null ? value : defaultValue\n if (typeof transformer === 'function') {\n newValue = transformer(newValue)\n }\n\n object[fieldName] = newValue\n\n return newValue !== oldValue\n }\n\n /**\n * Throws an error indicating that the a given method on a specific class has not been implemented.\n *\n * @param {String} className - the name of the class on which the method has not been implemented\n * @param {String} methodName - the name of the method which has not been implemented\n * @throws {Error} The error describing the class method which has not been implemented.\n * @public\n * @static\n */\n static throwUnimplemented(className, methodName) {\n throw new Error(`\"${methodName}\" method must be implemented on the ${className} class`)\n }\n\n /**\n * Transforms the specified string to upper case while remaining null-safe.\n *\n * @param {String} string - the string to be transformed to upper case\n * @return {String} string transformed to upper case if string is not null.\n * @public\n * @static\n */\n static toUpperCase(string) {\n return string != null && string.toUpperCase()\n }\n}\n\nexport default Utilities\n","/*\n * QRious\n * Copyright (C) 2016 Alasdair Mercer\n * Copyright (C) 2010 Tom Zerucha\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see .\n */\n\nimport Utilities from '../util/Utilities'\n\n/**\n * Defines a service contract that must be met by all implementations.\n *\n * @public\n */\nclass Service {\n\n /**\n * Returns the name of this {@link Service}.\n *\n * @return {String} The service name.\n * @public\n */\n getName() {\n Utilities.throwUnimplemented('Service', 'getName')\n }\n}\n\nexport default Service\n","/*\n * QRious\n * Copyright (C) 2016 Alasdair Mercer\n * Copyright (C) 2010 Tom Zerucha\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see .\n */\n\nimport Service from '../Service'\nimport Utilities from '../../util/Utilities'\n\n/**\n * A service for working with elements.\n *\n * @public\n * @extends Service\n */\nclass ElementService extends Service {\n\n /**\n * Creates an instance of a canvas element.\n *\n * @return {*} The newly created canvas element.\n * @public\n */\n createCanvas() {\n Utilities.throwUnimplemented('ElementService', 'createCanvas')\n }\n\n /**\n * Creates an instance of a image element.\n *\n * @return {*} The newly created image element.\n * @public\n */\n createImage() {\n Utilities.throwUnimplemented('ElementService', 'createImage')\n }\n\n /**\n * @override\n */\n getName() {\n return 'element'\n }\n\n /**\n * Returns whether the specified element is a canvas.\n *\n * @param {*} element - the element to be checked\n * @return {Boolean} true if element is a canvas; otherwise false.\n * @public\n */\n isCanvas(element) {\n Utilities.throwUnimplemented('ElementService', 'isCanvas')\n }\n\n /**\n * Returns whether the specified element is an image.\n *\n * @param {*} element - the element to be checked\n * @return {Boolean} true if element is an image; otherwise false.\n * @public\n */\n isImage(element) {\n Utilities.throwUnimplemented('ElementService', 'isImage')\n }\n}\n\nexport default ElementService\n","/*\n * QRious\n * Copyright (C) 2016 Alasdair Mercer\n * Copyright (C) 2010 Tom Zerucha\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see .\n */\n\nimport ElementService from './ElementService'\n\n/**\n * An implementation of {@link ElementService} intended for use within a browser environment.\n *\n * @public\n * @extends ElementService\n */\nclass BrowserElementService extends ElementService {\n\n /**\n * @override\n */\n createCanvas() {\n return document.createElement('canvas')\n }\n\n /**\n * @override\n */\n createImage() {\n return document.createElement('img')\n }\n\n /**\n * @override\n */\n isCanvas(element) {\n return element instanceof HTMLCanvasElement\n }\n\n /**\n * @override\n */\n isImage(element) {\n return element instanceof HTMLImageElement\n }\n}\n\nexport default BrowserElementService\n","/*\n * QRious\n * Copyright (C) 2016 Alasdair Mercer\n * Copyright (C) 2010 Tom Zerucha\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see .\n */\n\nimport Utilities from '../util/Utilities'\n\n/**\n * Responsible for rendering a QR code {@link Frame} on a specific type of element.\n *\n * A renderer may be dependant on the rendering of another element, so ordering of their execution is important.\n *\n * @public\n */\nclass Renderer {\n\n /**\n * Creates a new instance of {@link Renderer} for the qrious instance provided.\n *\n * @param {QRious} qrious - the {@link QRious} instance to be used\n * @public\n */\n constructor(qrious) {\n /**\n * The {@link QRious} instance.\n *\n * @protected\n * @type {QRious}\n */\n this.qrious = qrious\n }\n\n /**\n * Draws the specified QR code frame on the underlying element.\n *\n * Implementations of {@link Renderer} must override this method with their own specific logic.\n *\n * @param {Frame} frame - the {@link Frame} to be drawn\n * @protected\n */\n draw(frame) {\n Utilities.throwUnimplemented('Renderer', 'draw')\n }\n\n /**\n * Calculates the size (in pixel units) to represent an individual module within the QR code based on the\n * frame provided.\n *\n * The returned value will be at least one, even in cases where the size of the QR code does not fit its contents.\n * This is done so that the inevitable clipping is handled more gracefully since this way at least something is\n * displayed instead of just a blank space filled by the background color.\n *\n * @param {Frame} frame - the {@link Frame} from which the module size is to be derived\n * @return {Number} The pixel size for each module in the QR code which will be no less than one.\n * @protected\n */\n getModuleSize(frame) {\n const pixels = Math.floor(this.qrious.size / frame.width)\n\n return Math.max(1, pixels)\n }\n\n /**\n * Calculates the offset/padding (in pixel units) to be inserted before the QR code based on the frame\n * provided.\n *\n * The returned value will be zero if there is no available offset or if the size of the QR code does not fit its\n * contents. It will never be a negative value. This is done so that the inevitable clipping appears more naturally\n * and it is not clipped from all directions.\n *\n * @param {Frame} frame - the {@link Frame} from which the offset is to be derived\n * @return {Number} The pixel offset for the QR code which will be no less than zero.\n * @protected\n */\n getOffset(frame) {\n const moduleSize = this.getModuleSize(frame)\n const offset = Math.floor((this.qrious.size - moduleSize * frame.width) / 2)\n\n return Math.max(0, offset)\n }\n\n /**\n * Renders a QR code on the underlying element based on the frame provided.\n *\n * @param {Frame} frame - the {@link Frame} to be rendered\n * @public\n */\n render(frame) {\n this.resize()\n this.reset()\n this.draw(frame)\n }\n\n /**\n * Resets the underlying element, effectively clearing any previously rendered QR code.\n *\n * Implementations of {@link Renderer} must override this method with their own specific logic.\n *\n * @protected\n */\n reset() {\n Utilities.throwUnimplemented('Renderer', 'reset')\n }\n\n /**\n * Ensures that the size of the underlying element matches that defined on the associated {@link QRious} instance.\n *\n * Implementations of {@link Renderer} must override this method with their own specific logic.\n *\n * @protected\n */\n resize() {\n Utilities.throwUnimplemented('Renderer', 'resize')\n }\n}\n\nexport default Renderer\n","/*\n * QRious\n * Copyright (C) 2016 Alasdair Mercer\n * Copyright (C) 2010 Tom Zerucha\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see .\n */\n\nimport Renderer from './Renderer'\n\n/**\n * An implementation of {@link Renderer} for working with canvas elements.\n *\n * @public\n * @extends Renderer\n */\nclass CanvasRenderer extends Renderer {\n\n /**\n * @override\n */\n draw(frame) {\n const qrious = this.qrious\n const moduleSize = this.getModuleSize(frame)\n const offset = this.getOffset(frame)\n const context = qrious.canvas.getContext('2d')\n\n context.fillStyle = qrious.foreground\n\n for (let i = 0; i < frame.width; i++) {\n for (let j = 0; j < frame.width; j++) {\n if (frame.buffer[j * frame.width + i]) {\n context.fillRect(moduleSize * i + offset, moduleSize * j + offset, moduleSize, moduleSize)\n }\n }\n }\n }\n\n /**\n * @override\n */\n reset() {\n const qrious = this.qrious\n const context = qrious.canvas.getContext('2d')\n\n context.lineWidth = 1\n context.clearRect(0, 0, qrious.size, qrious.size)\n context.fillStyle = qrious.background\n context.fillRect(0, 0, qrious.size, qrious.size)\n }\n\n /**\n * @override\n */\n resize() {\n const qrious = this.qrious\n const canvas = qrious.canvas\n\n canvas.width = qrious.size\n canvas.height = qrious.size\n }\n}\n\nexport default CanvasRenderer\n","/*\n * QRious\n * Copyright (C) 2016 Alasdair Mercer\n * Copyright (C) 2010 Tom Zerucha\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see .\n */\n\n/* eslint no-multi-spaces: 0 */\n\n/**\n * Contains alignment pattern information.\n *\n * @public\n */\nclass Alignment {\n\n /**\n * Returns the alignment pattern block.\n *\n * @return {Number[]} The alignment pattern block.\n * @public\n * @static\n */\n static get BLOCK() {\n return [\n 0, 11, 15, 19, 23, 27, 31,\n 16, 18, 20, 22, 24, 26, 28, 20, 22, 24, 24, 26, 28, 28, 22, 24, 24,\n 26, 26, 28, 28, 24, 24, 26, 26, 26, 28, 28, 24, 26, 26, 26, 28, 28\n ]\n }\n}\n\nexport default Alignment\n","/*\n * QRious\n * Copyright (C) 2016 Alasdair Mercer\n * Copyright (C) 2010 Tom Zerucha\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see .\n */\n\n/* eslint no-multi-spaces: 0 */\n\n/**\n * Contains error correction information.\n *\n * @public\n */\nclass ErrorCorrection {\n\n /**\n * Returns the error correction blocks.\n *\n * There are four elements per version. The first two indicate the number of blocks, then the data width, and finally\n * the ECC width.\n *\n * @return {Number[]} The ECC blocks.\n * @public\n * @static\n */\n static get BLOCKS() {\n return [\n 1, 0, 19, 7, 1, 0, 16, 10, 1, 0, 13, 13, 1, 0, 9, 17,\n 1, 0, 34, 10, 1, 0, 28, 16, 1, 0, 22, 22, 1, 0, 16, 28,\n 1, 0, 55, 15, 1, 0, 44, 26, 2, 0, 17, 18, 2, 0, 13, 22,\n 1, 0, 80, 20, 2, 0, 32, 18, 2, 0, 24, 26, 4, 0, 9, 16,\n 1, 0, 108, 26, 2, 0, 43, 24, 2, 2, 15, 18, 2, 2, 11, 22,\n 2, 0, 68, 18, 4, 0, 27, 16, 4, 0, 19, 24, 4, 0, 15, 28,\n 2, 0, 78, 20, 4, 0, 31, 18, 2, 4, 14, 18, 4, 1, 13, 26,\n 2, 0, 97, 24, 2, 2, 38, 22, 4, 2, 18, 22, 4, 2, 14, 26,\n 2, 0, 116, 30, 3, 2, 36, 22, 4, 4, 16, 20, 4, 4, 12, 24,\n 2, 2, 68, 18, 4, 1, 43, 26, 6, 2, 19, 24, 6, 2, 15, 28,\n 4, 0, 81, 20, 1, 4, 50, 30, 4, 4, 22, 28, 3, 8, 12, 24,\n 2, 2, 92, 24, 6, 2, 36, 22, 4, 6, 20, 26, 7, 4, 14, 28,\n 4, 0, 107, 26, 8, 1, 37, 22, 8, 4, 20, 24, 12, 4, 11, 22,\n 3, 1, 115, 30, 4, 5, 40, 24, 11, 5, 16, 20, 11, 5, 12, 24,\n 5, 1, 87, 22, 5, 5, 41, 24, 5, 7, 24, 30, 11, 7, 12, 24,\n 5, 1, 98, 24, 7, 3, 45, 28, 15, 2, 19, 24, 3, 13, 15, 30,\n 1, 5, 107, 28, 10, 1, 46, 28, 1, 15, 22, 28, 2, 17, 14, 28,\n 5, 1, 120, 30, 9, 4, 43, 26, 17, 1, 22, 28, 2, 19, 14, 28,\n 3, 4, 113, 28, 3, 11, 44, 26, 17, 4, 21, 26, 9, 16, 13, 26,\n 3, 5, 107, 28, 3, 13, 41, 26, 15, 5, 24, 30, 15, 10, 15, 28,\n 4, 4, 116, 28, 17, 0, 42, 26, 17, 6, 22, 28, 19, 6, 16, 30,\n 2, 7, 111, 28, 17, 0, 46, 28, 7, 16, 24, 30, 34, 0, 13, 24,\n 4, 5, 121, 30, 4, 14, 47, 28, 11, 14, 24, 30, 16, 14, 15, 30,\n 6, 4, 117, 30, 6, 14, 45, 28, 11, 16, 24, 30, 30, 2, 16, 30,\n 8, 4, 106, 26, 8, 13, 47, 28, 7, 22, 24, 30, 22, 13, 15, 30,\n 10, 2, 114, 28, 19, 4, 46, 28, 28, 6, 22, 28, 33, 4, 16, 30,\n 8, 4, 122, 30, 22, 3, 45, 28, 8, 26, 23, 30, 12, 28, 15, 30,\n 3, 10, 117, 30, 3, 23, 45, 28, 4, 31, 24, 30, 11, 31, 15, 30,\n 7, 7, 116, 30, 21, 7, 45, 28, 1, 37, 23, 30, 19, 26, 15, 30,\n 5, 10, 115, 30, 19, 10, 47, 28, 15, 25, 24, 30, 23, 25, 15, 30,\n 13, 3, 115, 30, 2, 29, 46, 28, 42, 1, 24, 30, 23, 28, 15, 30,\n 17, 0, 115, 30, 10, 23, 46, 28, 10, 35, 24, 30, 19, 35, 15, 30,\n 17, 1, 115, 30, 14, 21, 46, 28, 29, 19, 24, 30, 11, 46, 15, 30,\n 13, 6, 115, 30, 14, 23, 46, 28, 44, 7, 24, 30, 59, 1, 16, 30,\n 12, 7, 121, 30, 12, 26, 47, 28, 39, 14, 24, 30, 22, 41, 15, 30,\n 6, 14, 121, 30, 6, 34, 47, 28, 46, 10, 24, 30, 2, 64, 15, 30,\n 17, 4, 122, 30, 29, 14, 46, 28, 49, 10, 24, 30, 24, 46, 15, 30,\n 4, 18, 122, 30, 13, 32, 46, 28, 48, 14, 24, 30, 42, 32, 15, 30,\n 20, 4, 117, 30, 40, 7, 47, 28, 43, 22, 24, 30, 10, 67, 15, 30,\n 19, 6, 118, 30, 18, 31, 47, 28, 34, 34, 24, 30, 20, 61, 15, 30\n ]\n }\n\n /**\n * Returns the final format bits with mask (level << 3 | mask).\n *\n * @return {Number[]} The final format bits.\n * @public\n * @static\n */\n static get FINAL_FORMAT() {\n return [\n // L\n 0x77c4, 0x72f3, 0x7daa, 0x789d, 0x662f, 0x6318, 0x6c41, 0x6976,\n // M\n 0x5412, 0x5125, 0x5e7c, 0x5b4b, 0x45f9, 0x40ce, 0x4f97, 0x4aa0,\n // Q\n 0x355f, 0x3068, 0x3f31, 0x3a06, 0x24b4, 0x2183, 0x2eda, 0x2bed,\n // H\n 0x1689, 0x13be, 0x1ce7, 0x19d0, 0x0762, 0x0255, 0x0d0c, 0x083b\n ]\n }\n\n /**\n * Returns a map of human-readable ECC levels.\n *\n * @return {Object} A ECC level mapping.\n * @public\n * @static\n */\n static get LEVELS() {\n return {\n L: 1,\n M: 2,\n Q: 3,\n H: 4\n }\n }\n}\n\nexport default ErrorCorrection\n","/*\n * QRious\n * Copyright (C) 2016 Alasdair Mercer\n * Copyright (C) 2010 Tom Zerucha\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see .\n */\n\n/**\n * Contains Galois field information.\n *\n * @public\n */\nclass Galois {\n\n /**\n * Returns the Galois field exponent table.\n *\n * @return {Number[]} The Galois field exponent table.\n * @public\n * @static\n */\n static get EXPONENT() {\n return [\n 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1d, 0x3a, 0x74, 0xe8, 0xcd, 0x87, 0x13, 0x26,\n 0x4c, 0x98, 0x2d, 0x5a, 0xb4, 0x75, 0xea, 0xc9, 0x8f, 0x03, 0x06, 0x0c, 0x18, 0x30, 0x60, 0xc0,\n 0x9d, 0x27, 0x4e, 0x9c, 0x25, 0x4a, 0x94, 0x35, 0x6a, 0xd4, 0xb5, 0x77, 0xee, 0xc1, 0x9f, 0x23,\n 0x46, 0x8c, 0x05, 0x0a, 0x14, 0x28, 0x50, 0xa0, 0x5d, 0xba, 0x69, 0xd2, 0xb9, 0x6f, 0xde, 0xa1,\n 0x5f, 0xbe, 0x61, 0xc2, 0x99, 0x2f, 0x5e, 0xbc, 0x65, 0xca, 0x89, 0x0f, 0x1e, 0x3c, 0x78, 0xf0,\n 0xfd, 0xe7, 0xd3, 0xbb, 0x6b, 0xd6, 0xb1, 0x7f, 0xfe, 0xe1, 0xdf, 0xa3, 0x5b, 0xb6, 0x71, 0xe2,\n 0xd9, 0xaf, 0x43, 0x86, 0x11, 0x22, 0x44, 0x88, 0x0d, 0x1a, 0x34, 0x68, 0xd0, 0xbd, 0x67, 0xce,\n 0x81, 0x1f, 0x3e, 0x7c, 0xf8, 0xed, 0xc7, 0x93, 0x3b, 0x76, 0xec, 0xc5, 0x97, 0x33, 0x66, 0xcc,\n 0x85, 0x17, 0x2e, 0x5c, 0xb8, 0x6d, 0xda, 0xa9, 0x4f, 0x9e, 0x21, 0x42, 0x84, 0x15, 0x2a, 0x54,\n 0xa8, 0x4d, 0x9a, 0x29, 0x52, 0xa4, 0x55, 0xaa, 0x49, 0x92, 0x39, 0x72, 0xe4, 0xd5, 0xb7, 0x73,\n 0xe6, 0xd1, 0xbf, 0x63, 0xc6, 0x91, 0x3f, 0x7e, 0xfc, 0xe5, 0xd7, 0xb3, 0x7b, 0xf6, 0xf1, 0xff,\n 0xe3, 0xdb, 0xab, 0x4b, 0x96, 0x31, 0x62, 0xc4, 0x95, 0x37, 0x6e, 0xdc, 0xa5, 0x57, 0xae, 0x41,\n 0x82, 0x19, 0x32, 0x64, 0xc8, 0x8d, 0x07, 0x0e, 0x1c, 0x38, 0x70, 0xe0, 0xdd, 0xa7, 0x53, 0xa6,\n 0x51, 0xa2, 0x59, 0xb2, 0x79, 0xf2, 0xf9, 0xef, 0xc3, 0x9b, 0x2b, 0x56, 0xac, 0x45, 0x8a, 0x09,\n 0x12, 0x24, 0x48, 0x90, 0x3d, 0x7a, 0xf4, 0xf5, 0xf7, 0xf3, 0xfb, 0xeb, 0xcb, 0x8b, 0x0b, 0x16,\n 0x2c, 0x58, 0xb0, 0x7d, 0xfa, 0xe9, 0xcf, 0x83, 0x1b, 0x36, 0x6c, 0xd8, 0xad, 0x47, 0x8e, 0x00\n ]\n }\n\n /**\n * Returns the Galois field log table.\n *\n * @return {Number[]} The Galois field log table.\n * @public\n * @static\n */\n static get LOG() {\n return [\n 0xff, 0x00, 0x01, 0x19, 0x02, 0x32, 0x1a, 0xc6, 0x03, 0xdf, 0x33, 0xee, 0x1b, 0x68, 0xc7, 0x4b,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 0x7b, 0xa4, 0x76, 0xc4, 0x17, 0x49, 0xec, 0x7f, 0x0c, 0x6f, 0xf6,\n 0x6c, 0xa1, 0x3b, 0x52, 0x29, 0x9d, 0x55, 0xaa, 0xfb, 0x60, 0x86, 0xb1, 0xbb, 0xcc, 0x3e, 0x5a,\n 0xcb, 0x59, 0x5f, 0xb0, 0x9c, 0xa9, 0xa0, 0x51, 0x0b, 0xf5, 0x16, 0xeb, 0x7a, 0x75, 0x2c, 0xd7,\n 0x4f, 0xae, 0xd5, 0xe9, 0xe6, 0xe7, 0xad, 0xe8, 0x74, 0xd6, 0xf4, 0xea, 0xa8, 0x50, 0x58, 0xaf\n ]\n }\n}\n\nexport default Galois\n","/*\n * QRious\n * Copyright (C) 2016 Alasdair Mercer\n * Copyright (C) 2010 Tom Zerucha\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see .\n */\n\n/**\n * Contains version pattern information.\n *\n * @public\n */\nclass Version {\n\n /**\n * Returns the version pattern block.\n *\n * @return {Number[]} The version pattern block.\n * @public\n * @static\n */\n static get BLOCK() {\n return [\n 0xc94, 0x5bc, 0xa99, 0x4d3, 0xbf6, 0x762, 0x847, 0x60d, 0x928, 0xb78, 0x45d, 0xa17, 0x532,\n 0x9a6, 0x683, 0x8c9, 0x7ec, 0xec4, 0x1e1, 0xfab, 0x08e, 0xc1a, 0x33f, 0xd75, 0x250, 0x9d5,\n 0x6f0, 0x8ba, 0x79f, 0xb0b, 0x42e, 0xa64, 0x541, 0xc69\n ]\n }\n}\n\nexport default Version\n","/*\n * QRious\n * Copyright (C) 2016 Alasdair Mercer\n * Copyright (C) 2010 Tom Zerucha\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see .\n */\n\nimport Alignment from './Alignment'\nimport ErrorCorrection from './ErrorCorrection'\nimport Galois from './Galois'\nimport Version from './Version'\n\n/**\n * Generates information for a QR code frame based on a specific value to be encoded.\n *\n * @public\n */\nclass Frame {\n\n static _createArray(length) {\n const array = []\n\n for (let i = 0; i < length; i++) {\n array[i] = 0\n }\n\n return array\n }\n\n static _getMaskBit(x, y) {\n let bit\n\n if (x > y) {\n bit = x\n x = y\n y = bit\n }\n\n bit = y\n bit += y * y\n bit >>= 1\n bit += x\n\n return bit\n }\n\n static _modN(x) {\n while (x >= 255) {\n x -= 255\n x = (x >> 8) + (x & 255)\n }\n\n return x\n }\n\n // *Badness* coefficients.\n static get N1() {\n return 3\n }\n static get N2() {\n return 3\n }\n static get N3() {\n return 40\n }\n static get N4() {\n return 10\n }\n\n /**\n * Creates an instance of {@link Frame} based on the options provided.\n *\n * @param {Frame~Options} options - the options to be used\n * @public\n */\n constructor(options) {\n this._badness = []\n this._level = ErrorCorrection.LEVELS[options.level]\n this._polynomial = []\n this._value = options.value\n this._valueLength = this._value.length\n this._version = 0\n this._stringBuffer = this._value.slice(0)\n\n let dataBlock\n let eccBlock\n let neccBlock1\n let neccBlock2\n\n while (this._version < 40) {\n this._version++\n\n let index = (this._level - 1) * 4 + (this._version - 1) * 16\n\n neccBlock1 = ErrorCorrection.BLOCKS[index++]\n neccBlock2 = ErrorCorrection.BLOCKS[index++]\n dataBlock = ErrorCorrection.BLOCKS[index++]\n eccBlock = ErrorCorrection.BLOCKS[index]\n\n index = dataBlock * (neccBlock1 + neccBlock2) + neccBlock2 - 3 + (this._version <= 9)\n\n if (this._valueLength <= index) {\n break\n }\n }\n\n this._dataBlock = dataBlock\n this._eccBlock = eccBlock\n this._neccBlock1 = neccBlock1\n this._neccBlock2 = neccBlock2\n\n /**\n * The data width is based on version.\n *\n * @public\n * @type {Number}\n */\n // FIXME: Ensure that it fits instead of being truncated.\n this.width = 17 + 4 * this._version\n\n /**\n * The image buffer.\n *\n * @public\n * @type {Number[]}\n */\n this.buffer = Frame._createArray(this.width * this.width)\n\n this._ecc = Frame._createArray(this._dataBlock + (this._dataBlock + this._eccBlock) * (this._neccBlock1 + this._neccBlock2) + this._neccBlock2)\n this._mask = Frame._createArray((this.width * (this.width + 1) + 1) / 2)\n\n this._insertFinders()\n this._insertAlignments()\n\n // Insert single foreground cell.\n this.buffer[8 + this.width * (this.width - 8)] = 1\n\n this._insertTimingGap()\n this._reverseMask()\n this._insertTimingRowAndColumn()\n this._insertVersion()\n this._syncMask()\n this._convertBitStream(this._stringBuffer.length)\n this._calculatePolynomial()\n this._appendEccToData()\n this._interleaveBlocks()\n this._pack()\n this._finish()\n }\n\n _addAlignment(x, y) {\n this.buffer[x + this.width * y] = 1\n\n for (let i = -2; i < 2; i++) {\n this.buffer[x + i + this.width * (y - 2)] = 1\n this.buffer[x - 2 + this.width * (y + i + 1)] = 1\n this.buffer[x + 2 + this.width * (y + i)] = 1\n this.buffer[x + i + 1 + this.width * (y + 2)] = 1\n }\n\n for (let i = 0; i < 2; i++) {\n this._setMask(x - 1, y + i)\n this._setMask(x + 1, y - i)\n this._setMask(x - i, y - 1)\n this._setMask(x + i, y + 1)\n }\n }\n\n _appendData(data, dataLength, ecc, eccLength) {\n for (let i = 0; i < eccLength; i++) {\n this._stringBuffer[ecc + i] = 0\n }\n\n for (let i = 0; i < dataLength; i++) {\n const bit = Galois.LOG[this._stringBuffer[data + i] ^ this._stringBuffer[ecc]]\n\n if (bit !== 255) {\n for (let j = 1; j < eccLength; j++) {\n this._stringBuffer[ecc + j - 1] = this._stringBuffer[ecc + j] ^ Galois.EXPONENT[Frame._modN(bit + this._polynomial[eccLength - j])]\n }\n } else {\n for (let j = ecc; j < ecc + eccLength; j++) {\n this._stringBuffer[j] = this._stringBuffer[j + 1]\n }\n }\n\n this._stringBuffer[ecc + eccLength - 1] = bit === 255 ? 0 : Galois.EXPONENT[Frame._modN(bit + this._polynomial[0])]\n }\n }\n\n _appendEccToData() {\n let data = 0\n let ecc = this._calculateMaxLength()\n\n for (let i = 0; i < this._neccBlock1; i++) {\n this._appendData(data, this._dataBlock, ecc, this._eccBlock)\n\n data += this._dataBlock\n ecc += this._eccBlock\n }\n\n for (let i = 0; i < this._neccBlock2; i++) {\n this._appendData(data, this._dataBlock + 1, ecc, this._eccBlock)\n\n data += this._dataBlock + 1\n ecc += this._eccBlock\n }\n }\n\n _applyMask(mask) {\n const width = this.width\n\n switch (mask) {\n case 0:\n for (let y = 0; y < width; y++) {\n for (let x = 0; x < width; x++) {\n if (!(x + y & 1) && !this._isMasked(x, y)) {\n this.buffer[x + y * width] ^= 1\n }\n }\n }\n\n break\n case 1:\n for (let y = 0; y < width; y++) {\n for (let x = 0; x < width; x++) {\n if (!(y & 1) && !this._isMasked(x, y)) {\n this.buffer[x + y * width] ^= 1\n }\n }\n }\n\n break\n case 2:\n for (let y = 0; y < width; y++) {\n for (let r3x = 0, x = 0; x < width; x++, r3x++) {\n if (r3x === 3) {\n r3x = 0\n }\n\n if (!r3x && !this._isMasked(x, y)) {\n this.buffer[x + y * width] ^= 1\n }\n }\n }\n\n break\n case 3:\n for (let r3y = 0, y = 0; y < width; y++, r3y++) {\n if (r3y === 3) {\n r3y = 0\n }\n\n for (let r3x = r3y, x = 0; x < width; x++, r3x++) {\n if (r3x === 3) {\n r3x = 0\n }\n\n if (!r3x && !this._isMasked(x, y)) {\n this.buffer[x + y * width] ^= 1\n }\n }\n }\n\n break\n case 4:\n for (let y = 0; y < width; y++) {\n for (let r3x = 0, r3y = y >> 1 & 1, x = 0; x < width; x++, r3x++) {\n if (r3x === 3) {\n r3x = 0\n r3y = !r3y\n }\n\n if (!r3y && !this._isMasked(x, y)) {\n this.buffer[x + y * width] ^= 1\n }\n }\n }\n\n break\n case 5:\n for (let r3y = 0, y = 0; y < width; y++, r3y++) {\n if (r3y === 3) {\n r3y = 0\n }\n\n for (let r3x = 0, x = 0; x < width; x++, r3x++) {\n if (r3x === 3) {\n r3x = 0\n }\n\n if (!((x & y & 1) + !(!r3x | !r3y)) && !this._isMasked(x, y)) {\n this.buffer[x + y * width] ^= 1\n }\n }\n }\n\n break\n case 6:\n for (let r3y = 0, y = 0; y < width; y++, r3y++) {\n if (r3y === 3) {\n r3y = 0\n }\n\n for (let r3x = 0, x = 0; x < width; x++, r3x++) {\n if (r3x === 3) {\n r3x = 0\n }\n\n if (!(x & y & 1 + (r3x && r3x === r3y) & 1) && !this._isMasked(x, y)) {\n this.buffer[x + y * width] ^= 1\n }\n }\n }\n\n break\n case 7:\n for (let r3y = 0, y = 0; y < width; y++, r3y++) {\n if (r3y === 3) {\n r3y = 0\n }\n\n for (let r3x = 0, x = 0; x < width; x++, r3x++) {\n if (r3x === 3) {\n r3x = 0\n }\n\n if (!((r3x && r3x === r3y) + (x + y & 1) & 1) && !this._isMasked(x, y)) {\n this.buffer[x + y * width] ^= 1\n }\n }\n }\n\n break\n }\n }\n\n _calculateMaxLength() {\n return this._dataBlock * (this._neccBlock1 + this._neccBlock2) + this._neccBlock2\n }\n\n _calculatePolynomial() {\n this._polynomial[0] = 1\n\n for (let i = 0; i < this._eccBlock; i++) {\n this._polynomial[i + 1] = 1\n\n for (let j = i; j > 0; j--) {\n this._polynomial[j] = this._polynomial[j] ? this._polynomial[j - 1] ^ Galois.EXPONENT[Frame._modN(Galois.LOG[this._polynomial[j]] + i)] : this._polynomial[j - 1]\n }\n\n this._polynomial[0] = Galois.EXPONENT[Frame._modN(Galois.LOG[this._polynomial[0]] + i)]\n }\n\n // Use logs for generator polynomial to save calculation step.\n for (let i = 0; i <= this._eccBlock; i++) {\n this._polynomial[i] = Galois.LOG[this._polynomial[i]]\n }\n }\n\n _checkBadness() {\n let bad = 0\n const width = this.width\n\n // Blocks of same colour.\n for (let y = 0; y < width - 1; y++) {\n for (let x = 0; x < width - 1; x++) {\n // All foreground colour.\n if (this.buffer[x + width * y] &&\n this.buffer[x + 1 + width * y] &&\n this.buffer[x + width * (y + 1)] &&\n this.buffer[x + 1 + width * (y + 1)] ||\n // All background colour.\n !(this.buffer[x + width * y] ||\n this.buffer[x + 1 + width * y] ||\n this.buffer[x + width * (y + 1)] ||\n this.buffer[x + 1 + width * (y + 1)])) {\n bad += Frame.N2\n }\n }\n }\n\n let bw = 0\n\n // X runs.\n for (let y = 0; y < width; y++) {\n let h = 0\n\n this._badness[0] = 0\n\n for (let b = 0, x = 0; x < width; x++) {\n let b1 = this.buffer[x + width * y]\n\n if (b === b1) {\n this._badness[h]++\n } else {\n this._badness[++h] = 1\n }\n\n b = b1\n bw += b ? 1 : -1\n }\n\n bad += this._getBadness(h)\n }\n\n if (bw < 0) {\n bw = -bw\n }\n\n let count = 0\n let big = bw\n big += big << 2\n big <<= 1\n\n while (big > width * width) {\n big -= width * width\n count++\n }\n\n bad += count * Frame.N4\n\n // Y runs.\n for (let x = 0; x < width; x++) {\n let h = 0\n\n this._badness[0] = 0\n\n for (let b = 0, y = 0; y < width; y++) {\n let b1 = this.buffer[x + width * y]\n\n if (b === b1) {\n this._badness[h]++\n } else {\n this._badness[++h] = 1\n }\n\n b = b1\n }\n\n bad += this._getBadness(h)\n }\n\n return bad\n }\n\n _convertBitStream(length) {\n // Convert string to bit stream. 8-bit data to QR-coded 8-bit data (numeric, alphanum, or kanji\n // not supported).\n\n for (let i = 0; i < length; i++) {\n this._ecc[i] = this._stringBuffer.charCodeAt(i)\n }\n\n this._stringBuffer = this._ecc.slice(0)\n\n const maxLength = this._calculateMaxLength()\n\n if (length >= maxLength - 2) {\n length = maxLength - 2\n\n if (this._version > 9) {\n length--\n }\n }\n\n // Shift and re-pack to insert length prefix.\n let index = length\n\n if (this._version > 9) {\n this._stringBuffer[index + 2] = 0\n this._stringBuffer[index + 3] = 0\n\n while (index--) {\n const bit = this._stringBuffer[index]\n\n this._stringBuffer[index + 3] |= 255 & bit << 4\n this._stringBuffer[index + 2] = bit >> 4\n }\n\n this._stringBuffer[2] |= 255 & length << 4\n this._stringBuffer[1] = length >> 4\n this._stringBuffer[0] = 0x40 | length >> 12\n } else {\n this._stringBuffer[index + 1] = 0\n this._stringBuffer[index + 2] = 0\n\n while (index--) {\n const bit = this._stringBuffer[index]\n\n this._stringBuffer[index + 2] |= 255 & bit << 4\n this._stringBuffer[index + 1] = bit >> 4\n }\n\n this._stringBuffer[1] |= 255 & length << 4\n this._stringBuffer[0] = 0x40 | length >> 4\n }\n\n // Fill to end with pad pattern.\n index = length + 3 - (this._version < 10)\n\n while (index < maxLength) {\n this._stringBuffer[index++] = 0xec\n this._stringBuffer[index++] = 0x11\n }\n }\n\n _getBadness(length) {\n let badRuns = 0\n\n for (let i = 0; i <= length; i++) {\n if (this._badness[i] >= 5) {\n badRuns += Frame.N1 + this._badness[i] - 5\n }\n }\n\n // FBFFFBF as in finder.\n for (let i = 3; i < length - 1; i += 2) {\n if (this._badness[i - 2] === this._badness[i + 2] &&\n this._badness[i + 2] === this._badness[i - 1] &&\n this._badness[i - 1] === this._badness[i + 1] &&\n this._badness[i - 1] * 3 === this._badness[i] &&\n // Background around the foreground pattern? Not part of the specs.\n (this._badness[i - 3] === 0 || i + 3 > length ||\n this._badness[i - 3] * 3 >= this._badness[i] * 4 ||\n this._badness[i + 3] * 3 >= this._badness[i] * 4)) {\n badRuns += Frame.N3\n }\n }\n\n return badRuns\n }\n\n _finish() {\n // Save pre-mask copy of frame.\n this._stringBuffer = this.buffer.slice(0)\n\n let bit = 0\n let i\n let mask = 30000\n\n /*\n * Using for instead of while since in original Arduino code if an early mask was \"good enough\" it wouldn't try for\n * a better one since they get more complex and take longer.\n */\n for (i = 0; i < 8; i++) {\n // Returns foreground-background imbalance.\n this._applyMask(i)\n\n const currentMask = this._checkBadness()\n\n // Is current mask better than previous best?\n if (currentMask < mask) {\n mask = currentMask\n bit = i\n }\n\n // Don't increment \"i\" to a void redoing mask.\n if (bit === 7) {\n break\n }\n\n // Reset for next pass.\n this.buffer = this._stringBuffer.slice(0)\n }\n\n // Redo best mask as none were \"good enough\" (i.e. last wasn't bit).\n if (bit !== i) {\n this._applyMask(bit)\n }\n\n // Add in final mask/ECC level bytes.\n mask = ErrorCorrection.FINAL_FORMAT[bit + (this._level - 1 << 3)]\n\n // Low byte.\n for (i = 0; i < 8; i++, mask >>= 1) {\n if (mask & 1) {\n this.buffer[this.width - 1 - i + this.width * 8] = 1\n\n if (i < 6) {\n this.buffer[8 + this.width * i] = 1\n } else {\n this.buffer[8 + this.width * (i + 1)] = 1\n }\n }\n }\n\n // High byte.\n for (i = 0; i < 7; i++, mask >>= 1) {\n if (mask & 1) {\n this.buffer[8 + this.width * (this.width - 7 + i)] = 1\n\n if (i) {\n this.buffer[6 - i + this.width * 8] = 1\n } else {\n this.buffer[7 + this.width * 8] = 1\n }\n }\n }\n }\n\n _interleaveBlocks() {\n const maxLength = this._calculateMaxLength()\n let i\n let k = 0\n\n for (i = 0; i < this._dataBlock; i++) {\n for (let j = 0; j < this._neccBlock1; j++) {\n this._ecc[k++] = this._stringBuffer[i + j * this._dataBlock]\n }\n\n for (let j = 0; j < this._neccBlock2; j++) {\n this._ecc[k++] = this._stringBuffer[this._neccBlock1 * this._dataBlock + i + j * (this._dataBlock + 1)]\n }\n }\n\n for (let j = 0; j < this._neccBlock2; j++) {\n this._ecc[k++] = this._stringBuffer[this._neccBlock1 * this._dataBlock + i + j * (this._dataBlock + 1)]\n }\n\n for (i = 0; i < this._eccBlock; i++) {\n for (let j = 0; j < this._neccBlock1 + this._neccBlock2; j++) {\n this._ecc[k++] = this._stringBuffer[maxLength + i + j * this._eccBlock]\n }\n }\n\n this._stringBuffer = this._ecc\n }\n\n _insertAlignments() {\n const width = this.width\n\n if (this._version > 1) {\n const i = Alignment.BLOCK[this._version]\n let y = width - 7\n\n for (;;) {\n let x = width - 7\n\n while (x > i - 3) {\n this._addAlignment(x, y)\n\n if (x < i) {\n break\n }\n\n x -= i\n }\n\n if (y <= i + 9) {\n break\n }\n\n y -= i\n\n this._addAlignment(6, y)\n this._addAlignment(y, 6)\n }\n }\n }\n\n _insertFinders() {\n const width = this.width\n\n for (let i = 0; i < 3; i++) {\n let j = 0\n let y = 0\n\n if (i === 1) {\n j = width - 7\n }\n if (i === 2) {\n y = width - 7\n }\n\n this.buffer[y + 3 + width * (j + 3)] = 1\n\n for (let x = 0; x < 6; x++) {\n this.buffer[y + x + width * j] = 1\n this.buffer[y + width * (j + x + 1)] = 1\n this.buffer[y + 6 + width * (j + x)] = 1\n this.buffer[y + x + 1 + width * (j + 6)] = 1\n }\n\n for (let x = 1; x < 5; x++) {\n this._setMask(y + x, j + 1)\n this._setMask(y + 1, j + x + 1)\n this._setMask(y + 5, j + x)\n this._setMask(y + x + 1, j + 5)\n }\n\n for (let x = 2; x < 4; x++) {\n this.buffer[y + x + width * (j + 2)] = 1\n this.buffer[y + 2 + width * (j + x + 1)] = 1\n this.buffer[y + 4 + width * (j + x)] = 1\n this.buffer[y + x + 1 + width * (j + 4)] = 1\n }\n }\n }\n\n _insertTimingGap() {\n const width = this.width\n\n for (let y = 0; y < 7; y++) {\n this._setMask(7, y)\n this._setMask(width - 8, y)\n this._setMask(7, y + width - 7)\n }\n\n for (let x = 0; x < 8; x++) {\n this._setMask(x, 7)\n this._setMask(x + width - 8, 7)\n this._setMask(x, width - 8)\n }\n }\n\n _insertTimingRowAndColumn() {\n const width = this.width\n\n for (let x = 0; x < width - 14; x++) {\n if (x & 1) {\n this._setMask(8 + x, 6)\n this._setMask(6, 8 + x)\n } else {\n this.buffer[8 + x + width * 6] = 1\n this.buffer[6 + width * (8 + x)] = 1\n }\n }\n }\n\n _insertVersion() {\n const width = this.width\n\n if (this._version > 6) {\n let i = Version.BLOCK[this._version - 7]\n let j = 17\n\n for (let x = 0; x < 6; x++) {\n for (let y = 0; y < 3; y++, j--) {\n if (1 & (j > 11 ? this._version >> j - 12 : i >> j)) {\n this.buffer[5 - x + width * (2 - y + width - 11)] = 1\n this.buffer[2 - y + width - 11 + width * (5 - x)] = 1\n } else {\n this._setMask(5 - x, 2 - y + width - 11)\n this._setMask(2 - y + width - 11, 5 - x)\n }\n }\n }\n }\n }\n\n _isMasked(x, y) {\n const bit = Frame._getMaskBit(x, y)\n\n return this._mask[bit] === 1\n }\n\n _pack() {\n let x = this.width - 1\n let y = this.width - 1\n let k = 1\n let v = 1\n\n // Interleaved data and ECC codes.\n const length = (this._dataBlock + this._eccBlock) * (this._neccBlock1 + this._neccBlock2) + this._neccBlock2\n\n for (let i = 0; i < length; i++) {\n let bit = this._stringBuffer[i]\n\n for (let j = 0; j < 8; j++, bit <<= 1) {\n if (0x80 & bit) {\n this.buffer[x + this.width * y] = 1\n }\n\n // Find next fill position.\n do {\n if (v) {\n x--\n } else {\n x++\n\n if (k) {\n if (y !== 0) {\n y--\n } else {\n x -= 2\n k = !k\n\n if (x === 6) {\n x--\n y = 9\n }\n }\n } else if (y !== this.width - 1) {\n y++\n } else {\n x -= 2\n k = !k\n\n if (x === 6) {\n x--\n y -= 8\n }\n }\n }\n\n v = !v\n } while (this._isMasked(x, y))\n }\n }\n }\n\n _reverseMask() {\n const width = this.width\n\n for (let x = 0; x < 9; x++) {\n this._setMask(x, 8)\n }\n\n for (let x = 0; x < 8; x++) {\n this._setMask(x + width - 8, 8)\n this._setMask(8, x)\n }\n\n for (let y = 0; y < 7; y++) {\n this._setMask(8, y + width - 7)\n }\n }\n\n _setMask(x, y) {\n const bit = Frame._getMaskBit(x, y)\n\n this._mask[bit] = 1\n }\n\n _syncMask() {\n const width = this.width\n\n for (let y = 0; y < width; y++) {\n for (let x = 0; x <= y; x++) {\n if (this.buffer[x + width * y]) {\n this._setMask(x, y)\n }\n }\n }\n }\n}\n\nexport default Frame\n\n/**\n * The options used by {@link Frame}.\n *\n * @typedef {Object} Frame~Options\n * @property {String} level - The ECC level to be used.\n * @property {String} value - The value to be encoded.\n */\n","/*\n * QRious\n * Copyright (C) 2016 Alasdair Mercer\n * Copyright (C) 2010 Tom Zerucha\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see .\n */\n\nimport Renderer from './Renderer'\n\n/**\n * An implementation of {@link Renderer} for working with img elements.\n *\n * This depends on {@link CanvasRenderer} being executed first as this implementation simply applies the data URL from\n * the rendered canvas element as the src for the img element being rendered.\n *\n * @public\n * @extends Renderer\n */\nclass ImageRenderer extends Renderer {\n\n /**\n * @override\n */\n draw() {\n const qrious = this.qrious\n\n qrious.image.src = qrious.toDataURL()\n }\n\n /**\n * @override\n */\n reset() {\n const qrious = this.qrious\n\n qrious.image.src = ''\n }\n\n /**\n * @override\n */\n resize() {\n const qrious = this.qrious\n const image = qrious.image\n\n image.width = qrious.size\n image.height = qrious.size\n }\n}\n\nexport default ImageRenderer\n","/*\n * QRious\n * Copyright (C) 2016 Alasdair Mercer\n * Copyright (C) 2010 Tom Zerucha\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see .\n */\n\n/**\n * A basic manager for {@link Service} implementations that are mapped to simple names.\n *\n * @public\n */\nclass ServiceManager {\n\n /**\n * Creates a new instance of {@link ServiceManager}.\n *\n * @public\n */\n constructor() {\n this._services = {}\n }\n\n /**\n * Returns the {@link Service} being managed with the specified name.\n *\n * @param {String} name - the name of the {@link Service} to be returned\n * @return {Service} The {@link Service} is being managed with name.\n * @throws {Error} If no {@link Service} is being managed with name.\n * @public\n */\n getService(name) {\n const service = this._services[name]\n if (!service) {\n throw new Error(`Service is not being managed with name: ${name}`)\n }\n\n return service\n }\n\n /**\n * Sets the {@link Service} implementation to be managed for the specified name to the\n * service provided.\n *\n * @param {String} name - the name of the {@link Service} to be managed with name\n * @param {Service} service - the {@link Service} implementation to be managed\n * @throws {Error} If a {@link Service} is already being managed with the same name.\n * @public\n */\n setService(name, service) {\n if (this._services[name]) {\n throw new Error(`Service is already managed with name: ${name}`)\n }\n\n if (service) {\n this._services[name] = service\n }\n }\n}\n\nexport default ServiceManager\n","/*\n * QRious\n * Copyright (C) 2016 Alasdair Mercer\n * Copyright (C) 2010 Tom Zerucha\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see .\n */\n\nimport CanvasRenderer from './renderer/CanvasRenderer'\nimport Frame from './Frame'\nimport ImageRenderer from './renderer/ImageRenderer'\nimport ServiceManager from './service/ServiceManager'\nimport Utilities from './util/Utilities'\n\n/**\n * Enables configuration of a QR code generator which uses HTML5 canvas for rendering.\n *\n * @public\n */\nclass QRious {\n\n /**\n * Returns the default options for {@link QRious}.\n *\n * @return {QRious~Options} The default options.\n * @public\n * @static\n */\n static get DEFAULTS() {\n return {\n background: 'white',\n foreground: 'black',\n level: 'L',\n mime: 'image/png',\n size: 100,\n value: ''\n }\n }\n\n /**\n * Returns the current version of {@link QRious}.\n *\n * @return {String} The current version.\n * @public\n * @static\n */\n static get VERSION() {\n return '2.0.0'\n }\n\n /**\n * Configures the service provided to be used by all {@link QRious} instances.\n *\n * @param {Service} service - the {@link Service} to be configured\n * @throws {Error} If a {@link Service} has already been configured with the same name.\n * @public\n * @static\n */\n static use(service) {\n QRious._serviceManager.setService(service.getName(), service)\n }\n\n static _parseOptions(options) {\n options = Object.assign({}, QRious.DEFAULTS, options)\n options.level = Utilities.toUpperCase(options.level)\n options.size = Math.abs(options.size)\n\n return options\n }\n\n /**\n * Creates a new instance of {@link QRious} based on the options provided.\n *\n * @param {QRious~Options} [options] - the options to be used\n * @public\n */\n constructor(options) {\n options = QRious._parseOptions(options)\n\n Utilities.privatize(this, options)\n\n let element = this._element\n let elementService = QRious._serviceManager.getService('element')\n\n /**\n * The canvas being used to render the QR code for this {@link QRious}.\n *\n * @public\n * @type {*}\n */\n this.canvas = element && elementService.isCanvas(element) ? element : elementService.createCanvas()\n this.canvas.qrious = this\n\n /**\n * The img to contain the rendered QR code for this {@link QRious}.\n *\n * @public\n * @type {*}\n */\n this.image = element && elementService.isImage(element) ? element : elementService.createImage()\n this.image.qrious = this\n\n this._renderers = [\n new CanvasRenderer(this),\n new ImageRenderer(this)\n ]\n\n this.update()\n }\n\n /**\n * Returns the image data URI for the generated QR code using the mime provided.\n *\n * @param {String} [mime] - the MIME type for the image\n * @return {String} The image data URI for the QR code.\n * @public\n */\n toDataURL(mime) {\n return this.canvas.toDataURL(mime || this.mime)\n }\n\n /**\n * Updates this {@link QRious} by generating a new {@link Frame} and re-rendering the QR code.\n *\n * @protected\n */\n update() {\n const frame = new Frame({\n level: this.level,\n value: this.value\n })\n\n this._renderers.forEach((renderer) => renderer.render(frame))\n }\n\n /**\n * Returns the background color for the QR code.\n *\n * @return {String} The background color.\n * @public\n */\n get background() {\n return this._background\n }\n\n /**\n * Sets the background color for the QR code to background.\n *\n * @param {String} [background=\"white\"] - the background color to be set\n * @public\n */\n set background(background) {\n const changed = Utilities.setter(this, '_background', background, QRious.DEFAULTS.background)\n\n if (changed) {\n this.update()\n }\n }\n\n /**\n * Returns the foreground color for the QR code.\n *\n * @return {String} The foreground color.\n * @public\n */\n get foreground() {\n return this._foreground\n }\n\n /**\n * Sets the foreground color for the QR code to foreground.\n *\n * @param {String} [foreground=\"black\"] - the foreground color to be set\n * @public\n */\n set foreground(foreground) {\n const changed = Utilities.setter(this, '_foreground', foreground, QRious.DEFAULTS.foreground)\n\n if (changed) {\n this.update()\n }\n }\n\n /**\n * Returns the error correction level for the QR code.\n *\n * @return {String} The ECC level.\n * @public\n */\n get level() {\n return this._level\n }\n\n /**\n * Sets the error correction level for the QR code to level.\n *\n * level will be transformed to upper case to aid mapping to known ECC level blocks.\n *\n * @param {String} [level=\"L\"] - the ECC level to be set\n * @public\n */\n set level(level) {\n const changed = Utilities.setter(this, '_level', level, QRious.DEFAULTS.level, Utilities.toUpperCase)\n\n if (changed) {\n this.update()\n }\n }\n\n /**\n * Returns the MIME type for the image rendered for the QR code.\n *\n * @return {String} The image MIME type.\n * @public\n */\n get mime() {\n return this._mime\n }\n\n /**\n * Sets the MIME type for the image rendered for the QR code to mime.\n *\n * @param {String} [mime=\"image/png\"] - the image MIME type to be set\n * @public\n */\n set mime(mime) {\n const changed = Utilities.setter(this, '_mime', mime, QRious.DEFAULTS.mime)\n\n if (changed) {\n this.update()\n }\n }\n\n /**\n * Returns the size of the QR code.\n *\n * @return {Number} The size in pixels.\n * @public\n */\n get size() {\n return this._size\n }\n\n /**\n * Sets the size of the QR code to size.\n *\n * size will be transformed to ensure that it is always an absolute positive numbers (e.g.\n * -100 would become 100).\n *\n * @param {Number} [size=100] - the size in pixels to be set\n * @public\n */\n set size(size) {\n const changed = Utilities.setter(this, '_size', size, QRious.DEFAULTS.size, Math.abs)\n\n if (changed) {\n this.update()\n }\n }\n\n /**\n * Returns the value of the QR code.\n *\n * @return {String} The value.\n * @public\n */\n get value() {\n return this._value\n }\n\n /**\n * Sets the value of the QR code to value.\n *\n * @param {String} [value=\"\"] - the value to be set\n * @public\n */\n set value(value) {\n const changed = Utilities.setter(this, '_value', value, QRious.DEFAULTS.value)\n\n if (changed) {\n this.update()\n }\n }\n}\n\nQRious._serviceManager = new ServiceManager()\n\nexport default QRious\n\n/**\n * The options used by {@link QRious}.\n *\n * @typedef {Object} QRious~Options\n * @property {String} [background=\"white\"] - The background color to be applied to the QR code.\n * @property {*} [element] - The element to be used to render the QR code which may either be an canvas or\n * img. The element(s) will be created if needed.\n * @property {String} [foreground=\"black\"] - The foreground color to be applied to the QR code.\n * @property {String} [level=\"L\"] - The error correction level to be applied to the QR code.\n * @property {String} [mime=\"image/png\"] - The MIME type to be used to render the image for the QR code.\n * @property {Number} [size=100] - The size of the QR code in pixels.\n * @property {String} [value=\"\"] - The value to be encoded within the QR code.\n */\n","/*\n * QRious\n * Copyright (C) 2016 Alasdair Mercer\n * Copyright (C) 2010 Tom Zerucha\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see .\n */\n\nimport BrowserElementService from '../service/element/BrowserElementService'\nimport QRious from '../QRious'\n\nQRious.use(new BrowserElementService())\n\nexport default QRious\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;EA+EO,IAAI,cAAc,GAAG,UAAU,QAAQ,EAAE,WAAW,EAAE;AAC7D,EAAA,EAAE,IAAI,CAAC,CAAC,QAAQ,YAAY,WAAW,CAAC,EAAE;AAC1C,EAAA,IAAI,MAAM,IAAI,SAAS,CAAC,mCAAmC,CAAC,CAAC;AAC7D,EA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EAAA;AACF,EAAA;;;;;AAGH,EAAA,OAAO,eAAP,GAAyB,IAAI,cAAJ,EAAzB,CAEA;;ECpRA,OAAO,GAAP,CAAW,IAAI,qBAAJ,EAAX,EAEA;;;;"} \ No newline at end of file diff --git a/dist/umd/qrious.min.js b/dist/umd/qrious.min.js new file mode 100644 index 0000000..c9feadb --- /dev/null +++ b/dist/umd/qrious.min.js @@ -0,0 +1,5 @@ +/*! QRious v2.0.0 | (C) 2016 Alasdair Mercer | GPL v3 License +Based on jsqrencode | (C) 2010 tz@execpc.com | GPL v3 License +*/ +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define("qrious",e):t.QRious=e()}(this,function(){"use strict";var t=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},e=function(){function t(t,e){for(var i=0;ie&&(i=t,t=e,e=i),i=e,i+=e*e,i>>=1,i+=t}},{key:"_modN",value:function(t){for(;t>=255;)t-=255,t=(t>>8)+(255&t);return t}},{key:"N1",get:function(){return 3}},{key:"N2",get:function(){return 3}},{key:"N3",get:function(){return 40}},{key:"N4",get:function(){return 10}}]),e(i,[{key:"_addAlignment",value:function(t,e){this.buffer[t+this.width*e]=1;for(var i=-2;i<2;i++)this.buffer[t+i+this.width*(e-2)]=1,this.buffer[t-2+this.width*(e+i+1)]=1,this.buffer[t+2+this.width*(e+i)]=1,this.buffer[t+i+1+this.width*(e+2)]=1;for(var s=0;s<2;s++)this._setMask(t-1,e+s),this._setMask(t+1,e-s),this._setMask(t-s,e-1),this._setMask(t+s,e+1)}},{key:"_appendData",value:function(t,e,s,r){for(var n=0;n>1&1,d=0;d0;e--)this._polynomial[e]=this._polynomial[e]?this._polynomial[e-1]^l.EXPONENT[i._modN(l.LOG[this._polynomial[e]]+t)]:this._polynomial[e-1];this._polynomial[0]=l.EXPONENT[i._modN(l.LOG[this._polynomial[0]]+t)]}for(var s=0;s<=this._eccBlock;s++)this._polynomial[s]=l.LOG[this._polynomial[s]]}},{key:"_checkBadness",value:function(){for(var t=0,e=this.width,s=0;se*e;)l-=e*e,c++;t+=c*i.N4;for(var _=0;_=i-2&&(t=i-2,this._version>9&&t--);var s=t;if(this._version>9){for(this._stringBuffer[s+2]=0,this._stringBuffer[s+3]=0;s--;){var r=this._stringBuffer[s];this._stringBuffer[s+3]|=255&r<<4,this._stringBuffer[s+2]=r>>4}this._stringBuffer[2]|=255&t<<4,this._stringBuffer[1]=t>>4,this._stringBuffer[0]=64|t>>12}else{for(this._stringBuffer[s+1]=0,this._stringBuffer[s+2]=0;s--;){var n=this._stringBuffer[s];this._stringBuffer[s+2]|=255&n<<4,this._stringBuffer[s+1]=n>>4}this._stringBuffer[1]|=255&t<<4,this._stringBuffer[0]=64|t>>4}for(s=t+3-(this._version<10);s=5&&(e+=i.N1+this._badness[s]-5);for(var r=3;rt||3*this._badness[r-3]>=4*this._badness[r]||3*this._badness[r+3]>=4*this._badness[r])&&(e+=i.N3);return e}},{key:"_finish",value:function(){this._stringBuffer=this.buffer.slice(0);var t=0,e=void 0,i=3e4;for(e=0;e<8;e++){this._applyMask(e);var s=this._checkBadness();if(s>=1)1&i&&(this.buffer[this.width-1-e+8*this.width]=1,e<6?this.buffer[8+this.width*e]=1:this.buffer[8+this.width*(e+1)]=1);for(e=0;e<7;e++,i>>=1)1&i&&(this.buffer[8+this.width*(this.width-7+e)]=1,e?this.buffer[6-e+8*this.width]=1:this.buffer[7+8*this.width]=1)}},{key:"_interleaveBlocks",value:function(){var t=this._calculateMaxLength(),e=void 0,i=0;for(e=0;e1)for(var e=u.BLOCK[this._version],i=t-7;;){for(var s=t-7;s>e-3&&(this._addAlignment(s,i),!(s6)for(var e=_.BLOCK[this._version-7],i=17,s=0;s<6;s++)for(var r=0;r<3;r++,i--)1&(i>11?this._version>>i-12:e>>i)?(this.buffer[5-s+t*(2-r+t-11)]=1,this.buffer[2-r+t-11+t*(5-s)]=1):(this._setMask(5-s,2-r+t-11),this._setMask(2-r+t-11,5-s))}},{key:"_isMasked",value:function(t,e){var s=i._getMaskBit(t,e);return 1===this._mask[s]}},{key:"_pack",value:function(){for(var t=this.width-1,e=this.width-1,i=1,s=1,r=(this._dataBlock+this._eccBlock)*(this._neccBlock1+this._neccBlock2)+this._neccBlock2,n=0;n 1) {\n var childArray = Array(childrenLength);\n\n for (var i = 0; i < childrenLength; i++) {\n childArray[i] = arguments[i + 3];\n }\n\n props.children = childArray;\n }\n\n return {\n $$typeof: REACT_ELEMENT_TYPE,\n type: type,\n key: key === undefined ? null : '' + key,\n ref: null,\n props: props,\n _owner: null\n };\n };\n}();\n\nexport var asyncToGenerator = function (fn) {\n return function () {\n var gen = fn.apply(this, arguments);\n return new Promise(function (resolve, reject) {\n function step(key, arg) {\n try {\n var info = gen[key](arg);\n var value = info.value;\n } catch (error) {\n reject(error);\n return;\n }\n\n if (info.done) {\n resolve(value);\n } else {\n return Promise.resolve(value).then(function (value) {\n return step(\"next\", value);\n }, function (err) {\n return step(\"throw\", err);\n });\n }\n }\n\n return step(\"next\");\n });\n };\n};\n\nexport var classCallCheck = function (instance, Constructor) {\n if (!(instance instanceof Constructor)) {\n throw new TypeError(\"Cannot call a class as a function\");\n }\n};\n\nexport var createClass = function () {\n function defineProperties(target, props) {\n for (var i = 0; i < props.length; i++) {\n var descriptor = props[i];\n descriptor.enumerable = descriptor.enumerable || false;\n descriptor.configurable = true;\n if (\"value\" in descriptor) descriptor.writable = true;\n Object.defineProperty(target, descriptor.key, descriptor);\n }\n }\n\n return function (Constructor, protoProps, staticProps) {\n if (protoProps) defineProperties(Constructor.prototype, protoProps);\n if (staticProps) defineProperties(Constructor, staticProps);\n return Constructor;\n };\n}();\n\nexport var defineEnumerableProperties = function (obj, descs) {\n for (var key in descs) {\n var desc = descs[key];\n desc.configurable = desc.enumerable = true;\n if (\"value\" in desc) desc.writable = true;\n Object.defineProperty(obj, key, desc);\n }\n\n return obj;\n};\n\nexport var defaults = function (obj, defaults) {\n var keys = Object.getOwnPropertyNames(defaults);\n\n for (var i = 0; i < keys.length; i++) {\n var key = keys[i];\n var value = Object.getOwnPropertyDescriptor(defaults, key);\n\n if (value && value.configurable && obj[key] === undefined) {\n Object.defineProperty(obj, key, value);\n }\n }\n\n return obj;\n};\n\nexport var defineProperty = function (obj, key, value) {\n if (key in obj) {\n Object.defineProperty(obj, key, {\n value: value,\n enumerable: true,\n configurable: true,\n writable: true\n });\n } else {\n obj[key] = value;\n }\n\n return obj;\n};\n\nvar _extends = Object.assign || function (target) {\n for (var i = 1; i < arguments.length; i++) {\n var source = arguments[i];\n\n for (var key in source) {\n if (Object.prototype.hasOwnProperty.call(source, key)) {\n target[key] = source[key];\n }\n }\n }\n\n return target;\n};\n\nexport var get = function get(object, property, receiver) {\n if (object === null) object = Function.prototype;\n var desc = Object.getOwnPropertyDescriptor(object, property);\n\n if (desc === undefined) {\n var parent = Object.getPrototypeOf(object);\n\n if (parent === null) {\n return undefined;\n } else {\n return get(parent, property, receiver);\n }\n } else if (\"value\" in desc) {\n return desc.value;\n } else {\n var getter = desc.get;\n\n if (getter === undefined) {\n return undefined;\n }\n\n return getter.call(receiver);\n }\n};\n\nexport var inherits = function (subClass, superClass) {\n if (typeof superClass !== \"function\" && superClass !== null) {\n throw new TypeError(\"Super expression must either be null or a function, not \" + typeof superClass);\n }\n\n subClass.prototype = Object.create(superClass && superClass.prototype, {\n constructor: {\n value: subClass,\n enumerable: false,\n writable: true,\n configurable: true\n }\n });\n if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;\n};\n\nvar _instanceof = function (left, right) {\n if (right != null && typeof Symbol !== \"undefined\" && right[Symbol.hasInstance]) {\n return right[Symbol.hasInstance](left);\n } else {\n return left instanceof right;\n }\n};\n\nexport var interopRequireDefault = function (obj) {\n return obj && obj.__esModule ? obj : {\n default: obj\n };\n};\n\nexport var interopRequireWildcard = function (obj) {\n if (obj && obj.__esModule) {\n return obj;\n } else {\n var newObj = {};\n\n if (obj != null) {\n for (var key in obj) {\n if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key];\n }\n }\n\n newObj.default = obj;\n return newObj;\n }\n};\n\nexport var newArrowCheck = function (innerThis, boundThis) {\n if (innerThis !== boundThis) {\n throw new TypeError(\"Cannot instantiate an arrow function\");\n }\n};\n\nexport var objectDestructuringEmpty = function (obj) {\n if (obj == null) throw new TypeError(\"Cannot destructure undefined\");\n};\n\nexport var objectWithoutProperties = function (obj, keys) {\n var target = {};\n\n for (var i in obj) {\n if (keys.indexOf(i) >= 0) continue;\n if (!Object.prototype.hasOwnProperty.call(obj, i)) continue;\n target[i] = obj[i];\n }\n\n return target;\n};\n\nexport var possibleConstructorReturn = function (self, call) {\n if (!self) {\n throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\");\n }\n\n return call && (typeof call === \"object\" || typeof call === \"function\") ? call : self;\n};\n\nexport var selfGlobal = typeof global === \"undefined\" ? self : global;\n\nexport var set = function set(object, property, value, receiver) {\n var desc = Object.getOwnPropertyDescriptor(object, property);\n\n if (desc === undefined) {\n var parent = Object.getPrototypeOf(object);\n\n if (parent !== null) {\n set(parent, property, value, receiver);\n }\n } else if (\"value\" in desc && desc.writable) {\n desc.value = value;\n } else {\n var setter = desc.set;\n\n if (setter !== undefined) {\n setter.call(receiver, value);\n }\n }\n\n return value;\n};\n\nexport var slicedToArray = function () {\n function sliceIterator(arr, i) {\n var _arr = [];\n var _n = true;\n var _d = false;\n var _e = undefined;\n\n try {\n for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {\n _arr.push(_s.value);\n\n if (i && _arr.length === i) break;\n }\n } catch (err) {\n _d = true;\n _e = err;\n } finally {\n try {\n if (!_n && _i[\"return\"]) _i[\"return\"]();\n } finally {\n if (_d) throw _e;\n }\n }\n\n return _arr;\n }\n\n return function (arr, i) {\n if (Array.isArray(arr)) {\n return arr;\n } else if (Symbol.iterator in Object(arr)) {\n return sliceIterator(arr, i);\n } else {\n throw new TypeError(\"Invalid attempt to destructure non-iterable instance\");\n }\n };\n}();\n\nexport var slicedToArrayLoose = function (arr, i) {\n if (Array.isArray(arr)) {\n return arr;\n } else if (Symbol.iterator in Object(arr)) {\n var _arr = [];\n\n for (var _iterator = arr[Symbol.iterator](), _step; !(_step = _iterator.next()).done;) {\n _arr.push(_step.value);\n\n if (i && _arr.length === i) break;\n }\n\n return _arr;\n } else {\n throw new TypeError(\"Invalid attempt to destructure non-iterable instance\");\n }\n};\n\nexport var taggedTemplateLiteral = function (strings, raw) {\n return Object.freeze(Object.defineProperties(strings, {\n raw: {\n value: Object.freeze(raw)\n }\n }));\n};\n\nexport var taggedTemplateLiteralLoose = function (strings, raw) {\n strings.raw = raw;\n return strings;\n};\n\nexport var temporalRef = function (val, name, undef) {\n if (val === undef) {\n throw new ReferenceError(name + \" is not defined - temporal dead zone\");\n } else {\n return val;\n }\n};\n\nexport var temporalUndefined = {};\n\nexport var toArray = function (arr) {\n return Array.isArray(arr) ? arr : Array.from(arr);\n};\n\nexport var toConsumableArray = function (arr) {\n if (Array.isArray(arr)) {\n for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i];\n\n return arr2;\n } else {\n return Array.from(arr);\n }\n};\n\nbabelHelpers;\n\nexport { _typeof as typeof, _extends as extends, _instanceof as instanceof }","/*\n * QRious\n * Copyright (C) 2016 Alasdair Mercer\n * Copyright (C) 2010 Tom Zerucha\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see .\n */\n\n/**\n * Contains utility methods that are useful throughout the library.\n *\n * @public\n */\nclass Utilities {\n\n /**\n * Copies all properties from the source object to the target object, however, all property\n * names on the target will be prefixed with an underscore, used to indicate that they are private.\n *\n * @param {Object} target - the object to which the private fields are to be copied\n * @param {Object} source - the object from which the fields are to be copied\n * @return {Object} A reference to the target object.\n * @public\n * @static\n */\n static privatize(target, source) {\n for (let key in source) {\n if (source.hasOwnProperty(key)) {\n target[`_${key}`] = source[key]\n }\n }\n\n return target\n }\n\n /**\n * Sets the specified value on a given field on the object provided.\n *\n * If value is null, the specified default value will be used instead.\n *\n * An optional transformer can be specified which will be used to transform the value (or default value)\n * before it is assigned to the field.\n *\n * @param {Object} object - the object whose field is to be set with value\n * @param {String} fieldName - the field to be set with value\n * @param {*} value - the value to be set on the named field\n * @param {*} [defaultValue] - the value to be used if value is null\n * @param {Function} [transformer] - a function used to transform the value before it is assigned to the named field\n * @return {Boolean} true if the value of the field has changed as a result of the assignment; otherwise\n * false.\n * @public\n * @static\n */\n static setter(object, fieldName, value, defaultValue, transformer) {\n const oldValue = object[fieldName]\n let newValue = value != null ? value : defaultValue\n if (typeof transformer === 'function') {\n newValue = transformer(newValue)\n }\n\n object[fieldName] = newValue\n\n return newValue !== oldValue\n }\n\n /**\n * Throws an error indicating that the a given method on a specific class has not been implemented.\n *\n * @param {String} className - the name of the class on which the method has not been implemented\n * @param {String} methodName - the name of the method which has not been implemented\n * @throws {Error} The error describing the class method which has not been implemented.\n * @public\n * @static\n */\n static throwUnimplemented(className, methodName) {\n throw new Error(`\"${methodName}\" method must be implemented on the ${className} class`)\n }\n\n /**\n * Transforms the specified string to upper case while remaining null-safe.\n *\n * @param {String} string - the string to be transformed to upper case\n * @return {String} string transformed to upper case if string is not null.\n * @public\n * @static\n */\n static toUpperCase(string) {\n return string != null && string.toUpperCase()\n }\n}\n\nexport default Utilities\n","/*\n * QRious\n * Copyright (C) 2016 Alasdair Mercer\n * Copyright (C) 2010 Tom Zerucha\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see .\n */\n\nimport Utilities from '../util/Utilities'\n\n/**\n * Defines a service contract that must be met by all implementations.\n *\n * @public\n */\nclass Service {\n\n /**\n * Returns the name of this {@link Service}.\n *\n * @return {String} The service name.\n * @public\n */\n getName() {\n Utilities.throwUnimplemented('Service', 'getName')\n }\n}\n\nexport default Service\n","/*\n * QRious\n * Copyright (C) 2016 Alasdair Mercer\n * Copyright (C) 2010 Tom Zerucha\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see .\n */\n\nimport Service from '../Service'\nimport Utilities from '../../util/Utilities'\n\n/**\n * A service for working with elements.\n *\n * @public\n * @extends Service\n */\nclass ElementService extends Service {\n\n /**\n * Creates an instance of a canvas element.\n *\n * @return {*} The newly created canvas element.\n * @public\n */\n createCanvas() {\n Utilities.throwUnimplemented('ElementService', 'createCanvas')\n }\n\n /**\n * Creates an instance of a image element.\n *\n * @return {*} The newly created image element.\n * @public\n */\n createImage() {\n Utilities.throwUnimplemented('ElementService', 'createImage')\n }\n\n /**\n * @override\n */\n getName() {\n return 'element'\n }\n\n /**\n * Returns whether the specified element is a canvas.\n *\n * @param {*} element - the element to be checked\n * @return {Boolean} true if element is a canvas; otherwise false.\n * @public\n */\n isCanvas(element) {\n Utilities.throwUnimplemented('ElementService', 'isCanvas')\n }\n\n /**\n * Returns whether the specified element is an image.\n *\n * @param {*} element - the element to be checked\n * @return {Boolean} true if element is an image; otherwise false.\n * @public\n */\n isImage(element) {\n Utilities.throwUnimplemented('ElementService', 'isImage')\n }\n}\n\nexport default ElementService\n","/*\n * QRious\n * Copyright (C) 2016 Alasdair Mercer\n * Copyright (C) 2010 Tom Zerucha\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see .\n */\n\nimport ElementService from './ElementService'\n\n/**\n * An implementation of {@link ElementService} intended for use within a browser environment.\n *\n * @public\n * @extends ElementService\n */\nclass BrowserElementService extends ElementService {\n\n /**\n * @override\n */\n createCanvas() {\n return document.createElement('canvas')\n }\n\n /**\n * @override\n */\n createImage() {\n return document.createElement('img')\n }\n\n /**\n * @override\n */\n isCanvas(element) {\n return element instanceof HTMLCanvasElement\n }\n\n /**\n * @override\n */\n isImage(element) {\n return element instanceof HTMLImageElement\n }\n}\n\nexport default BrowserElementService\n","/*\n * QRious\n * Copyright (C) 2016 Alasdair Mercer\n * Copyright (C) 2010 Tom Zerucha\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see .\n */\n\nimport Utilities from '../util/Utilities'\n\n/**\n * Responsible for rendering a QR code {@link Frame} on a specific type of element.\n *\n * A renderer may be dependant on the rendering of another element, so ordering of their execution is important.\n *\n * @public\n */\nclass Renderer {\n\n /**\n * Creates a new instance of {@link Renderer} for the qrious instance provided.\n *\n * @param {QRious} qrious - the {@link QRious} instance to be used\n * @public\n */\n constructor(qrious) {\n /**\n * The {@link QRious} instance.\n *\n * @protected\n * @type {QRious}\n */\n this.qrious = qrious\n }\n\n /**\n * Draws the specified QR code frame on the underlying element.\n *\n * Implementations of {@link Renderer} must override this method with their own specific logic.\n *\n * @param {Frame} frame - the {@link Frame} to be drawn\n * @protected\n */\n draw(frame) {\n Utilities.throwUnimplemented('Renderer', 'draw')\n }\n\n /**\n * Calculates the size (in pixel units) to represent an individual module within the QR code based on the\n * frame provided.\n *\n * The returned value will be at least one, even in cases where the size of the QR code does not fit its contents.\n * This is done so that the inevitable clipping is handled more gracefully since this way at least something is\n * displayed instead of just a blank space filled by the background color.\n *\n * @param {Frame} frame - the {@link Frame} from which the module size is to be derived\n * @return {Number} The pixel size for each module in the QR code which will be no less than one.\n * @protected\n */\n getModuleSize(frame) {\n const pixels = Math.floor(this.qrious.size / frame.width)\n\n return Math.max(1, pixels)\n }\n\n /**\n * Calculates the offset/padding (in pixel units) to be inserted before the QR code based on the frame\n * provided.\n *\n * The returned value will be zero if there is no available offset or if the size of the QR code does not fit its\n * contents. It will never be a negative value. This is done so that the inevitable clipping appears more naturally\n * and it is not clipped from all directions.\n *\n * @param {Frame} frame - the {@link Frame} from which the offset is to be derived\n * @return {Number} The pixel offset for the QR code which will be no less than zero.\n * @protected\n */\n getOffset(frame) {\n const moduleSize = this.getModuleSize(frame)\n const offset = Math.floor((this.qrious.size - moduleSize * frame.width) / 2)\n\n return Math.max(0, offset)\n }\n\n /**\n * Renders a QR code on the underlying element based on the frame provided.\n *\n * @param {Frame} frame - the {@link Frame} to be rendered\n * @public\n */\n render(frame) {\n this.resize()\n this.reset()\n this.draw(frame)\n }\n\n /**\n * Resets the underlying element, effectively clearing any previously rendered QR code.\n *\n * Implementations of {@link Renderer} must override this method with their own specific logic.\n *\n * @protected\n */\n reset() {\n Utilities.throwUnimplemented('Renderer', 'reset')\n }\n\n /**\n * Ensures that the size of the underlying element matches that defined on the associated {@link QRious} instance.\n *\n * Implementations of {@link Renderer} must override this method with their own specific logic.\n *\n * @protected\n */\n resize() {\n Utilities.throwUnimplemented('Renderer', 'resize')\n }\n}\n\nexport default Renderer\n","/*\n * QRious\n * Copyright (C) 2016 Alasdair Mercer\n * Copyright (C) 2010 Tom Zerucha\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see .\n */\n\nimport Renderer from './Renderer'\n\n/**\n * An implementation of {@link Renderer} for working with canvas elements.\n *\n * @public\n * @extends Renderer\n */\nclass CanvasRenderer extends Renderer {\n\n /**\n * @override\n */\n draw(frame) {\n const qrious = this.qrious\n const moduleSize = this.getModuleSize(frame)\n const offset = this.getOffset(frame)\n const context = qrious.canvas.getContext('2d')\n\n context.fillStyle = qrious.foreground\n\n for (let i = 0; i < frame.width; i++) {\n for (let j = 0; j < frame.width; j++) {\n if (frame.buffer[j * frame.width + i]) {\n context.fillRect(moduleSize * i + offset, moduleSize * j + offset, moduleSize, moduleSize)\n }\n }\n }\n }\n\n /**\n * @override\n */\n reset() {\n const qrious = this.qrious\n const context = qrious.canvas.getContext('2d')\n\n context.lineWidth = 1\n context.clearRect(0, 0, qrious.size, qrious.size)\n context.fillStyle = qrious.background\n context.fillRect(0, 0, qrious.size, qrious.size)\n }\n\n /**\n * @override\n */\n resize() {\n const qrious = this.qrious\n const canvas = qrious.canvas\n\n canvas.width = qrious.size\n canvas.height = qrious.size\n }\n}\n\nexport default CanvasRenderer\n","/*\n * QRious\n * Copyright (C) 2016 Alasdair Mercer\n * Copyright (C) 2010 Tom Zerucha\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see .\n */\n\n/* eslint no-multi-spaces: 0 */\n\n/**\n * Contains alignment pattern information.\n *\n * @public\n */\nclass Alignment {\n\n /**\n * Returns the alignment pattern block.\n *\n * @return {Number[]} The alignment pattern block.\n * @public\n * @static\n */\n static get BLOCK() {\n return [\n 0, 11, 15, 19, 23, 27, 31,\n 16, 18, 20, 22, 24, 26, 28, 20, 22, 24, 24, 26, 28, 28, 22, 24, 24,\n 26, 26, 28, 28, 24, 24, 26, 26, 26, 28, 28, 24, 26, 26, 26, 28, 28\n ]\n }\n}\n\nexport default Alignment\n","/*\n * QRious\n * Copyright (C) 2016 Alasdair Mercer\n * Copyright (C) 2010 Tom Zerucha\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see .\n */\n\n/* eslint no-multi-spaces: 0 */\n\n/**\n * Contains error correction information.\n *\n * @public\n */\nclass ErrorCorrection {\n\n /**\n * Returns the error correction blocks.\n *\n * There are four elements per version. The first two indicate the number of blocks, then the data width, and finally\n * the ECC width.\n *\n * @return {Number[]} The ECC blocks.\n * @public\n * @static\n */\n static get BLOCKS() {\n return [\n 1, 0, 19, 7, 1, 0, 16, 10, 1, 0, 13, 13, 1, 0, 9, 17,\n 1, 0, 34, 10, 1, 0, 28, 16, 1, 0, 22, 22, 1, 0, 16, 28,\n 1, 0, 55, 15, 1, 0, 44, 26, 2, 0, 17, 18, 2, 0, 13, 22,\n 1, 0, 80, 20, 2, 0, 32, 18, 2, 0, 24, 26, 4, 0, 9, 16,\n 1, 0, 108, 26, 2, 0, 43, 24, 2, 2, 15, 18, 2, 2, 11, 22,\n 2, 0, 68, 18, 4, 0, 27, 16, 4, 0, 19, 24, 4, 0, 15, 28,\n 2, 0, 78, 20, 4, 0, 31, 18, 2, 4, 14, 18, 4, 1, 13, 26,\n 2, 0, 97, 24, 2, 2, 38, 22, 4, 2, 18, 22, 4, 2, 14, 26,\n 2, 0, 116, 30, 3, 2, 36, 22, 4, 4, 16, 20, 4, 4, 12, 24,\n 2, 2, 68, 18, 4, 1, 43, 26, 6, 2, 19, 24, 6, 2, 15, 28,\n 4, 0, 81, 20, 1, 4, 50, 30, 4, 4, 22, 28, 3, 8, 12, 24,\n 2, 2, 92, 24, 6, 2, 36, 22, 4, 6, 20, 26, 7, 4, 14, 28,\n 4, 0, 107, 26, 8, 1, 37, 22, 8, 4, 20, 24, 12, 4, 11, 22,\n 3, 1, 115, 30, 4, 5, 40, 24, 11, 5, 16, 20, 11, 5, 12, 24,\n 5, 1, 87, 22, 5, 5, 41, 24, 5, 7, 24, 30, 11, 7, 12, 24,\n 5, 1, 98, 24, 7, 3, 45, 28, 15, 2, 19, 24, 3, 13, 15, 30,\n 1, 5, 107, 28, 10, 1, 46, 28, 1, 15, 22, 28, 2, 17, 14, 28,\n 5, 1, 120, 30, 9, 4, 43, 26, 17, 1, 22, 28, 2, 19, 14, 28,\n 3, 4, 113, 28, 3, 11, 44, 26, 17, 4, 21, 26, 9, 16, 13, 26,\n 3, 5, 107, 28, 3, 13, 41, 26, 15, 5, 24, 30, 15, 10, 15, 28,\n 4, 4, 116, 28, 17, 0, 42, 26, 17, 6, 22, 28, 19, 6, 16, 30,\n 2, 7, 111, 28, 17, 0, 46, 28, 7, 16, 24, 30, 34, 0, 13, 24,\n 4, 5, 121, 30, 4, 14, 47, 28, 11, 14, 24, 30, 16, 14, 15, 30,\n 6, 4, 117, 30, 6, 14, 45, 28, 11, 16, 24, 30, 30, 2, 16, 30,\n 8, 4, 106, 26, 8, 13, 47, 28, 7, 22, 24, 30, 22, 13, 15, 30,\n 10, 2, 114, 28, 19, 4, 46, 28, 28, 6, 22, 28, 33, 4, 16, 30,\n 8, 4, 122, 30, 22, 3, 45, 28, 8, 26, 23, 30, 12, 28, 15, 30,\n 3, 10, 117, 30, 3, 23, 45, 28, 4, 31, 24, 30, 11, 31, 15, 30,\n 7, 7, 116, 30, 21, 7, 45, 28, 1, 37, 23, 30, 19, 26, 15, 30,\n 5, 10, 115, 30, 19, 10, 47, 28, 15, 25, 24, 30, 23, 25, 15, 30,\n 13, 3, 115, 30, 2, 29, 46, 28, 42, 1, 24, 30, 23, 28, 15, 30,\n 17, 0, 115, 30, 10, 23, 46, 28, 10, 35, 24, 30, 19, 35, 15, 30,\n 17, 1, 115, 30, 14, 21, 46, 28, 29, 19, 24, 30, 11, 46, 15, 30,\n 13, 6, 115, 30, 14, 23, 46, 28, 44, 7, 24, 30, 59, 1, 16, 30,\n 12, 7, 121, 30, 12, 26, 47, 28, 39, 14, 24, 30, 22, 41, 15, 30,\n 6, 14, 121, 30, 6, 34, 47, 28, 46, 10, 24, 30, 2, 64, 15, 30,\n 17, 4, 122, 30, 29, 14, 46, 28, 49, 10, 24, 30, 24, 46, 15, 30,\n 4, 18, 122, 30, 13, 32, 46, 28, 48, 14, 24, 30, 42, 32, 15, 30,\n 20, 4, 117, 30, 40, 7, 47, 28, 43, 22, 24, 30, 10, 67, 15, 30,\n 19, 6, 118, 30, 18, 31, 47, 28, 34, 34, 24, 30, 20, 61, 15, 30\n ]\n }\n\n /**\n * Returns the final format bits with mask (level << 3 | mask).\n *\n * @return {Number[]} The final format bits.\n * @public\n * @static\n */\n static get FINAL_FORMAT() {\n return [\n // L\n 0x77c4, 0x72f3, 0x7daa, 0x789d, 0x662f, 0x6318, 0x6c41, 0x6976,\n // M\n 0x5412, 0x5125, 0x5e7c, 0x5b4b, 0x45f9, 0x40ce, 0x4f97, 0x4aa0,\n // Q\n 0x355f, 0x3068, 0x3f31, 0x3a06, 0x24b4, 0x2183, 0x2eda, 0x2bed,\n // H\n 0x1689, 0x13be, 0x1ce7, 0x19d0, 0x0762, 0x0255, 0x0d0c, 0x083b\n ]\n }\n\n /**\n * Returns a map of human-readable ECC levels.\n *\n * @return {Object} A ECC level mapping.\n * @public\n * @static\n */\n static get LEVELS() {\n return {\n L: 1,\n M: 2,\n Q: 3,\n H: 4\n }\n }\n}\n\nexport default ErrorCorrection\n","/*\n * QRious\n * Copyright (C) 2016 Alasdair Mercer\n * Copyright (C) 2010 Tom Zerucha\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see .\n */\n\n/**\n * Contains Galois field information.\n *\n * @public\n */\nclass Galois {\n\n /**\n * Returns the Galois field exponent table.\n *\n * @return {Number[]} The Galois field exponent table.\n * @public\n * @static\n */\n static get EXPONENT() {\n return [\n 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1d, 0x3a, 0x74, 0xe8, 0xcd, 0x87, 0x13, 0x26,\n 0x4c, 0x98, 0x2d, 0x5a, 0xb4, 0x75, 0xea, 0xc9, 0x8f, 0x03, 0x06, 0x0c, 0x18, 0x30, 0x60, 0xc0,\n 0x9d, 0x27, 0x4e, 0x9c, 0x25, 0x4a, 0x94, 0x35, 0x6a, 0xd4, 0xb5, 0x77, 0xee, 0xc1, 0x9f, 0x23,\n 0x46, 0x8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 0xf4, 0xf5, 0xf7, 0xf3, 0xfb, 0xeb, 0xcb, 0x8b, 0x0b, 0x16,\n 0x2c, 0x58, 0xb0, 0x7d, 0xfa, 0xe9, 0xcf, 0x83, 0x1b, 0x36, 0x6c, 0xd8, 0xad, 0x47, 0x8e, 0x00\n ]\n }\n\n /**\n * Returns the Galois field log table.\n *\n * @return {Number[]} The Galois field log table.\n * @public\n * @static\n */\n static get LOG() {\n return [\n 0xff, 0x00, 0x01, 0x19, 0x02, 0x32, 0x1a, 0xc6, 0x03, 0xdf, 0x33, 0xee, 0x1b, 0x68, 0xc7, 0x4b,\n 0x04, 0x64, 0xe0, 0x0e, 0x34, 0x8d, 0xef, 0x81, 0x1c, 0xc1, 0x69, 0xf8, 0xc8, 0x08, 0x4c, 0x71,\n 0x05, 0x8a, 0x65, 0x2f, 0xe1, 0x24, 0x0f, 0x21, 0x35, 0x93, 0x8e, 0xda, 0xf0, 0x12, 0x82, 0x45,\n 0x1d, 0xb5, 0xc2, 0x7d, 0x6a, 0x27, 0xf9, 0xb9, 0xc9, 0x9a, 0x09, 0x78, 0x4d, 0xe4, 0x72, 0xa6,\n 0x06, 0xbf, 0x8b, 0x62, 0x66, 0xdd, 0x30, 0xfd, 0xe2, 0x98, 0x25, 0xb3, 0x10, 0x91, 0x22, 0x88,\n 0x36, 0xd0, 0x94, 0xce, 0x8f, 0x96, 0xdb, 0xbd, 0xf1, 0xd2, 0x13, 0x5c, 0x83, 0x38, 0x46, 0x40,\n 0x1e, 0x42, 0xb6, 0xa3, 0xc3, 0x48, 0x7e, 0x6e, 0x6b, 0x3a, 0x28, 0x54, 0xfa, 0x85, 0xba, 0x3d,\n 0xca, 0x5e, 0x9b, 0x9f, 0x0a, 0x15, 0x79, 0x2b, 0x4e, 0xd4, 0xe5, 0xac, 0x73, 0xf3, 0xa7, 0x57,\n 0x07, 0x70, 0xc0, 0xf7, 0x8c, 0x80, 0x63, 0x0d, 0x67, 0x4a, 0xde, 0xed, 0x31, 0xc5, 0xfe, 0x18,\n 0xe3, 0xa5, 0x99, 0x77, 0x26, 0xb8, 0xb4, 0x7c, 0x11, 0x44, 0x92, 0xd9, 0x23, 0x20, 0x89, 0x2e,\n 0x37, 0x3f, 0xd1, 0x5b, 0x95, 0xbc, 0xcf, 0xcd, 0x90, 0x87, 0x97, 0xb2, 0xdc, 0xfc, 0xbe, 0x61,\n 0xf2, 0x56, 0xd3, 0xab, 0x14, 0x2a, 0x5d, 0x9e, 0x84, 0x3c, 0x39, 0x53, 0x47, 0x6d, 0x41, 0xa2,\n 0x1f, 0x2d, 0x43, 0xd8, 0xb7, 0x7b, 0xa4, 0x76, 0xc4, 0x17, 0x49, 0xec, 0x7f, 0x0c, 0x6f, 0xf6,\n 0x6c, 0xa1, 0x3b, 0x52, 0x29, 0x9d, 0x55, 0xaa, 0xfb, 0x60, 0x86, 0xb1, 0xbb, 0xcc, 0x3e, 0x5a,\n 0xcb, 0x59, 0x5f, 0xb0, 0x9c, 0xa9, 0xa0, 0x51, 0x0b, 0xf5, 0x16, 0xeb, 0x7a, 0x75, 0x2c, 0xd7,\n 0x4f, 0xae, 0xd5, 0xe9, 0xe6, 0xe7, 0xad, 0xe8, 0x74, 0xd6, 0xf4, 0xea, 0xa8, 0x50, 0x58, 0xaf\n ]\n }\n}\n\nexport default Galois\n","/*\n * QRious\n * Copyright (C) 2016 Alasdair Mercer\n * Copyright (C) 2010 Tom Zerucha\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see .\n */\n\n/**\n * Contains version pattern information.\n *\n * @public\n */\nclass Version {\n\n /**\n * Returns the version pattern block.\n *\n * @return {Number[]} The version pattern block.\n * @public\n * @static\n */\n static get BLOCK() {\n return [\n 0xc94, 0x5bc, 0xa99, 0x4d3, 0xbf6, 0x762, 0x847, 0x60d, 0x928, 0xb78, 0x45d, 0xa17, 0x532,\n 0x9a6, 0x683, 0x8c9, 0x7ec, 0xec4, 0x1e1, 0xfab, 0x08e, 0xc1a, 0x33f, 0xd75, 0x250, 0x9d5,\n 0x6f0, 0x8ba, 0x79f, 0xb0b, 0x42e, 0xa64, 0x541, 0xc69\n ]\n }\n}\n\nexport default Version\n","/*\n * QRious\n * Copyright (C) 2016 Alasdair Mercer\n * Copyright (C) 2010 Tom Zerucha\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see .\n */\n\nimport Alignment from './Alignment'\nimport ErrorCorrection from './ErrorCorrection'\nimport Galois from './Galois'\nimport Version from './Version'\n\n/**\n * Generates information for a QR code frame based on a specific value to be encoded.\n *\n * @public\n */\nclass Frame {\n\n static _createArray(length) {\n const array = []\n\n for (let i = 0; i < length; i++) {\n array[i] = 0\n }\n\n return array\n }\n\n static _getMaskBit(x, y) {\n let bit\n\n if (x > y) {\n bit = x\n x = y\n y = bit\n }\n\n bit = y\n bit += y * y\n bit >>= 1\n bit += x\n\n return bit\n }\n\n static _modN(x) {\n while (x >= 255) {\n x -= 255\n x = (x >> 8) + (x & 255)\n }\n\n return x\n }\n\n // *Badness* coefficients.\n static get N1() {\n return 3\n }\n static get N2() {\n return 3\n }\n static get N3() {\n return 40\n }\n static get N4() {\n return 10\n }\n\n /**\n * Creates an instance of {@link Frame} based on the options provided.\n *\n * @param {Frame~Options} options - the options to be used\n * @public\n */\n constructor(options) {\n this._badness = []\n this._level = ErrorCorrection.LEVELS[options.level]\n this._polynomial = []\n this._value = options.value\n this._valueLength = this._value.length\n this._version = 0\n this._stringBuffer = this._value.slice(0)\n\n let dataBlock\n let eccBlock\n let neccBlock1\n let neccBlock2\n\n while (this._version < 40) {\n this._version++\n\n let index = (this._level - 1) * 4 + (this._version - 1) * 16\n\n neccBlock1 = ErrorCorrection.BLOCKS[index++]\n neccBlock2 = ErrorCorrection.BLOCKS[index++]\n dataBlock = ErrorCorrection.BLOCKS[index++]\n eccBlock = ErrorCorrection.BLOCKS[index]\n\n index = dataBlock * (neccBlock1 + neccBlock2) + neccBlock2 - 3 + (this._version <= 9)\n\n if (this._valueLength <= index) {\n break\n }\n }\n\n this._dataBlock = dataBlock\n this._eccBlock = eccBlock\n this._neccBlock1 = neccBlock1\n this._neccBlock2 = neccBlock2\n\n /**\n * The data width is based on version.\n *\n * @public\n * @type {Number}\n */\n // FIXME: Ensure that it fits instead of being truncated.\n this.width = 17 + 4 * this._version\n\n /**\n * The image buffer.\n *\n * @public\n * @type {Number[]}\n */\n this.buffer = Frame._createArray(this.width * this.width)\n\n this._ecc = Frame._createArray(this._dataBlock + (this._dataBlock + this._eccBlock) * (this._neccBlock1 + this._neccBlock2) + this._neccBlock2)\n this._mask = Frame._createArray((this.width * (this.width + 1) + 1) / 2)\n\n this._insertFinders()\n this._insertAlignments()\n\n // Insert single foreground cell.\n this.buffer[8 + this.width * (this.width - 8)] = 1\n\n this._insertTimingGap()\n this._reverseMask()\n this._insertTimingRowAndColumn()\n this._insertVersion()\n this._syncMask()\n this._convertBitStream(this._stringBuffer.length)\n this._calculatePolynomial()\n this._appendEccToData()\n this._interleaveBlocks()\n this._pack()\n this._finish()\n }\n\n _addAlignment(x, y) {\n this.buffer[x + this.width * y] = 1\n\n for (let i = -2; i < 2; i++) {\n this.buffer[x + i + this.width * (y - 2)] = 1\n this.buffer[x - 2 + this.width * (y + i + 1)] = 1\n this.buffer[x + 2 + this.width * (y + i)] = 1\n this.buffer[x + i + 1 + this.width * (y + 2)] = 1\n }\n\n for (let i = 0; i < 2; i++) {\n this._setMask(x - 1, y + i)\n this._setMask(x + 1, y - i)\n this._setMask(x - i, y - 1)\n this._setMask(x + i, y + 1)\n }\n }\n\n _appendData(data, dataLength, ecc, eccLength) {\n for (let i = 0; i < eccLength; i++) {\n this._stringBuffer[ecc + i] = 0\n }\n\n for (let i = 0; i < dataLength; i++) {\n const bit = Galois.LOG[this._stringBuffer[data + i] ^ this._stringBuffer[ecc]]\n\n if (bit !== 255) {\n for (let j = 1; j < eccLength; j++) {\n this._stringBuffer[ecc + j - 1] = this._stringBuffer[ecc + j] ^ Galois.EXPONENT[Frame._modN(bit + this._polynomial[eccLength - j])]\n }\n } else {\n for (let j = ecc; j < ecc + eccLength; j++) {\n this._stringBuffer[j] = this._stringBuffer[j + 1]\n }\n }\n\n this._stringBuffer[ecc + eccLength - 1] = bit === 255 ? 0 : Galois.EXPONENT[Frame._modN(bit + this._polynomial[0])]\n }\n }\n\n _appendEccToData() {\n let data = 0\n let ecc = this._calculateMaxLength()\n\n for (let i = 0; i < this._neccBlock1; i++) {\n this._appendData(data, this._dataBlock, ecc, this._eccBlock)\n\n data += this._dataBlock\n ecc += this._eccBlock\n }\n\n for (let i = 0; i < this._neccBlock2; i++) {\n this._appendData(data, this._dataBlock + 1, ecc, this._eccBlock)\n\n data += this._dataBlock + 1\n ecc += this._eccBlock\n }\n }\n\n _applyMask(mask) {\n const width = this.width\n\n switch (mask) {\n case 0:\n for (let y = 0; y < width; y++) {\n for (let x = 0; x < width; x++) {\n if (!(x + y & 1) && !this._isMasked(x, y)) {\n this.buffer[x + y * width] ^= 1\n }\n }\n }\n\n break\n case 1:\n for (let y = 0; y < width; y++) {\n for (let x = 0; x < width; x++) {\n if (!(y & 1) && !this._isMasked(x, y)) {\n this.buffer[x + y * width] ^= 1\n }\n }\n }\n\n break\n case 2:\n for (let y = 0; y < width; y++) {\n for (let r3x = 0, x = 0; x < width; x++, r3x++) {\n if (r3x === 3) {\n r3x = 0\n }\n\n if (!r3x && !this._isMasked(x, y)) {\n this.buffer[x + y * width] ^= 1\n }\n }\n }\n\n break\n case 3:\n for (let r3y = 0, y = 0; y < width; y++, r3y++) {\n if (r3y === 3) {\n r3y = 0\n }\n\n for (let r3x = r3y, x = 0; x < width; x++, r3x++) {\n if (r3x === 3) {\n r3x = 0\n }\n\n if (!r3x && !this._isMasked(x, y)) {\n this.buffer[x + y * width] ^= 1\n }\n }\n }\n\n break\n case 4:\n for (let y = 0; y < width; y++) {\n for (let r3x = 0, r3y = y >> 1 & 1, x = 0; x < width; x++, r3x++) {\n if (r3x === 3) {\n r3x = 0\n r3y = !r3y\n }\n\n if (!r3y && !this._isMasked(x, y)) {\n this.buffer[x + y * width] ^= 1\n }\n }\n }\n\n break\n case 5:\n for (let r3y = 0, y = 0; y < width; y++, r3y++) {\n if (r3y === 3) {\n r3y = 0\n }\n\n for (let r3x = 0, x = 0; x < width; x++, r3x++) {\n if (r3x === 3) {\n r3x = 0\n }\n\n if (!((x & y & 1) + !(!r3x | !r3y)) && !this._isMasked(x, y)) {\n this.buffer[x + y * width] ^= 1\n }\n }\n }\n\n break\n case 6:\n for (let r3y = 0, y = 0; y < width; y++, r3y++) {\n if (r3y === 3) {\n r3y = 0\n }\n\n for (let r3x = 0, x = 0; x < width; x++, r3x++) {\n if (r3x === 3) {\n r3x = 0\n }\n\n if (!(x & y & 1 + (r3x && r3x === r3y) & 1) && !this._isMasked(x, y)) {\n this.buffer[x + y * width] ^= 1\n }\n }\n }\n\n break\n case 7:\n for (let r3y = 0, y = 0; y < width; y++, r3y++) {\n if (r3y === 3) {\n r3y = 0\n }\n\n for (let r3x = 0, x = 0; x < width; x++, r3x++) {\n if (r3x === 3) {\n r3x = 0\n }\n\n if (!((r3x && r3x === r3y) + (x + y & 1) & 1) && !this._isMasked(x, y)) {\n this.buffer[x + y * width] ^= 1\n }\n }\n }\n\n break\n }\n }\n\n _calculateMaxLength() {\n return this._dataBlock * (this._neccBlock1 + this._neccBlock2) + this._neccBlock2\n }\n\n _calculatePolynomial() {\n this._polynomial[0] = 1\n\n for (let i = 0; i < this._eccBlock; i++) {\n this._polynomial[i + 1] = 1\n\n for (let j = i; j > 0; j--) {\n this._polynomial[j] = this._polynomial[j] ? this._polynomial[j - 1] ^ Galois.EXPONENT[Frame._modN(Galois.LOG[this._polynomial[j]] + i)] : this._polynomial[j - 1]\n }\n\n this._polynomial[0] = Galois.EXPONENT[Frame._modN(Galois.LOG[this._polynomial[0]] + i)]\n }\n\n // Use logs for generator polynomial to save calculation step.\n for (let i = 0; i <= this._eccBlock; i++) {\n this._polynomial[i] = Galois.LOG[this._polynomial[i]]\n }\n }\n\n _checkBadness() {\n let bad = 0\n const width = this.width\n\n // Blocks of same colour.\n for (let y = 0; y < width - 1; y++) {\n for (let x = 0; x < width - 1; x++) {\n // All foreground colour.\n if (this.buffer[x + width * y] &&\n this.buffer[x + 1 + width * y] &&\n this.buffer[x + width * (y + 1)] &&\n this.buffer[x + 1 + width * (y + 1)] ||\n // All background colour.\n !(this.buffer[x + width * y] ||\n this.buffer[x + 1 + width * y] ||\n this.buffer[x + width * (y + 1)] ||\n this.buffer[x + 1 + width * (y + 1)])) {\n bad += Frame.N2\n }\n }\n }\n\n let bw = 0\n\n // X runs.\n for (let y = 0; y < width; y++) {\n let h = 0\n\n this._badness[0] = 0\n\n for (let b = 0, x = 0; x < width; x++) {\n let b1 = this.buffer[x + width * y]\n\n if (b === b1) {\n this._badness[h]++\n } else {\n this._badness[++h] = 1\n }\n\n b = b1\n bw += b ? 1 : -1\n }\n\n bad += this._getBadness(h)\n }\n\n if (bw < 0) {\n bw = -bw\n }\n\n let count = 0\n let big = bw\n big += big << 2\n big <<= 1\n\n while (big > width * width) {\n big -= width * width\n count++\n }\n\n bad += count * Frame.N4\n\n // Y runs.\n for (let x = 0; x < width; x++) {\n let h = 0\n\n this._badness[0] = 0\n\n for (let b = 0, y = 0; y < width; y++) {\n let b1 = this.buffer[x + width * y]\n\n if (b === b1) {\n this._badness[h]++\n } else {\n this._badness[++h] = 1\n }\n\n b = b1\n }\n\n bad += this._getBadness(h)\n }\n\n return bad\n }\n\n _convertBitStream(length) {\n // Convert string to bit stream. 8-bit data to QR-coded 8-bit data (numeric, alphanum, or kanji\n // not supported).\n\n for (let i = 0; i < length; i++) {\n this._ecc[i] = this._stringBuffer.charCodeAt(i)\n }\n\n this._stringBuffer = this._ecc.slice(0)\n\n const maxLength = this._calculateMaxLength()\n\n if (length >= maxLength - 2) {\n length = maxLength - 2\n\n if (this._version > 9) {\n length--\n }\n }\n\n // Shift and re-pack to insert length prefix.\n let index = length\n\n if (this._version > 9) {\n this._stringBuffer[index + 2] = 0\n this._stringBuffer[index + 3] = 0\n\n while (index--) {\n const bit = this._stringBuffer[index]\n\n this._stringBuffer[index + 3] |= 255 & bit << 4\n this._stringBuffer[index + 2] = bit >> 4\n }\n\n this._stringBuffer[2] |= 255 & length << 4\n this._stringBuffer[1] = length >> 4\n this._stringBuffer[0] = 0x40 | length >> 12\n } else {\n this._stringBuffer[index + 1] = 0\n this._stringBuffer[index + 2] = 0\n\n while (index--) {\n const bit = this._stringBuffer[index]\n\n this._stringBuffer[index + 2] |= 255 & bit << 4\n this._stringBuffer[index + 1] = bit >> 4\n }\n\n this._stringBuffer[1] |= 255 & length << 4\n this._stringBuffer[0] = 0x40 | length >> 4\n }\n\n // Fill to end with pad pattern.\n index = length + 3 - (this._version < 10)\n\n while (index < maxLength) {\n this._stringBuffer[index++] = 0xec\n this._stringBuffer[index++] = 0x11\n }\n }\n\n _getBadness(length) {\n let badRuns = 0\n\n for (let i = 0; i <= length; i++) {\n if (this._badness[i] >= 5) {\n badRuns += Frame.N1 + this._badness[i] - 5\n }\n }\n\n // FBFFFBF as in finder.\n for (let i = 3; i < length - 1; i += 2) {\n if (this._badness[i - 2] === this._badness[i + 2] &&\n this._badness[i + 2] === this._badness[i - 1] &&\n this._badness[i - 1] === this._badness[i + 1] &&\n this._badness[i - 1] * 3 === this._badness[i] &&\n // Background around the foreground pattern? Not part of the specs.\n (this._badness[i - 3] === 0 || i + 3 > length ||\n this._badness[i - 3] * 3 >= this._badness[i] * 4 ||\n this._badness[i + 3] * 3 >= this._badness[i] * 4)) {\n badRuns += Frame.N3\n }\n }\n\n return badRuns\n }\n\n _finish() {\n // Save pre-mask copy of frame.\n this._stringBuffer = this.buffer.slice(0)\n\n let bit = 0\n let i\n let mask = 30000\n\n /*\n * Using for instead of while since in original Arduino code if an early mask was \"good enough\" it wouldn't try for\n * a better one since they get more complex and take longer.\n */\n for (i = 0; i < 8; i++) {\n // Returns foreground-background imbalance.\n this._applyMask(i)\n\n const currentMask = this._checkBadness()\n\n // Is current mask better than previous best?\n if (currentMask < mask) {\n mask = currentMask\n bit = i\n }\n\n // Don't increment \"i\" to a void redoing mask.\n if (bit === 7) {\n break\n }\n\n // Reset for next pass.\n this.buffer = this._stringBuffer.slice(0)\n }\n\n // Redo best mask as none were \"good enough\" (i.e. last wasn't bit).\n if (bit !== i) {\n this._applyMask(bit)\n }\n\n // Add in final mask/ECC level bytes.\n mask = ErrorCorrection.FINAL_FORMAT[bit + (this._level - 1 << 3)]\n\n // Low byte.\n for (i = 0; i < 8; i++, mask >>= 1) {\n if (mask & 1) {\n this.buffer[this.width - 1 - i + this.width * 8] = 1\n\n if (i < 6) {\n this.buffer[8 + this.width * i] = 1\n } else {\n this.buffer[8 + this.width * (i + 1)] = 1\n }\n }\n }\n\n // High byte.\n for (i = 0; i < 7; i++, mask >>= 1) {\n if (mask & 1) {\n this.buffer[8 + this.width * (this.width - 7 + i)] = 1\n\n if (i) {\n this.buffer[6 - i + this.width * 8] = 1\n } else {\n this.buffer[7 + this.width * 8] = 1\n }\n }\n }\n }\n\n _interleaveBlocks() {\n const maxLength = this._calculateMaxLength()\n let i\n let k = 0\n\n for (i = 0; i < this._dataBlock; i++) {\n for (let j = 0; j < this._neccBlock1; j++) {\n this._ecc[k++] = this._stringBuffer[i + j * this._dataBlock]\n }\n\n for (let j = 0; j < this._neccBlock2; j++) {\n this._ecc[k++] = this._stringBuffer[this._neccBlock1 * this._dataBlock + i + j * (this._dataBlock + 1)]\n }\n }\n\n for (let j = 0; j < this._neccBlock2; j++) {\n this._ecc[k++] = this._stringBuffer[this._neccBlock1 * this._dataBlock + i + j * (this._dataBlock + 1)]\n }\n\n for (i = 0; i < this._eccBlock; i++) {\n for (let j = 0; j < this._neccBlock1 + this._neccBlock2; j++) {\n this._ecc[k++] = this._stringBuffer[maxLength + i + j * this._eccBlock]\n }\n }\n\n this._stringBuffer = this._ecc\n }\n\n _insertAlignments() {\n const width = this.width\n\n if (this._version > 1) {\n const i = Alignment.BLOCK[this._version]\n let y = width - 7\n\n for (;;) {\n let x = width - 7\n\n while (x > i - 3) {\n this._addAlignment(x, y)\n\n if (x < i) {\n break\n }\n\n x -= i\n }\n\n if (y <= i + 9) {\n break\n }\n\n y -= i\n\n this._addAlignment(6, y)\n this._addAlignment(y, 6)\n }\n }\n }\n\n _insertFinders() {\n const width = this.width\n\n for (let i = 0; i < 3; i++) {\n let j = 0\n let y = 0\n\n if (i === 1) {\n j = width - 7\n }\n if (i === 2) {\n y = width - 7\n }\n\n this.buffer[y + 3 + width * (j + 3)] = 1\n\n for (let x = 0; x < 6; x++) {\n this.buffer[y + x + width * j] = 1\n this.buffer[y + width * (j + x + 1)] = 1\n this.buffer[y + 6 + width * (j + x)] = 1\n this.buffer[y + x + 1 + width * (j + 6)] = 1\n }\n\n for (let x = 1; x < 5; x++) {\n this._setMask(y + x, j + 1)\n this._setMask(y + 1, j + x + 1)\n this._setMask(y + 5, j + x)\n this._setMask(y + x + 1, j + 5)\n }\n\n for (let x = 2; x < 4; x++) {\n this.buffer[y + x + width * (j + 2)] = 1\n this.buffer[y + 2 + width * (j + x + 1)] = 1\n this.buffer[y + 4 + width * (j + x)] = 1\n this.buffer[y + x + 1 + width * (j + 4)] = 1\n }\n }\n }\n\n _insertTimingGap() {\n const width = this.width\n\n for (let y = 0; y < 7; y++) {\n this._setMask(7, y)\n this._setMask(width - 8, y)\n this._setMask(7, y + width - 7)\n }\n\n for (let x = 0; x < 8; x++) {\n this._setMask(x, 7)\n this._setMask(x + width - 8, 7)\n this._setMask(x, width - 8)\n }\n }\n\n _insertTimingRowAndColumn() {\n const width = this.width\n\n for (let x = 0; x < width - 14; x++) {\n if (x & 1) {\n this._setMask(8 + x, 6)\n this._setMask(6, 8 + x)\n } else {\n this.buffer[8 + x + width * 6] = 1\n this.buffer[6 + width * (8 + x)] = 1\n }\n }\n }\n\n _insertVersion() {\n const width = this.width\n\n if (this._version > 6) {\n let i = Version.BLOCK[this._version - 7]\n let j = 17\n\n for (let x = 0; x < 6; x++) {\n for (let y = 0; y < 3; y++, j--) {\n if (1 & (j > 11 ? this._version >> j - 12 : i >> j)) {\n this.buffer[5 - x + width * (2 - y + width - 11)] = 1\n this.buffer[2 - y + width - 11 + width * (5 - x)] = 1\n } else {\n this._setMask(5 - x, 2 - y + width - 11)\n this._setMask(2 - y + width - 11, 5 - x)\n }\n }\n }\n }\n }\n\n _isMasked(x, y) {\n const bit = Frame._getMaskBit(x, y)\n\n return this._mask[bit] === 1\n }\n\n _pack() {\n let x = this.width - 1\n let y = this.width - 1\n let k = 1\n let v = 1\n\n // Interleaved data and ECC codes.\n const length = (this._dataBlock + this._eccBlock) * (this._neccBlock1 + this._neccBlock2) + this._neccBlock2\n\n for (let i = 0; i < length; i++) {\n let bit = this._stringBuffer[i]\n\n for (let j = 0; j < 8; j++, bit <<= 1) {\n if (0x80 & bit) {\n this.buffer[x + this.width * y] = 1\n }\n\n // Find next fill position.\n do {\n if (v) {\n x--\n } else {\n x++\n\n if (k) {\n if (y !== 0) {\n y--\n } else {\n x -= 2\n k = !k\n\n if (x === 6) {\n x--\n y = 9\n }\n }\n } else if (y !== this.width - 1) {\n y++\n } else {\n x -= 2\n k = !k\n\n if (x === 6) {\n x--\n y -= 8\n }\n }\n }\n\n v = !v\n } while (this._isMasked(x, y))\n }\n }\n }\n\n _reverseMask() {\n const width = this.width\n\n for (let x = 0; x < 9; x++) {\n this._setMask(x, 8)\n }\n\n for (let x = 0; x < 8; x++) {\n this._setMask(x + width - 8, 8)\n this._setMask(8, x)\n }\n\n for (let y = 0; y < 7; y++) {\n this._setMask(8, y + width - 7)\n }\n }\n\n _setMask(x, y) {\n const bit = Frame._getMaskBit(x, y)\n\n this._mask[bit] = 1\n }\n\n _syncMask() {\n const width = this.width\n\n for (let y = 0; y < width; y++) {\n for (let x = 0; x <= y; x++) {\n if (this.buffer[x + width * y]) {\n this._setMask(x, y)\n }\n }\n }\n }\n}\n\nexport default Frame\n\n/**\n * The options used by {@link Frame}.\n *\n * @typedef {Object} Frame~Options\n * @property {String} level - The ECC level to be used.\n * @property {String} value - The value to be encoded.\n */\n","/*\n * QRious\n * Copyright (C) 2016 Alasdair Mercer\n * Copyright (C) 2010 Tom Zerucha\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see .\n */\n\nimport Renderer from './Renderer'\n\n/**\n * An implementation of {@link Renderer} for working with img elements.\n *\n * This depends on {@link CanvasRenderer} being executed first as this implementation simply applies the data URL from\n * the rendered canvas element as the src for the img element being rendered.\n *\n * @public\n * @extends Renderer\n */\nclass ImageRenderer extends Renderer {\n\n /**\n * @override\n */\n draw() {\n const qrious = this.qrious\n\n qrious.image.src = qrious.toDataURL()\n }\n\n /**\n * @override\n */\n reset() {\n const qrious = this.qrious\n\n qrious.image.src = ''\n }\n\n /**\n * @override\n */\n resize() {\n const qrious = this.qrious\n const image = qrious.image\n\n image.width = qrious.size\n image.height = qrious.size\n }\n}\n\nexport default ImageRenderer\n","/*\n * QRious\n * Copyright (C) 2016 Alasdair Mercer\n * Copyright (C) 2010 Tom Zerucha\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see .\n */\n\n/**\n * A basic manager for {@link Service} implementations that are mapped to simple names.\n *\n * @public\n */\nclass ServiceManager {\n\n /**\n * Creates a new instance of {@link ServiceManager}.\n *\n * @public\n */\n constructor() {\n this._services = {}\n }\n\n /**\n * Returns the {@link Service} being managed with the specified name.\n *\n * @param {String} name - the name of the {@link Service} to be returned\n * @return {Service} The {@link Service} is being managed with name.\n * @throws {Error} If no {@link Service} is being managed with name.\n * @public\n */\n getService(name) {\n const service = this._services[name]\n if (!service) {\n throw new Error(`Service is not being managed with name: ${name}`)\n }\n\n return service\n }\n\n /**\n * Sets the {@link Service} implementation to be managed for the specified name to the\n * service provided.\n *\n * @param {String} name - the name of the {@link Service} to be managed with name\n * @param {Service} service - the {@link Service} implementation to be managed\n * @throws {Error} If a {@link Service} is already being managed with the same name.\n * @public\n */\n setService(name, service) {\n if (this._services[name]) {\n throw new Error(`Service is already managed with name: ${name}`)\n }\n\n if (service) {\n this._services[name] = service\n }\n }\n}\n\nexport default ServiceManager\n","/*\n * QRious\n * Copyright (C) 2016 Alasdair Mercer\n * Copyright (C) 2010 Tom Zerucha\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see .\n */\n\nimport CanvasRenderer from './renderer/CanvasRenderer'\nimport Frame from './Frame'\nimport ImageRenderer from './renderer/ImageRenderer'\nimport ServiceManager from './service/ServiceManager'\nimport Utilities from './util/Utilities'\n\n/**\n * Enables configuration of a QR code generator which uses HTML5 canvas for rendering.\n *\n * @public\n */\nclass QRious {\n\n /**\n * Returns the default options for {@link QRious}.\n *\n * @return {QRious~Options} The default options.\n * @public\n * @static\n */\n static get DEFAULTS() {\n return {\n background: 'white',\n foreground: 'black',\n level: 'L',\n mime: 'image/png',\n size: 100,\n value: ''\n }\n }\n\n /**\n * Returns the current version of {@link QRious}.\n *\n * @return {String} The current version.\n * @public\n * @static\n */\n static get VERSION() {\n return '2.0.0'\n }\n\n /**\n * Configures the service provided to be used by all {@link QRious} instances.\n *\n * @param {Service} service - the {@link Service} to be configured\n * @throws {Error} If a {@link Service} has already been configured with the same name.\n * @public\n * @static\n */\n static use(service) {\n QRious._serviceManager.setService(service.getName(), service)\n }\n\n static _parseOptions(options) {\n options = Object.assign({}, QRious.DEFAULTS, options)\n options.level = Utilities.toUpperCase(options.level)\n options.size = Math.abs(options.size)\n\n return options\n }\n\n /**\n * Creates a new instance of {@link QRious} based on the options provided.\n *\n * @param {QRious~Options} [options] - the options to be used\n * @public\n */\n constructor(options) {\n options = QRious._parseOptions(options)\n\n Utilities.privatize(this, options)\n\n let element = this._element\n let elementService = QRious._serviceManager.getService('element')\n\n /**\n * The canvas being used to render the QR code for this {@link QRious}.\n *\n * @public\n * @type {*}\n */\n this.canvas = element && elementService.isCanvas(element) ? element : elementService.createCanvas()\n this.canvas.qrious = this\n\n /**\n * The img to contain the rendered QR code for this {@link QRious}.\n *\n * @public\n * @type {*}\n */\n this.image = element && elementService.isImage(element) ? element : elementService.createImage()\n this.image.qrious = this\n\n this._renderers = [\n new CanvasRenderer(this),\n new ImageRenderer(this)\n ]\n\n this.update()\n }\n\n /**\n * Returns the image data URI for the generated QR code using the mime provided.\n *\n * @param {String} [mime] - the MIME type for the image\n * @return {String} The image data URI for the QR code.\n * @public\n */\n toDataURL(mime) {\n return this.canvas.toDataURL(mime || this.mime)\n }\n\n /**\n * Updates this {@link QRious} by generating a new {@link Frame} and re-rendering the QR code.\n *\n * @protected\n */\n update() {\n const frame = new Frame({\n level: this.level,\n value: this.value\n })\n\n this._renderers.forEach((renderer) => renderer.render(frame))\n }\n\n /**\n * Returns the background color for the QR code.\n *\n * @return {String} The background color.\n * @public\n */\n get background() {\n return this._background\n }\n\n /**\n * Sets the background color for the QR code to background.\n *\n * @param {String} [background=\"white\"] - the background color to be set\n * @public\n */\n set background(background) {\n const changed = Utilities.setter(this, '_background', background, QRious.DEFAULTS.background)\n\n if (changed) {\n this.update()\n }\n }\n\n /**\n * Returns the foreground color for the QR code.\n *\n * @return {String} The foreground color.\n * @public\n */\n get foreground() {\n return this._foreground\n }\n\n /**\n * Sets the foreground color for the QR code to foreground.\n *\n * @param {String} [foreground=\"black\"] - the foreground color to be set\n * @public\n */\n set foreground(foreground) {\n const changed = Utilities.setter(this, '_foreground', foreground, QRious.DEFAULTS.foreground)\n\n if (changed) {\n this.update()\n }\n }\n\n /**\n * Returns the error correction level for the QR code.\n *\n * @return {String} The ECC level.\n * @public\n */\n get level() {\n return this._level\n }\n\n /**\n * Sets the error correction level for the QR code to level.\n *\n * level will be transformed to upper case to aid mapping to known ECC level blocks.\n *\n * @param {String} [level=\"L\"] - the ECC level to be set\n * @public\n */\n set level(level) {\n const changed = Utilities.setter(this, '_level', level, QRious.DEFAULTS.level, Utilities.toUpperCase)\n\n if (changed) {\n this.update()\n }\n }\n\n /**\n * Returns the MIME type for the image rendered for the QR code.\n *\n * @return {String} The image MIME type.\n * @public\n */\n get mime() {\n return this._mime\n }\n\n /**\n * Sets the MIME type for the image rendered for the QR code to mime.\n *\n * @param {String} [mime=\"image/png\"] - the image MIME type to be set\n * @public\n */\n set mime(mime) {\n const changed = Utilities.setter(this, '_mime', mime, QRious.DEFAULTS.mime)\n\n if (changed) {\n this.update()\n }\n }\n\n /**\n * Returns the size of the QR code.\n *\n * @return {Number} The size in pixels.\n * @public\n */\n get size() {\n return this._size\n }\n\n /**\n * Sets the size of the QR code to size.\n *\n * size will be transformed to ensure that it is always an absolute positive numbers (e.g.\n * -100 would become 100).\n *\n * @param {Number} [size=100] - the size in pixels to be set\n * @public\n */\n set size(size) {\n const changed = Utilities.setter(this, '_size', size, QRious.DEFAULTS.size, Math.abs)\n\n if (changed) {\n this.update()\n }\n }\n\n /**\n * Returns the value of the QR code.\n *\n * @return {String} The value.\n * @public\n */\n get value() {\n return this._value\n }\n\n /**\n * Sets the value of the QR code to value.\n *\n * @param {String} [value=\"\"] - the value to be set\n * @public\n */\n set value(value) {\n const changed = Utilities.setter(this, '_value', value, QRious.DEFAULTS.value)\n\n if (changed) {\n this.update()\n }\n }\n}\n\nQRious._serviceManager = new ServiceManager()\n\nexport default QRious\n\n/**\n * The options used by {@link QRious}.\n *\n * @typedef {Object} QRious~Options\n * @property {String} [background=\"white\"] - The background color to be applied to the QR code.\n * @property {*} [element] - The element to be used to render the QR code which may either be an canvas or\n * img. The element(s) will be created if needed.\n * @property {String} [foreground=\"black\"] - The foreground color to be applied to the QR code.\n * @property {String} [level=\"L\"] - The error correction level to be applied to the QR code.\n * @property {String} [mime=\"image/png\"] - The MIME type to be used to render the image for the QR code.\n * @property {Number} [size=100] - The size of the QR code in pixels.\n * @property {String} [value=\"\"] - The value to be encoded within the QR code.\n */\n","/*\n * QRious\n * Copyright (C) 2016 Alasdair Mercer\n * Copyright (C) 2010 Tom Zerucha\n *\n * This program is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see .\n */\n\nimport BrowserElementService from '../service/element/BrowserElementService'\nimport QRious from '../QRious'\n\nQRious.use(new BrowserElementService())\n\nexport default QRious\n"],"names":["classCallCheck","instance","Constructor","TypeError","createClass","defineProperties","target","props","i","length","descriptor","enumerable","configurable","writable","Object","defineProperty","key","protoProps","staticProps","prototype","inherits","subClass","superClass","create","constructor","value","setPrototypeOf","__proto__","possibleConstructorReturn","self","call","ReferenceError","Utilities","source","hasOwnProperty","object","fieldName","defaultValue","transformer","oldValue","newValue","className","methodName","Error","string","toUpperCase","Service","throwUnimplemented","ElementService","element","BrowserElementService","document","createElement","HTMLCanvasElement","HTMLImageElement","Renderer","qrious","frame","pixels","Math","floor","this","size","width","max","moduleSize","getModuleSize","offset","resize","reset","draw","CanvasRenderer","getOffset","context","canvas","getContext","fillStyle","foreground","j","buffer","fillRect","lineWidth","clearRect","background","height","Alignment","ErrorCorrection","Galois","Version","Frame","options","_badness","_level","LEVELS","level","_polynomial","_value","_valueLength","_version","_stringBuffer","slice","dataBlock","eccBlock","neccBlock1","neccBlock2","index","BLOCKS","_dataBlock","_eccBlock","_neccBlock1","_neccBlock2","_createArray","_ecc","_mask","_insertFinders","_insertAlignments","_insertTimingGap","_reverseMask","_insertTimingRowAndColumn","_insertVersion","_syncMask","_convertBitStream","_calculatePolynomial","_appendEccToData","_interleaveBlocks","_pack","_finish","array","x","y","bit","_i","_setMask","data","dataLength","ecc","eccLength","_i2","LOG","EXPONENT","_modN","_j","_calculateMaxLength","_appendData","_i3","mask","_isMasked","_y","_x","_y2","r3x","_x2","r3y","_y3","_r3x","_x3","_y4","_r3x2","_r3y","_x4","_r3y2","_y5","_r3x3","_x5","_r3y3","_y6","_r3x4","_x6","_r3y4","_y7","_r3x5","_x7","_i4","bad","N2","bw","_y8","h","b","_x8","b1","_getBadness","count","big","N4","_x9","_h","_b","_y9","_b2","charCodeAt","maxLength","_bit","badRuns","N1","_i5","N3","_applyMask","currentMask","_checkBadness","FINAL_FORMAT","k","_j2","_j3","_j4","BLOCK","_addAlignment","_x10","_x11","_getMaskBit","v","_x12","ImageRenderer","image","src","toDataURL","ServiceManager","_services","name","service","QRious","_parseOptions","privatize","_element","elementService","_serviceManager","getService","isCanvas","createCanvas","isImage","createImage","_renderers","update","setService","getName","assign","DEFAULTS","abs","mime","forEach","renderer","render","_background","changed","setter","_foreground","_mime","_size","use"],"mappings":";;;0LA+EO,IAAIA,GAAiB,SAAUC,EAAUC,GAC9C,KAAMD,YAAoBC,IACxB,KAAM,IAAIC,WAAU,sCAIbC,EAAc,WACvB,QAASC,GAAiBC,EAAQC,GAChC,IAAK,GAAIC,GAAI,EAAGA,EAAID,EAAME,OAAQD,IAAK,CACrC,GAAIE,GAAaH,EAAMC,EACvBE,GAAWC,WAAaD,EAAWC,aAAc,EACjDD,EAAWE,cAAe,EACtB,SAAWF,KAAYA,EAAWG,UAAW,GACjDC,OAAOC,eAAeT,EAAQI,EAAWM,IAAKN,IAIlD,MAAO,UAAUR,EAAae,EAAYC,GAGxC,MAFID,IAAYZ,EAAiBH,EAAYiB,UAAWF,GACpDC,GAAab,EAAiBH,EAAagB,GACxChB,MAoFAkB,EAAW,SAAUC,EAAUC,GACxC,GAA0B,kBAAfA,IAA4C,OAAfA,EACtC,KAAM,IAAInB,WAAU,iEAAoEmB,GAG1FD,GAASF,UAAYL,OAAOS,OAAOD,GAAcA,EAAWH,WAC1DK,aACEC,MAAOJ,EACPV,YAAY,EACZE,UAAU,EACVD,cAAc,KAGdU,IAAYR,OAAOY,eAAiBZ,OAAOY,eAAeL,EAAUC,GAAcD,EAASM,UAAYL,IAwDlGM,EAA4B,SAAUC,EAAMC,GACrD,IAAKD,EACH,KAAM,IAAIE,gBAAe,4DAG3B,QAAOD,GAAyB,gBAATA,IAAqC,kBAATA,GAA8BD,EAAPC,GCzOtEE,qFAYa1B,EAAQ2B,OAClB,GAAIjB,KAAOiB,GACVA,EAAOC,eAAelB,WACbA,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BACA,cACL,SACD,iBACA,UACC,0CAYF,iDAsECoJ,SACDjL,MAAKa,OAAO6I,UAAUuB,GAAQjL,KAAKiL,0CASpCrL,GAAQ,GAAIgC,UACT5B,KAAKiC,YACLjC,KAAKpC,aAGT8M,WAAWQ,QAAQ,SAACC,SAAaA,GAASC,OAAOxL,8CAU/CI,MAAKqL,0BASC/J,MACPgK,GAAUnN,EAAUoN,OAAOvL,KAAM,cAAesB,EAAYyI,EAAOgB,SAASzJ,WAE9EgK,SACGX,kDAWA3K,MAAKwL,0BASCxK,MACPsK,GAAUnN,EAAUoN,OAAOvL,KAAM,cAAegB,EAAY+I,EAAOgB,SAAS/J,WAE9EsK,SACGX,6CAWA3K,MAAK+B,qBAWJE,MACFqJ,GAAUnN,EAAUoN,OAAOvL,KAAM,SAAUiC,EAAO8H,EAAOgB,SAAS9I,MAAO9D,EAAUa,YAErFsM,SACGX,4CAWA3K,MAAKyL,oBASLR,MACDK,GAAUnN,EAAUoN,OAAOvL,KAAM,QAASiL,EAAMlB,EAAOgB,SAASE,KAElEK,SACGX,4CAWA3K,MAAK0L,oBAYLzL,MACDqL,GAAUnN,EAAUoN,OAAOvL,KAAM,QAASC,EAAM8J,EAAOgB,SAAS9K,KAAMH,KAAKkL,IAE7EM,SACGX,6CAWA3K,MAAKmC,qBASJvE,MACF0N,GAAUnN,EAAUoN,OAAOvL,KAAM,SAAUpC,EAAOmM,EAAOgB,SAASnN,MAEpE0N,SACGX,wBAKXZ,GAAOK,gBAAkB,GAAIT,GClR7BI,EAAO4B,IAAI,GAAItM"} \ No newline at end of file diff --git a/docs/docco.css b/docs/docco.css deleted file mode 100644 index b60f6fa..0000000 --- a/docs/docco.css +++ /dev/null @@ -1,518 +0,0 @@ -/*--------------------- Typography ----------------------------*/ - -@font-face { - font-family: 'aller-light'; - src: url('public/fonts/aller-light.eot'); - src: url('public/fonts/aller-light.eot?#iefix') format('embedded-opentype'), - url('public/fonts/aller-light.woff') format('woff'), - url('public/fonts/aller-light.ttf') format('truetype'); - font-weight: normal; - font-style: normal; -} - -@font-face { - font-family: 'aller-bold'; - src: url('public/fonts/aller-bold.eot'); - src: url('public/fonts/aller-bold.eot?#iefix') format('embedded-opentype'), - url('public/fonts/aller-bold.woff') format('woff'), - url('public/fonts/aller-bold.ttf') format('truetype'); - font-weight: normal; - font-style: normal; -} - -@font-face { - font-family: 'roboto-black'; - src: url('public/fonts/roboto-black.eot'); - src: url('public/fonts/roboto-black.eot?#iefix') format('embedded-opentype'), - url('public/fonts/roboto-black.woff') format('woff'), - url('public/fonts/roboto-black.ttf') format('truetype'); - font-weight: normal; - font-style: normal; -} - -/*--------------------- Layout ----------------------------*/ -html { height: 100%; } -body { - font-family: "aller-light"; - font-size: 14px; - line-height: 18px; - color: #30404f; - margin: 0; padding: 0; - height:100%; -} -#container { min-height: 100%; } - -a { - color: #000; -} - -b, strong { - font-weight: normal; - font-family: "aller-bold"; -} - -p { - margin: 15px 0 0px; -} - .annotation ul, .annotation ol { - margin: 25px 0; - } - .annotation ul li, .annotation ol li { - font-size: 14px; - line-height: 18px; - margin: 10px 0; - } - -h1, h2, h3, h4, h5, h6 { - color: #112233; - line-height: 1em; - font-weight: normal; - font-family: "roboto-black"; - text-transform: uppercase; - margin: 30px 0 15px 0; -} - -h1 { - margin-top: 40px; -} -h2 { - font-size: 1.26em; -} - -hr { - border: 0; - background: 1px #ddd; - height: 1px; - margin: 20px 0; -} - -pre, tt, code { - font-size: 12px; line-height: 16px; - font-family: Menlo, Monaco, Consolas, "Lucida Console", monospace; - margin: 0; padding: 0; -} - .annotation pre { - display: block; - margin: 0; - padding: 7px 10px; - background: #fcfcfc; - -moz-box-shadow: inset 0 0 10px rgba(0,0,0,0.1); - -webkit-box-shadow: inset 0 0 10px rgba(0,0,0,0.1); - box-shadow: inset 0 0 10px rgba(0,0,0,0.1); - overflow-x: auto; - } - .annotation pre code { - border: 0; - padding: 0; - background: transparent; - } - - -blockquote { - border-left: 5px solid #ccc; - margin: 0; - padding: 1px 0 1px 1em; -} - .sections blockquote p { - font-family: Menlo, Consolas, Monaco, monospace; - font-size: 12px; line-height: 16px; - color: #999; - margin: 10px 0 0; - white-space: pre-wrap; - } - -ul.sections { - list-style: none; - padding:0 0 5px 0;; - margin:0; -} - -/* - Force border-box so that % widths fit the parent - container without overlap because of margin/padding. - - More Info : http://www.quirksmode.org/css/box.html -*/ -ul.sections > li > div { - -moz-box-sizing: border-box; /* firefox */ - -ms-box-sizing: border-box; /* ie */ - -webkit-box-sizing: border-box; /* webkit */ - -khtml-box-sizing: border-box; /* konqueror */ - box-sizing: border-box; /* css3 */ -} - - -/*---------------------- Jump Page -----------------------------*/ -#jump_to, #jump_page { - margin: 0; - background: white; - -webkit-box-shadow: 0 0 25px #777; -moz-box-shadow: 0 0 25px #777; - -webkit-border-bottom-left-radius: 5px; -moz-border-radius-bottomleft: 5px; - font: 16px Arial; - cursor: pointer; - text-align: right; - list-style: none; -} - -#jump_to a { - text-decoration: none; -} - -#jump_to a.large { - display: none; -} -#jump_to a.small { - font-size: 22px; - font-weight: bold; - color: #676767; -} - -#jump_to, #jump_wrapper { - position: fixed; - right: 0; top: 0; - padding: 10px 15px; - margin:0; -} - -#jump_wrapper { - display: none; - padding:0; -} - -#jump_to:hover #jump_wrapper { - display: block; -} - -#jump_page_wrapper{ - position: fixed; - right: 0; - top: 0; - bottom: 0; -} - -#jump_page { - padding: 5px 0 3px; - margin: 0 0 25px 25px; - max-height: 100%; - overflow: auto; -} - -#jump_page .source { - display: block; - padding: 15px; - text-decoration: none; - border-top: 1px solid #eee; -} - -#jump_page .source:hover { - background: #f5f5ff; -} - -#jump_page .source:first-child { -} - -/*---------------------- Low resolutions (> 320px) ---------------------*/ -@media only screen and (min-width: 320px) { - .pilwrap { display: none; } - - ul.sections > li > div { - display: block; - padding:5px 10px 0 10px; - } - - ul.sections > li > div.annotation ul, ul.sections > li > div.annotation ol { - padding-left: 30px; - } - - ul.sections > li > div.content { - overflow-x:auto; - -webkit-box-shadow: inset 0 0 5px #e5e5ee; - box-shadow: inset 0 0 5px #e5e5ee; - border: 1px solid #dedede; - margin:5px 10px 5px 10px; - padding-bottom: 5px; - } - - ul.sections > li > div.annotation pre { - margin: 7px 0 7px; - padding-left: 15px; - } - - ul.sections > li > div.annotation p tt, .annotation code { - background: #f8f8ff; - border: 1px solid #dedede; - font-size: 12px; - padding: 0 0.2em; - } -} - -/*---------------------- (> 481px) ---------------------*/ -@media only screen and (min-width: 481px) { - #container { - position: relative; - } - body { - background-color: #F5F5FF; - font-size: 15px; - line-height: 21px; - } - pre, tt, code { - line-height: 18px; - } - p, ul, ol { - margin: 0 0 15px; - } - - - #jump_to { - padding: 5px 10px; - } - #jump_wrapper { - padding: 0; - } - #jump_to, #jump_page { - font: 10px Arial; - text-transform: uppercase; - } - #jump_page .source { - padding: 5px 10px; - } - #jump_to a.large { - display: inline-block; - } - #jump_to a.small { - display: none; - } - - - - #background { - position: absolute; - top: 0; bottom: 0; - width: 350px; - background: #fff; - border-right: 1px solid #e5e5ee; - z-index: -1; - } - - ul.sections > li > div.annotation ul, ul.sections > li > div.annotation ol { - padding-left: 40px; - } - - ul.sections > li { - white-space: nowrap; - } - - ul.sections > li > div { - display: inline-block; - } - - ul.sections > li > div.annotation { - max-width: 350px; - min-width: 350px; - min-height: 5px; - padding: 13px; - overflow-x: hidden; - white-space: normal; - vertical-align: top; - text-align: left; - } - ul.sections > li > div.annotation pre { - margin: 15px 0 15px; - padding-left: 15px; - } - - ul.sections > li > div.content { - padding: 13px; - vertical-align: top; - border: none; - -webkit-box-shadow: none; - box-shadow: none; - } - - .pilwrap { - position: relative; - display: inline; - } - - .pilcrow { - font: 12px Arial; - text-decoration: none; - color: #454545; - position: absolute; - top: 3px; left: -20px; - padding: 1px 2px; - opacity: 0; - -webkit-transition: opacity 0.2s linear; - } - .for-h1 .pilcrow { - top: 47px; - } - .for-h2 .pilcrow, .for-h3 .pilcrow, .for-h4 .pilcrow { - top: 35px; - } - - ul.sections > li > div.annotation:hover .pilcrow { - opacity: 1; - } -} - -/*---------------------- (> 1025px) ---------------------*/ -@media only screen and (min-width: 1025px) { - - body { - font-size: 16px; - line-height: 24px; - } - - #background { - width: 525px; - } - ul.sections > li > div.annotation { - max-width: 525px; - min-width: 525px; - padding: 10px 25px 1px 50px; - } - ul.sections > li > div.content { - padding: 9px 15px 16px 25px; - } -} - -/*---------------------- Syntax Highlighting -----------------------------*/ - -td.linenos { background-color: #f0f0f0; padding-right: 10px; } -span.lineno { background-color: #f0f0f0; padding: 0 5px 0 5px; } -/* - -github.com style (c) Vasily Polovnyov - -*/ - -pre code { - display: block; padding: 0.5em; - color: #000; - background: #f8f8ff -} - -pre .hljs-comment, -pre .hljs-template_comment, -pre .hljs-diff .hljs-header, -pre .hljs-javadoc { - color: #408080; - font-style: italic -} - -pre .hljs-keyword, -pre .hljs-assignment, -pre .hljs-literal, -pre .hljs-css .hljs-rule .hljs-keyword, -pre .hljs-winutils, -pre .hljs-javascript .hljs-title, -pre .hljs-lisp .hljs-title, -pre .hljs-subst { - color: #954121; - /*font-weight: bold*/ -} - -pre .hljs-number, -pre .hljs-hexcolor { - color: #40a070 -} - -pre .hljs-string, -pre .hljs-tag .hljs-value, -pre .hljs-phpdoc, -pre .hljs-tex .hljs-formula { - color: #219161; -} - -pre .hljs-title, -pre .hljs-id { - color: #19469D; -} -pre .hljs-params { - color: #00F; -} - -pre .hljs-javascript .hljs-title, -pre .hljs-lisp .hljs-title, -pre .hljs-subst { - font-weight: normal -} - -pre .hljs-class .hljs-title, -pre .hljs-haskell .hljs-label, -pre .hljs-tex .hljs-command { - color: #458; - font-weight: bold -} - -pre .hljs-tag, -pre .hljs-tag .hljs-title, -pre .hljs-rules .hljs-property, -pre .hljs-django .hljs-tag .hljs-keyword { - color: #000080; - font-weight: normal -} - -pre .hljs-attribute, -pre .hljs-variable, -pre .hljs-instancevar, -pre .hljs-lisp .hljs-body { - color: #008080 -} - -pre .hljs-regexp { - color: #B68 -} - -pre .hljs-class { - color: #458; - font-weight: bold -} - -pre .hljs-symbol, -pre .hljs-ruby .hljs-symbol .hljs-string, -pre .hljs-ruby .hljs-symbol .hljs-keyword, -pre .hljs-ruby .hljs-symbol .hljs-keymethods, -pre .hljs-lisp .hljs-keyword, -pre .hljs-tex .hljs-special, -pre .hljs-input_number { - color: #990073 -} - -pre .hljs-builtin, -pre .hljs-constructor, -pre .hljs-built_in, -pre .hljs-lisp .hljs-title { - color: #0086b3 -} - -pre .hljs-preprocessor, -pre .hljs-pi, -pre .hljs-doctype, -pre .hljs-shebang, -pre .hljs-cdata { - color: #999; - font-weight: bold -} - -pre .hljs-deletion { - background: #fdd -} - -pre .hljs-addition { - background: #dfd -} - -pre .hljs-diff .hljs-change { - background: #0086b3 -} - -pre .hljs-chunk { - color: #aaa -} - -pre .hljs-tex .hljs-formula { - opacity: 0.5; -} diff --git a/docs/public/fonts/aller-bold.eot b/docs/public/fonts/aller-bold.eot deleted file mode 100644 index 1b32532..0000000 Binary files a/docs/public/fonts/aller-bold.eot and /dev/null differ diff --git a/docs/public/fonts/aller-bold.ttf b/docs/public/fonts/aller-bold.ttf deleted file mode 100644 index dc4cc9c..0000000 Binary files a/docs/public/fonts/aller-bold.ttf and /dev/null differ diff --git a/docs/public/fonts/aller-bold.woff b/docs/public/fonts/aller-bold.woff deleted file mode 100644 index fa16fd0..0000000 Binary files a/docs/public/fonts/aller-bold.woff and /dev/null differ diff --git a/docs/public/fonts/aller-light.eot b/docs/public/fonts/aller-light.eot deleted file mode 100644 index 40bd654..0000000 Binary files a/docs/public/fonts/aller-light.eot and /dev/null differ diff --git a/docs/public/fonts/aller-light.ttf b/docs/public/fonts/aller-light.ttf deleted file mode 100644 index c2c7290..0000000 Binary files a/docs/public/fonts/aller-light.ttf and /dev/null differ diff --git a/docs/public/fonts/aller-light.woff b/docs/public/fonts/aller-light.woff deleted file mode 100644 index 81a09d1..0000000 Binary files a/docs/public/fonts/aller-light.woff and /dev/null differ diff --git a/docs/public/fonts/roboto-black.eot b/docs/public/fonts/roboto-black.eot deleted file mode 100755 index 571ed49..0000000 Binary files a/docs/public/fonts/roboto-black.eot and /dev/null differ diff --git a/docs/public/fonts/roboto-black.ttf b/docs/public/fonts/roboto-black.ttf deleted file mode 100755 index e0300b3..0000000 Binary files a/docs/public/fonts/roboto-black.ttf and /dev/null differ diff --git a/docs/public/fonts/roboto-black.woff b/docs/public/fonts/roboto-black.woff deleted file mode 100755 index 642e5b6..0000000 Binary files a/docs/public/fonts/roboto-black.woff and /dev/null differ diff --git a/docs/public/stylesheets/normalize.css b/docs/public/stylesheets/normalize.css deleted file mode 100644 index 73abb76..0000000 --- a/docs/public/stylesheets/normalize.css +++ /dev/null @@ -1,375 +0,0 @@ -/*! normalize.css v2.0.1 | MIT License | git.io/normalize */ - -/* ========================================================================== - HTML5 display definitions - ========================================================================== */ - -/* - * Corrects `block` display not defined in IE 8/9. - */ - -article, -aside, -details, -figcaption, -figure, -footer, -header, -hgroup, -nav, -section, -summary { - display: block; -} - -/* - * Corrects `inline-block` display not defined in IE 8/9. - */ - -audio, -canvas, -video { - display: inline-block; -} - -/* - * Prevents modern browsers from displaying `audio` without controls. - * Remove excess height in iOS 5 devices. - */ - -audio:not([controls]) { - display: none; - height: 0; -} - -/* - * Addresses styling for `hidden` attribute not present in IE 8/9. - */ - -[hidden] { - display: none; -} - -/* ========================================================================== - Base - ========================================================================== */ - -/* - * 1. Sets default font family to sans-serif. - * 2. Prevents iOS text size adjust after orientation change, without disabling - * user zoom. - */ - -html { - font-family: sans-serif; /* 1 */ - -webkit-text-size-adjust: 100%; /* 2 */ - -ms-text-size-adjust: 100%; /* 2 */ -} - -/* - * Removes default margin. - */ - -body { - margin: 0; -} - -/* ========================================================================== - Links - ========================================================================== */ - -/* - * Addresses `outline` inconsistency between Chrome and other browsers. - */ - -a:focus { - outline: thin dotted; -} - -/* - * Improves readability when focused and also mouse hovered in all browsers. - */ - -a:active, -a:hover { - outline: 0; -} - -/* ========================================================================== - Typography - ========================================================================== */ - -/* - * Addresses `h1` font sizes within `section` and `article` in Firefox 4+, - * Safari 5, and Chrome. - */ - -h1 { - font-size: 2em; -} - -/* - * Addresses styling not present in IE 8/9, Safari 5, and Chrome. - */ - -abbr[title] { - border-bottom: 1px dotted; -} - -/* - * Addresses style set to `bolder` in Firefox 4+, Safari 5, and Chrome. - */ - -b, -strong { - font-weight: bold; -} - -/* - * Addresses styling not present in Safari 5 and Chrome. - */ - -dfn { - font-style: italic; -} - -/* - * Addresses styling not present in IE 8/9. - */ - -mark { - background: #ff0; - color: #000; -} - - -/* - * Corrects font family set oddly in Safari 5 and Chrome. - */ - -code, -kbd, -pre, -samp { - font-family: monospace, serif; - font-size: 1em; -} - -/* - * Improves readability of pre-formatted text in all browsers. - */ - -pre { - white-space: pre; - white-space: pre-wrap; - word-wrap: break-word; -} - -/* - * Sets consistent quote types. - */ - -q { - quotes: "\201C" "\201D" "\2018" "\2019"; -} - -/* - * Addresses inconsistent and variable font size in all browsers. - */ - -small { - font-size: 80%; -} - -/* - * Prevents `sub` and `sup` affecting `line-height` in all browsers. - */ - -sub, -sup { - font-size: 75%; - line-height: 0; - position: relative; - vertical-align: baseline; -} - -sup { - top: -0.5em; -} - -sub { - bottom: -0.25em; -} - -/* ========================================================================== - Embedded content - ========================================================================== */ - -/* - * Removes border when inside `a` element in IE 8/9. - */ - -img { - border: 0; -} - -/* - * Corrects overflow displayed oddly in IE 9. - */ - -svg:not(:root) { - overflow: hidden; -} - -/* ========================================================================== - Figures - ========================================================================== */ - -/* - * Addresses margin not present in IE 8/9 and Safari 5. - */ - -figure { - margin: 0; -} - -/* ========================================================================== - Forms - ========================================================================== */ - -/* - * Define consistent border, margin, and padding. - */ - -fieldset { - border: 1px solid #c0c0c0; - margin: 0 2px; - padding: 0.35em 0.625em 0.75em; -} - -/* - * 1. Corrects color not being inherited in IE 8/9. - * 2. Remove padding so people aren't caught out if they zero out fieldsets. - */ - -legend { - border: 0; /* 1 */ - padding: 0; /* 2 */ -} - -/* - * 1. Corrects font family not being inherited in all browsers. - * 2. Corrects font size not being inherited in all browsers. - * 3. Addresses margins set differently in Firefox 4+, Safari 5, and Chrome - */ - -button, -input, -select, -textarea { - font-family: inherit; /* 1 */ - font-size: 100%; /* 2 */ - margin: 0; /* 3 */ -} - -/* - * Addresses Firefox 4+ setting `line-height` on `input` using `!important` in - * the UA stylesheet. - */ - -button, -input { - line-height: normal; -} - -/* - * 1. Avoid the WebKit bug in Android 4.0.* where (2) destroys native `audio` - * and `video` controls. - * 2. Corrects inability to style clickable `input` types in iOS. - * 3. Improves usability and consistency of cursor style between image-type - * `input` and others. - */ - -button, -html input[type="button"], /* 1 */ -input[type="reset"], -input[type="submit"] { - -webkit-appearance: button; /* 2 */ - cursor: pointer; /* 3 */ -} - -/* - * Re-set default cursor for disabled elements. - */ - -button[disabled], -input[disabled] { - cursor: default; -} - -/* - * 1. Addresses box sizing set to `content-box` in IE 8/9. - * 2. Removes excess padding in IE 8/9. - */ - -input[type="checkbox"], -input[type="radio"] { - box-sizing: border-box; /* 1 */ - padding: 0; /* 2 */ -} - -/* - * 1. Addresses `appearance` set to `searchfield` in Safari 5 and Chrome. - * 2. Addresses `box-sizing` set to `border-box` in Safari 5 and Chrome - * (include `-moz` to future-proof). - */ - -input[type="search"] { - -webkit-appearance: textfield; /* 1 */ - -moz-box-sizing: content-box; - -webkit-box-sizing: content-box; /* 2 */ - box-sizing: content-box; -} - -/* - * Removes inner padding and search cancel button in Safari 5 and Chrome - * on OS X. - */ - -input[type="search"]::-webkit-search-cancel-button, -input[type="search"]::-webkit-search-decoration { - -webkit-appearance: none; -} - -/* - * Removes inner padding and border in Firefox 4+. - */ - -button::-moz-focus-inner, -input::-moz-focus-inner { - border: 0; - padding: 0; -} - -/* - * 1. Removes default vertical scrollbar in IE 8/9. - * 2. Improves readability and alignment in all browsers. - */ - -textarea { - overflow: auto; /* 1 */ - vertical-align: top; /* 2 */ -} - -/* ========================================================================== - Tables - ========================================================================== */ - -/* - * Remove most spacing between table cells. - */ - -table { - border-collapse: collapse; - border-spacing: 0; -} \ No newline at end of file diff --git a/docs/qr.html b/docs/qr.html deleted file mode 100644 index 7a3193c..0000000 --- a/docs/qr.html +++ /dev/null @@ -1,2826 +0,0 @@ - - - - - qr.js - - - - - -
-
- -
    - -
  • -
    -

    qr.js

    -
    -
  • - - - -
  • -
    - -
    - -
    -

    qr.js
    (c) 2015 Alasdair Mercer
    Licensed under the GPL Version 3 license.
    Based on jsqrencode
    (c) 2010 tz@execpc.com
    Licensed under the GPL Version 3 license.
    For all details and documentation:
    http://neocotic.com/qr.js

    - -
    - -
    -(function (root) {
    -
    -  'use strict';
    - -
  • - - -
  • -
    - -
    - -
    -

    Private constants

    - -
    - -
  • - - -
  • -
    - -
    - -
    - -
    - -
  • - - -
  • -
    - -
    - -
    -

    Alignment pattern.

    - -
    - -
      var ALIGNMENT_DELTA = [
    -    0,  11, 15, 19, 23, 27, 31,
    -    16, 18, 20, 22, 24, 26, 28, 20, 22, 24, 24, 26, 28, 28, 22, 24, 24,
    -    26, 26, 28, 28, 24, 24, 26, 26, 26, 28, 28, 24, 26, 26, 26, 28, 28
    -  ];
    - -
  • - - -
  • -
    - -
    - -
    -

    Default MIME type.

    - -
    - -
      var DEFAULT_MIME = 'image/png';
    - -
  • - - -
  • -
    - -
    - -
    -

    MIME used to initiate a browser download prompt when qr.save is called.

    - -
    - -
      var DOWNLOAD_MIME = 'image/octet-stream';
    - -
  • - - -
  • -
    - -
    - -
    -

    There are four elements per version. The first two indicate the number of blocks, then the -data width, and finally the ECC width.

    - -
    - -
      var ECC_BLOCKS = [
    -    1,  0,  19,  7,     1,  0,  16,  10,    1,  0,  13,  13,    1,  0,  9,   17,
    -    1,  0,  34,  10,    1,  0,  28,  16,    1,  0,  22,  22,    1,  0,  16,  28,
    -    1,  0,  55,  15,    1,  0,  44,  26,    2,  0,  17,  18,    2,  0,  13,  22,
    -    1,  0,  80,  20,    2,  0,  32,  18,    2,  0,  24,  26,    4,  0,  9,   16,
    -    1,  0,  108, 26,    2,  0,  43,  24,    2,  2,  15,  18,    2,  2,  11,  22,
    -    2,  0,  68,  18,    4,  0,  27,  16,    4,  0,  19,  24,    4,  0,  15,  28,
    -    2,  0,  78,  20,    4,  0,  31,  18,    2,  4,  14,  18,    4,  1,  13,  26,
    -    2,  0,  97,  24,    2,  2,  38,  22,    4,  2,  18,  22,    4,  2,  14,  26,
    -    2,  0,  116, 30,    3,  2,  36,  22,    4,  4,  16,  20,    4,  4,  12,  24,
    -    2,  2,  68,  18,    4,  1,  43,  26,    6,  2,  19,  24,    6,  2,  15,  28,
    -    4,  0,  81,  20,    1,  4,  50,  30,    4,  4,  22,  28,    3,  8,  12,  24,
    -    2,  2,  92,  24,    6,  2,  36,  22,    4,  6,  20,  26,    7,  4,  14,  28,
    -    4,  0,  107, 26,    8,  1,  37,  22,    8,  4,  20,  24,    12, 4,  11,  22,
    -    3,  1,  115, 30,    4,  5,  40,  24,    11, 5,  16,  20,    11, 5,  12,  24,
    -    5,  1,  87,  22,    5,  5,  41,  24,    5,  7,  24,  30,    11, 7,  12,  24,
    -    5,  1,  98,  24,    7,  3,  45,  28,    15, 2,  19,  24,    3,  13, 15,  30,
    -    1,  5,  107, 28,    10, 1,  46,  28,    1,  15, 22,  28,    2,  17, 14,  28,
    -    5,  1,  120, 30,    9,  4,  43,  26,    17, 1,  22,  28,    2,  19, 14,  28,
    -    3,  4,  113, 28,    3,  11, 44,  26,    17, 4,  21,  26,    9,  16, 13,  26,
    -    3,  5,  107, 28,    3,  13, 41,  26,    15, 5,  24,  30,    15, 10, 15,  28,
    -    4,  4,  116, 28,    17, 0,  42,  26,    17, 6,  22,  28,    19, 6,  16,  30,
    -    2,  7,  111, 28,    17, 0,  46,  28,    7,  16, 24,  30,    34, 0,  13,  24,
    -    4,  5,  121, 30,    4,  14, 47,  28,    11, 14, 24,  30,    16, 14, 15,  30,
    -    6,  4,  117, 30,    6,  14, 45,  28,    11, 16, 24,  30,    30, 2,  16,  30,
    -    8,  4,  106, 26,    8,  13, 47,  28,    7,  22, 24,  30,    22, 13, 15,  30,
    -    10, 2,  114, 28,    19, 4,  46,  28,    28, 6,  22,  28,    33, 4,  16,  30,
    -    8,  4,  122, 30,    22, 3,  45,  28,    8,  26, 23,  30,    12, 28, 15,  30,
    -    3,  10, 117, 30,    3,  23, 45,  28,    4,  31, 24,  30,    11, 31, 15,  30,
    -    7,  7,  116, 30,    21, 7,  45,  28,    1,  37, 23,  30,    19, 26, 15,  30,
    -    5,  10, 115, 30,    19, 10, 47,  28,    15, 25, 24,  30,    23, 25, 15,  30,
    -    13, 3,  115, 30,    2,  29, 46,  28,    42, 1,  24,  30,    23, 28, 15,  30,
    -    17, 0,  115, 30,    10, 23, 46,  28,    10, 35, 24,  30,    19, 35, 15,  30,
    -    17, 1,  115, 30,    14, 21, 46,  28,    29, 19, 24,  30,    11, 46, 15,  30,
    -    13, 6,  115, 30,    14, 23, 46,  28,    44, 7,  24,  30,    59, 1,  16,  30,
    -    12, 7,  121, 30,    12, 26, 47,  28,    39, 14, 24,  30,    22, 41, 15,  30,
    -    6,  14, 121, 30,    6,  34, 47,  28,    46, 10, 24,  30,    2,  64, 15,  30,
    -    17, 4,  122, 30,    29, 14, 46,  28,    49, 10, 24,  30,    24, 46, 15,  30,
    -    4,  18, 122, 30,    13, 32, 46,  28,    48, 14, 24,  30,    42, 32, 15,  30,
    -    20, 4,  117, 30,    40, 7,  47,  28,    43, 22, 24,  30,    10, 67, 15,  30,
    -    19, 6,  118, 30,    18, 31, 47,  28,    34, 34, 24,  30,    20, 61, 15,  30
    -  ];
    - -
  • - - -
  • -
    - -
    - -
    -

    Map of human-readable ECC levels.

    - -
    - -
      var ECC_LEVELS = {
    -    L: 1,
    -    M: 2,
    -    Q: 3,
    -    H: 4
    -  };
    - -
  • - - -
  • -
    - -
    - -
    -

    Final format bits with mask (level << 3 | mask).

    - -
    - -
      var FINAL_FORMAT = [
    -    0x77c4, 0x72f3, 0x7daa, 0x789d, 0x662f, 0x6318, 0x6c41, 0x6976, /* L */
    -    0x5412, 0x5125, 0x5e7c, 0x5b4b, 0x45f9, 0x40ce, 0x4f97, 0x4aa0, /* M */
    -    0x355f, 0x3068, 0x3f31, 0x3a06, 0x24b4, 0x2183, 0x2eda, 0x2bed, /* Q */
    -    0x1689, 0x13be, 0x1ce7, 0x19d0, 0x0762, 0x0255, 0x0d0c, 0x083b  /* H */
    -  ];
    - -
  • - - -
  • -
    - -
    - -
    -

    Galois field exponent table.

    - -
    - -
      var GALOIS_EXPONENT = [
    -    0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1d, 0x3a, 0x74, 0xe8, 0xcd, 0x87, 0x13, 0x26,
    -    0x4c, 0x98, 0x2d, 0x5a, 0xb4, 0x75, 0xea, 0xc9, 0x8f, 0x03, 0x06, 0x0c, 0x18, 0x30, 0x60, 0xc0,
    -    0x9d, 0x27, 0x4e, 0x9c, 0x25, 0x4a, 0x94, 0x35, 0x6a, 0xd4, 0xb5, 0x77, 0xee, 0xc1, 0x9f, 0x23,
    -    0x46, 0x8c, 0x05, 0x0a, 0x14, 0x28, 0x50, 0xa0, 0x5d, 0xba, 0x69, 0xd2, 0xb9, 0x6f, 0xde, 0xa1,
    -    0x5f, 0xbe, 0x61, 0xc2, 0x99, 0x2f, 0x5e, 0xbc, 0x65, 0xca, 0x89, 0x0f, 0x1e, 0x3c, 0x78, 0xf0,
    -    0xfd, 0xe7, 0xd3, 0xbb, 0x6b, 0xd6, 0xb1, 0x7f, 0xfe, 0xe1, 0xdf, 0xa3, 0x5b, 0xb6, 0x71, 0xe2,
    -    0xd9, 0xaf, 0x43, 0x86, 0x11, 0x22, 0x44, 0x88, 0x0d, 0x1a, 0x34, 0x68, 0xd0, 0xbd, 0x67, 0xce,
    -    0x81, 0x1f, 0x3e, 0x7c, 0xf8, 0xed, 0xc7, 0x93, 0x3b, 0x76, 0xec, 0xc5, 0x97, 0x33, 0x66, 0xcc,
    -    0x85, 0x17, 0x2e, 0x5c, 0xb8, 0x6d, 0xda, 0xa9, 0x4f, 0x9e, 0x21, 0x42, 0x84, 0x15, 0x2a, 0x54,
    -    0xa8, 0x4d, 0x9a, 0x29, 0x52, 0xa4, 0x55, 0xaa, 0x49, 0x92, 0x39, 0x72, 0xe4, 0xd5, 0xb7, 0x73,
    -    0xe6, 0xd1, 0xbf, 0x63, 0xc6, 0x91, 0x3f, 0x7e, 0xfc, 0xe5, 0xd7, 0xb3, 0x7b, 0xf6, 0xf1, 0xff,
    -    0xe3, 0xdb, 0xab, 0x4b, 0x96, 0x31, 0x62, 0xc4, 0x95, 0x37, 0x6e, 0xdc, 0xa5, 0x57, 0xae, 0x41,
    -    0x82, 0x19, 0x32, 0x64, 0xc8, 0x8d, 0x07, 0x0e, 0x1c, 0x38, 0x70, 0xe0, 0xdd, 0xa7, 0x53, 0xa6,
    -    0x51, 0xa2, 0x59, 0xb2, 0x79, 0xf2, 0xf9, 0xef, 0xc3, 0x9b, 0x2b, 0x56, 0xac, 0x45, 0x8a, 0x09,
    -    0x12, 0x24, 0x48, 0x90, 0x3d, 0x7a, 0xf4, 0xf5, 0xf7, 0xf3, 0xfb, 0xeb, 0xcb, 0x8b, 0x0b, 0x16,
    -    0x2c, 0x58, 0xb0, 0x7d, 0xfa, 0xe9, 0xcf, 0x83, 0x1b, 0x36, 0x6c, 0xd8, 0xad, 0x47, 0x8e, 0x00
    -  ];
    - -
  • - - -
  • -
    - -
    - -
    -

    Galois field log table.

    - -
    - -
      var GALOIS_LOG = [
    -    0xff, 0x00, 0x01, 0x19, 0x02, 0x32, 0x1a, 0xc6, 0x03, 0xdf, 0x33, 0xee, 0x1b, 0x68, 0xc7, 0x4b,
    -    0x04, 0x64, 0xe0, 0x0e, 0x34, 0x8d, 0xef, 0x81, 0x1c, 0xc1, 0x69, 0xf8, 0xc8, 0x08, 0x4c, 0x71,
    -    0x05, 0x8a, 0x65, 0x2f, 0xe1, 0x24, 0x0f, 0x21, 0x35, 0x93, 0x8e, 0xda, 0xf0, 0x12, 0x82, 0x45,
    -    0x1d, 0xb5, 0xc2, 0x7d, 0x6a, 0x27, 0xf9, 0xb9, 0xc9, 0x9a, 0x09, 0x78, 0x4d, 0xe4, 0x72, 0xa6,
    -    0x06, 0xbf, 0x8b, 0x62, 0x66, 0xdd, 0x30, 0xfd, 0xe2, 0x98, 0x25, 0xb3, 0x10, 0x91, 0x22, 0x88,
    -    0x36, 0xd0, 0x94, 0xce, 0x8f, 0x96, 0xdb, 0xbd, 0xf1, 0xd2, 0x13, 0x5c, 0x83, 0x38, 0x46, 0x40,
    -    0x1e, 0x42, 0xb6, 0xa3, 0xc3, 0x48, 0x7e, 0x6e, 0x6b, 0x3a, 0x28, 0x54, 0xfa, 0x85, 0xba, 0x3d,
    -    0xca, 0x5e, 0x9b, 0x9f, 0x0a, 0x15, 0x79, 0x2b, 0x4e, 0xd4, 0xe5, 0xac, 0x73, 0xf3, 0xa7, 0x57,
    -    0x07, 0x70, 0xc0, 0xf7, 0x8c, 0x80, 0x63, 0x0d, 0x67, 0x4a, 0xde, 0xed, 0x31, 0xc5, 0xfe, 0x18,
    -    0xe3, 0xa5, 0x99, 0x77, 0x26, 0xb8, 0xb4, 0x7c, 0x11, 0x44, 0x92, 0xd9, 0x23, 0x20, 0x89, 0x2e,
    -    0x37, 0x3f, 0xd1, 0x5b, 0x95, 0xbc, 0xcf, 0xcd, 0x90, 0x87, 0x97, 0xb2, 0xdc, 0xfc, 0xbe, 0x61,
    -    0xf2, 0x56, 0xd3, 0xab, 0x14, 0x2a, 0x5d, 0x9e, 0x84, 0x3c, 0x39, 0x53, 0x47, 0x6d, 0x41, 0xa2,
    -    0x1f, 0x2d, 0x43, 0xd8, 0xb7, 0x7b, 0xa4, 0x76, 0xc4, 0x17, 0x49, 0xec, 0x7f, 0x0c, 0x6f, 0xf6,
    -    0x6c, 0xa1, 0x3b, 0x52, 0x29, 0x9d, 0x55, 0xaa, 0xfb, 0x60, 0x86, 0xb1, 0xbb, 0xcc, 0x3e, 0x5a,
    -    0xcb, 0x59, 0x5f, 0xb0, 0x9c, 0xa9, 0xa0, 0x51, 0x0b, 0xf5, 0x16, 0xeb, 0x7a, 0x75, 0x2c, 0xd7,
    -    0x4f, 0xae, 0xd5, 0xe9, 0xe6, 0xe7, 0xad, 0xe8, 0x74, 0xd6, 0xf4, 0xea, 0xa8, 0x50, 0x58, 0xaf
    -  ];
    - -
  • - - -
  • -
    - -
    - -
    -

    Badness coefficients.

    - -
    - -
      var N1 = 3;
    -  var N2 = 3;
    -  var N3 = 40;
    -  var N4 = 10;
    - -
  • - - -
  • -
    - -
    - -
    -

    Version pattern.

    - -
    - -
      var VERSION_BLOCK = [ 
    -    0xc94, 0x5bc, 0xa99, 0x4d3, 0xbf6, 0x762, 0x847, 0x60d, 0x928, 0xb78, 0x45d, 0xa17, 0x532,
    -    0x9a6, 0x683, 0x8c9, 0x7ec, 0xec4, 0x1e1, 0xfab, 0x08e, 0xc1a, 0x33f, 0xd75, 0x250, 0x9d5,
    -    0x6f0, 0x8ba, 0x79f, 0xb0b, 0x42e, 0xa64, 0x541, 0xc69
    -  ];
    - -
  • - - -
  • -
    - -
    - -
    -

    Mode for node.js file system file writes.

    - -
    - -
      var WRITE_MODE = parseInt('0666', 8);
    - -
  • - - -
  • -
    - -
    - -
    -

    Private variables

    - -
    - -
  • - - -
  • -
    - -
    - -
    - -
    - -
  • - - -
  • -
    - -
    - -
    -

    Run lengths for badness.

    - -
    - -
      var badBuffer = [];
    - -
  • - - -
  • -
    - -
    - -
    -

    Constructor for canvas elements in the node.js environment.

    - -
    - -
      var Canvas;
    - -
  • - - -
  • -
    - -
    - -
    -

    Data block.

    - -
    - -
      var dataBlock;
    - -
  • - - -
  • -
    - -
    - -
    -

    ECC data blocks and tables.

    - -
    - -
      var eccBlock, neccBlock1, neccBlock2;
    - -
  • - - -
  • -
    - -
    - -
    -

    ECC buffer.

    - -
    - -
      var eccBuffer = [];
    - -
  • - - -
  • -
    - -
    - -
    -

    ECC level (defaults to L).

    - -
    - -
      var eccLevel = 1;
    - -
  • - - -
  • -
    - -
    - -
    -

    Image buffer.

    - -
    - -
      var frameBuffer = [];
    - -
  • - - -
  • -
    - -
    - -
    -

    Fixed part of the image.

    - -
    - -
      var frameMask = [];
    - -
  • - - -
  • -
    - -
    - -
    -

    File system within the node.js environment.

    - -
    - -
      var fs;
    - -
  • - - -
  • -
    - -
    - -
    -

    Constructor for img elements in the node.js environment.

    - -
    - -
      var Image;
    - -
  • - - -
  • -
    - -
    - -
    -

    Indicates whether or not this script is running in node.js.

    - -
    - -
      var inNode = false;
    - -
  • - - -
  • -
    - -
    - -
    -

    Generator polynomial.

    - -
    - -
      var polynomial = [];
    - -
  • - - -
  • -
    - -
    - -
    -

    Save the previous value of the qr variable.

    - -
    - -
      var previousQr = root.qr;
    - -
  • - - -
  • -
    - -
    - -
    -

    Data input buffer.

    - -
    - -
      var stringBuffer = [];
    - -
  • - - -
  • -
    - -
    - -
    -

    Version for the data.

    - -
    - -
      var version;
    - -
  • - - -
  • -
    - -
    - -
    -

    Data width is based on version.

    - -
    - -
      var width;
    - -
  • - - -
  • -
    - -
    - -
    -

    Private functions

    - -
    - -
  • - - -
  • -
    - -
    - -
    - -
    - -
  • - - -
  • -
    - -
    - -
    -

    Create a new canvas using document.createElement unless script is running in node.js, in -which case the canvas module is used.

    - -
    - -
      function createCanvas() {
    -    return inNode ? new Canvas() : root.document.createElement('canvas');
    -  }
    - -
  • - - -
  • -
    - -
    - -
    -

    Create a new image using document.createElement unless script is running in node.js, in -which case the canvas module is used.

    - -
    - -
      function createImage() {
    -    return inNode ? new Image() : root.document.createElement('img');
    -  }
    - -
  • - - -
  • -
    - -
    - -
    -

    Force the canvas image to be downloaded in the browser.
    Optionally, a callback function can be specified which will be called upon completed. Since -this is not an asynchronous operation, this is merely convenient and helps simplify the -calling code.

    - -
    - -
      function download(cvs, data, callback) {
    -    var mime = data.mime || DEFAULT_MIME;
    -
    -    root.location.href = cvs.toDataURL(mime).replace(mime, DOWNLOAD_MIME);
    -
    -    if (typeof callback === 'function') callback();
    -  }
    - -
  • - - -
  • -
    - -
    - -
    -

    Normalize the data that is provided to the main API.

    - -
    - -
      function normalizeData(data) {
    -    if (typeof data === 'string') data = { value: data };
    -    return data || {};
    -  }
    - -
  • - - -
  • -
    - -
    - -
    -

    Override the qr API methods that require HTML5 canvas support to throw a relevant error.

    - -
    - -
      function overrideAPI(qr) {
    -    var methods = [ 'canvas', 'image', 'save', 'saveSync', 'toDataURL' ];
    -    var i;
    -
    -    function overrideMethod(name) {
    -      qr[name] = function () {
    -        throw new Error(name + ' requires HTML5 canvas element support');
    -      };
    -    }
    -
    -    for (i = 0; i < methods.length; i++) {
    -      overrideMethod(methods[i]);
    -    }
    -  }
    - -
  • - - -
  • -
    - -
    - -
    -

    Asynchronously write the data of the rendered canvas to a given file path.

    - -
    - -
      function writeFile(cvs, data, callback) {
    -    if (typeof data.path !== 'string') {
    -      return callback(new TypeError('Invalid path type: ' + typeof data.path));
    -    }
    -
    -    var fd, buff;
    - -
  • - - -
  • -
    - -
    - -
    -

    Write the buffer to the open file stream once both prerequisites are met.

    - -
    - -
        function writeBuffer() {
    -      fs.write(fd, buff, 0, buff.length, 0, function (error) {
    -        fs.close(fd);
    -
    -        callback(error);
    -      });
    -    }
    - -
  • - - -
  • -
    - -
    - -
    -

    Create a buffer of the canvas’ data.

    - -
    - -
        cvs.toBuffer(function (error, _buff) {
    -      if (error) return callback(error);
    -
    -      buff = _buff;
    -      if (fd) {
    -        writeBuffer();
    -      }
    -    });
    - -
  • - - -
  • -
    - -
    - -
    -

    Open a stream for the file to be written.

    - -
    - -
        fs.open(data.path, 'w', WRITE_MODE, function (error, _fd) {
    -      if (error) return callback(error);
    -
    -      fd = _fd;
    -      if (buff) {
    -        writeBuffer();
    -      }
    -    });
    -  }
    - -
  • - - -
  • -
    - -
    - -
    -

    Write the data of the rendered canvas to a given file path.

    - -
    - -
      function writeFileSync(cvs, data) {
    -    if (typeof data.path !== 'string') {
    -      throw new TypeError('Invalid path type: ' + typeof data.path);
    -    }
    -
    -    var buff = cvs.toBuffer();
    -    var fd = fs.openSync(data.path, 'w', WRITE_MODE);
    -
    -    try {
    -      fs.writeSync(fd, buff, 0, buff.length, 0);
    -    } finally {
    -      fs.closeSync(fd);
    -    }
    -  }
    - -
  • - - -
  • -
    - -
    - -
    -

    Set bit to indicate cell in frame is immutable (symmetric around diagonal).

    - -
    - -
      function setMask(x, y) {
    -    var bit;
    -
    -    if (x > y) {
    -      bit = x;
    -      x   = y;
    -      y   = bit;
    -    }
    -
    -    bit   = y;
    -    bit  *= y;
    -    bit  += y;
    -    bit >>= 1;
    -    bit  += x;
    -
    -    frameMask[bit] = 1;
    -  }
    - -
  • - - -
  • -
    - -
    - -
    -

    Enter alignment pattern. Foreground colour to frame, background to mask. Frame will be merged -with mask later.

    - -
    - -
      function addAlignment(x, y) {
    -    var i;
    -
    -    frameBuffer[x + width * y] = 1;
    -
    -    for (i = -2; i < 2; i++) {
    -      frameBuffer[(x + i)     + width * (y - 2)]     = 1;
    -      frameBuffer[(x - 2)     + width * (y + i + 1)] = 1;
    -      frameBuffer[(x + 2)     + width * (y + i)]     = 1;
    -      frameBuffer[(x + i + 1) + width * (y + 2)]     = 1;
    -    }
    -
    -    for (i = 0; i < 2; i++) {
    -      setMask(x - 1, y + i);
    -      setMask(x + 1, y - i);
    -      setMask(x - i, y - 1);
    -      setMask(x + i, y + 1);
    -    }
    -  }
    - -
  • - - -
  • -
    - -
    - -
    -

    Exponentiation mod N.

    - -
    - -
      function modN(x) {
    -    while (x >= 255) {
    -      x -= 255;
    -      x  = (x >> 8) + (x & 255);
    -    }
    -
    -    return x;
    -  }
    - -
  • - - -
  • -
    - -
    - -
    -

    Calculate and append ecc data to the data block. If block is in the string buffer the -indices to buffers are used.

    - -
    - -
      function appendData(data, dataLength, ecc, eccLength) {
    -    var bit, i, j;
    -
    -    for (i = 0; i < eccLength; i++) {
    -      stringBuffer[ecc + i] = 0;
    -    }
    -
    -    for (i = 0; i < dataLength; i++) {
    -      bit = GALOIS_LOG[stringBuffer[data + i] ^ stringBuffer[ecc]];
    -
    -      if (bit !== 255) {
    -        for (j = 1; j < eccLength; j++) {
    -          stringBuffer[ecc + j - 1] = stringBuffer[ecc + j] ^
    -              GALOIS_EXPONENT[modN(bit + polynomial[eccLength - j])];
    -        }
    -      } else {
    -        for (j = ecc; j < ecc + eccLength; j++) {
    -          stringBuffer[j] = stringBuffer[j + 1];
    -        }
    -      }
    -
    -      stringBuffer[ecc + eccLength - 1] = bit === 255 ? 0 :
    -          GALOIS_EXPONENT[modN(bit + polynomial[0])];
    -    }
    -  }
    - -
  • - - -
  • -
    - -
    - -
    -

    Check mask since symmetricals use half.

    - -
    - -
      function isMasked(x, y) {
    -    var bit;
    -
    -    if (x > y) {
    -      bit = x;
    -      x   = y;
    -      y   = bit;
    -    }
    -
    -    bit   = y;
    -    bit  += y * y;
    -    bit >>= 1;
    -    bit  += x;
    -
    -    return frameMask[bit] === 1;
    -  }
    - -
  • - - -
  • -
    - -
    - -
    -

    Apply the selected mask out of the 8 options.

    - -
    - -
      function applyMask(mask) {
    -    var x, y, r3x, r3y;
    -
    -    switch (mask) {
    -      case 0:
    -        for (y = 0; y < width; y++) {
    -          for (x = 0; x < width; x++) {
    -            if (!((x + y) & 1) && !isMasked(x, y)) {
    -              frameBuffer[x + y * width] ^= 1;
    -            }
    -          }
    -        }
    -
    -        break;
    -      case 1:
    -        for (y = 0; y < width; y++) {
    -          for (x = 0; x < width; x++) {
    -            if (!(y & 1) && !isMasked(x, y)) {
    -              frameBuffer[x + y * width] ^= 1;
    -            }
    -          }
    -        }
    -
    -        break;
    -      case 2:
    -        for (y = 0; y < width; y++) {
    -          for (r3x = 0, x = 0; x < width; x++, r3x++) {
    -            if (r3x === 3) r3x = 0;
    -
    -            if (!r3x && !isMasked(x, y)) {
    -              frameBuffer[x + y * width] ^= 1;
    -            }
    -          }
    -        }
    -
    -        break;
    -      case 3:
    -        for (r3y = 0, y = 0; y < width; y++, r3y++) {
    -          if (r3y === 3) r3y = 0;
    -
    -          for (r3x = r3y, x = 0; x < width; x++, r3x++) {
    -            if (r3x === 3) r3x = 0;
    -
    -            if (!r3x && !isMasked(x, y)) {
    -              frameBuffer[x + y * width] ^= 1;
    -            }
    -          }
    -        }
    -
    -        break;
    -      case 4:
    -        for (y = 0; y < width; y++) {
    -          for (r3x = 0, r3y = ((y >> 1) & 1), x = 0; x < width; x++, r3x++) {
    -            if (r3x === 3) {
    -              r3x = 0;
    -              r3y = !r3y;
    -            }
    -
    -            if (!r3y && !isMasked(x, y)) {
    -              frameBuffer[x + y * width] ^= 1;
    -            }
    -          }
    -        }
    -
    -        break;
    -      case 5:
    -        for (r3y = 0, y = 0; y < width; y++, r3y++) {
    -          if (r3y === 3) r3y = 0;
    -
    -          for (r3x = 0, x = 0; x < width; x++, r3x++) {
    -            if (r3x === 3) r3x = 0;
    -
    -            if (!((x & y & 1) + !(!r3x | !r3y)) && !isMasked(x, y)) {
    -              frameBuffer[x + y * width] ^= 1;
    -            }
    -          }
    -        }
    -
    -        break;
    -      case 6:
    -        for (r3y = 0, y = 0; y < width; y++, r3y++) {
    -          if (r3y === 3) r3y = 0;
    -
    -          for (r3x = 0, x = 0; x < width; x++, r3x++) {
    -            if (r3x === 3) r3x = 0;
    -
    -            if (!(((x & y & 1) + (r3x && (r3x === r3y))) & 1) && !isMasked(x, y)) {
    -              frameBuffer[x + y * width] ^= 1;
    -            }
    -          }
    -        }
    -
    -        break;
    -      case 7:
    -        for (r3y = 0, y = 0; y < width; y++, r3y++) {
    -          if (r3y === 3) r3y = 0;
    -
    -          for (r3x = 0, x = 0; x < width; x++, r3x++) {
    -            if (r3x === 3) r3x = 0;
    -
    -            if (!(((r3x && (r3x === r3y)) + ((x + y) & 1)) & 1) && !isMasked(x, y)) {
    -              frameBuffer[x + y * width] ^= 1;
    -            }
    -          }
    -        }
    -
    -        break;
    -    }
    -  }
    - -
  • - - -
  • -
    - -
    - -
    -

    Using the table for the length of each run, calculate the amount of bad image. Long runs or -those that look like finders are called twice; once for X and Y.

    - -
    - -
      function getBadRuns(length) {
    -    var badRuns = 0;
    -    var i;
    -
    -    for (i = 0; i <= length; i++) {
    -      if (badBuffer[i] >= 5) {
    -        badRuns += N1 + badBuffer[i] - 5;
    -      }
    -    }
    - -
  • - - -
  • -
    - -
    - -
    -

    FBFFFBF as in finder.

    - -
    - -
        for (i = 3; i < length - 1; i += 2) {
    -      if (badBuffer[i - 2] === badBuffer[i + 2] &&
    -          badBuffer[i + 2] === badBuffer[i - 1] &&
    -          badBuffer[i - 1] === badBuffer[i + 1] &&
    -          badBuffer[i - 1] * 3 === badBuffer[i] &&
    - -
  • - - -
  • -
    - -
    - -
    -

    Background around the foreground pattern? Not part of the specs.

    - -
    - -
              (badBuffer[i - 3] === 0 || i + 3 > length ||
    -           badBuffer[i - 3] * 3 >= badBuffer[i] * 4 ||
    -           badBuffer[i + 3] * 3 >= badBuffer[i] * 4)) {
    -        badRuns += N3;
    -      }
    -    }
    -
    -    return badRuns;
    -  }
    - -
  • - - -
  • -
    - -
    - -
    -

    Calculate how bad the masked image is (e.g. blocks, imbalance, runs, or finders).

    - -
    - -
      function checkBadness() {
    -    var b, b1, bad, big, bw, count, h, x, y;
    -    bad = bw = count = 0;
    - -
  • - - -
  • -
    - -
    - -
    -

    Blocks of same colour.

    - -
    - -
        for (y = 0; y < width - 1; y++) {
    -      for (x = 0; x < width - 1; x++) {
    - -
  • - - -
  • -
    - -
    - -
    -

    All foreground colour.

    - -
    - -
            if ((frameBuffer[x + width * y] &&
    -             frameBuffer[(x + 1) + width * y] &&
    -             frameBuffer[x + width * (y + 1)] &&
    -             frameBuffer[(x + 1) + width * (y + 1)]) ||
    - -
  • - - -
  • -
    - -
    - -
    -

    All background colour.

    - -
    - -
                !(frameBuffer[x + width * y] ||
    -              frameBuffer[(x + 1) + width * y] ||
    -              frameBuffer[x + width * (y + 1)] ||
    -              frameBuffer[(x + 1) + width * (y + 1)])) {
    -          bad += N2;
    -        }
    -      }
    -    }
    - -
  • - - -
  • -
    - -
    - -
    -

    X runs.

    - -
    - -
        for (y = 0; y < width; y++) {
    -      badBuffer[0] = 0;
    -
    -      for (h = b = x = 0; x < width; x++) {
    -        if ((b1 = frameBuffer[x + width * y]) === b) {
    -          badBuffer[h]++;
    -        } else {
    -          badBuffer[++h] = 1;
    -        }
    -
    -        b   = b1;
    -        bw += b ? 1 : -1;
    -      }
    -
    -      bad += getBadRuns(h);
    -    }
    -
    -    if (bw < 0) bw = -bw;
    -
    -    big   = bw;
    -    big  += big << 2;
    -    big <<= 1;
    -
    -    while (big > width * width) {
    -      big -= width * width;
    -      count++;
    -    }
    -
    -    bad += count * N4;
    - -
  • - - -
  • -
    - -
    - -
    -

    Y runs.

    - -
    - -
        for (x = 0; x < width; x++) {
    -      badBuffer[0] = 0;
    -
    -      for (h = b = y = 0; y < width; y++) {
    -        if ((b1 = frameBuffer[x + width * y]) === b) {
    -          badBuffer[h]++;
    -        } else {
    -          badBuffer[++h] = 1;
    -        }
    -
    -        b = b1;
    -      }
    -
    -      bad += getBadRuns(h);
    -    }
    -
    -    return bad;
    -  }
    - -
  • - - -
  • -
    - -
    - -
    -

    Generate the encoded QR image for the string provided.

    - -
    - -
      function generateFrame(str) {
    -    var i, j, k, m, t, v, x, y;
    - -
  • - - -
  • -
    - -
    - -
    -

    Find the smallest version that fits the string.

    - -
    - -
        t = str.length;
    -
    -    version = 0;
    -
    -    do {
    -      version++;
    -
    -      k = (eccLevel - 1) * 4 + (version - 1) * 16;
    -
    -      neccBlock1 = ECC_BLOCKS[k++];
    -      neccBlock2 = ECC_BLOCKS[k++];
    -      dataBlock  = ECC_BLOCKS[k++];
    -      eccBlock   = ECC_BLOCKS[k];
    -
    -      k = dataBlock * (neccBlock1 + neccBlock2) + neccBlock2 - 3 + (version <= 9);
    -
    -      if (t <= k) break;
    -    } while (version < 40);
    - -
  • - - -
  • -
    - -
    - -
    -

    FIXME: Ensure that it fits insted of being truncated.

    - -
    - -
        width = 17 + 4 * version;
    - -
  • - - -
  • -
    - -
    - -
    -

    Allocate, clear and setup data structures.

    - -
    - -
        v = dataBlock + (dataBlock + eccBlock) * (neccBlock1 + neccBlock2) + neccBlock2;
    -
    -    for (t = 0; t < v; t++) {
    -      eccBuffer[t] = 0;
    -    }
    -
    -    stringBuffer = str.slice(0);
    -
    -    for (t = 0; t < width * width; t++) {
    -      frameBuffer[t] = 0;
    -    }
    -
    -    for (t = 0; t < (width * (width + 1) + 1) / 2; t++) {
    -      frameMask[t] = 0;
    -    }
    - -
  • - - -
  • -
    - -
    - -
    -

    Insert finders: Foreground colour to frame and background to mask.

    - -
    - -
        for (t = 0; t < 3; t++) {
    -      k = y = 0;
    -
    -      if (t === 1) k = (width - 7);
    -      if (t === 2) y = (width - 7);
    -
    -      frameBuffer[(y + 3) + width * (k + 3)] = 1;
    -
    -      for (x = 0; x < 6; x++) {
    -        frameBuffer[(y + x) + width * k] = 1;
    -        frameBuffer[y + width * (k + x + 1)] = 1;
    -        frameBuffer[(y + 6) + width * (k + x)] = 1;
    -        frameBuffer[(y + x + 1) + width * (k + 6)] = 1;
    -      }
    -
    -      for (x = 1; x < 5; x++) {
    -        setMask(y + x, k + 1);
    -        setMask(y + 1, k + x + 1);
    -        setMask(y + 5, k + x);
    -        setMask(y + x + 1, k + 5);
    -      }
    -
    -      for (x = 2; x < 4; x++) {
    -        frameBuffer[(y + x) + width * (k + 2)] = 1;
    -        frameBuffer[(y + 2) + width * (k + x + 1)] = 1;
    -        frameBuffer[(y + 4) + width * (k + x)] = 1;
    -        frameBuffer[(y + x + 1) + width * (k + 4)] = 1;
    -      }
    -    }
    - -
  • - - -
  • -
    - -
    - -
    -

    Alignment blocks.

    - -
    - -
        if (version > 1) {
    -      t = ALIGNMENT_DELTA[version];
    -      y = width - 7;
    -
    -      for (;;) {
    -        x = width - 7;
    -
    -        while (x > t - 3) {
    -          addAlignment(x, y);
    -
    -          if (x < t) break;
    -
    -          x -= t;
    -        }
    -
    -        if (y <= t + 9) break;
    -
    -        y -= t;
    -
    -        addAlignment(6, y);
    -        addAlignment(y, 6);
    -      }
    -    }
    - -
  • - - -
  • -
    - -
    - -
    -

    Single foreground cell.

    - -
    - -
        frameBuffer[8 + width * (width - 8)] = 1;
    - -
  • - - -
  • -
    - -
    - -
    -

    Timing gap (mask only).

    - -
    - -
        for (y = 0; y < 7; y++) {
    -      setMask(7, y);
    -      setMask(width - 8, y);
    -      setMask(7, y + width - 7);
    -    }
    -
    -    for (x = 0; x < 8; x++) {
    -      setMask(x, 7);
    -      setMask(x + width - 8, 7);
    -      setMask(x, width - 8);
    -    }
    - -
  • - - -
  • -
    - -
    - -
    -

    Reserve mask, format area.

    - -
    - -
        for (x = 0; x < 9; x++) {
    -      setMask(x, 8);
    -    }
    -
    -    for (x = 0; x < 8; x++) {
    -      setMask(x + width - 8, 8);
    -      setMask(8, x);
    -    }
    -
    -    for (y = 0; y < 7; y++) {
    -      setMask(8, y + width - 7);
    -    }
    - -
  • - - -
  • -
    - -
    - -
    -

    Timing row/column.

    - -
    - -
        for (x = 0; x < width - 14; x++) {
    -      if (x & 1) {
    -        setMask(8 + x, 6);
    -        setMask(6, 8 + x);
    -      } else {
    -        frameBuffer[(8 + x) + width * 6] = 1;
    -        frameBuffer[6 + width * (8 + x)] = 1;
    -      }
    -    }
    - -
  • - - -
  • -
    - -
    - -
    -

    Version block.

    - -
    - -
        if (version > 6) {
    -      t = VERSION_BLOCK[version - 7];
    -      k = 17;
    -
    -      for (x = 0; x < 6; x++) {
    -        for (y = 0; y < 3; y++, k--) {
    -          if (1 & (k > 11 ? version >> (k - 12) : t >> k)) {
    -            frameBuffer[(5 - x) + width * (2 - y + width - 11)] = 1;
    -            frameBuffer[(2 - y + width - 11) + width * (5 - x)] = 1;
    -          } else {
    -            setMask(5 - x, 2 - y + width - 11);
    -            setMask(2 - y + width - 11, 5 - x);
    -          }
    -        }
    -      }
    -    }
    - -
  • - - -
  • -
    - -
    - -
    -

    Sync mask bits. Only set above for background cells, so now add the foreground.

    - -
    - -
        for (y = 0; y < width; y++) {
    -      for (x = 0; x <= y; x++) {
    -        if (frameBuffer[x + width * y]) {
    -          setMask(x, y);
    -        }
    -      }
    -    }
    - -
  • - - -
  • -
    - -
    - -
    -

    Convert string to bit stream. 8-bit data to QR-coded 8-bit data (numeric, alphanum, or kanji -not supported).

    - -
    - -
        v = stringBuffer.length;
    - -
  • - - -
  • -
    - -
    - -
    -

    String to array.

    - -
    - -
        for (i = 0; i < v; i++) {
    -      eccBuffer[i] = stringBuffer.charCodeAt(i);
    -    }
    -
    -    stringBuffer = eccBuffer.slice(0);
    - -
  • - - -
  • -
    - -
    - -
    -

    Calculate max string length.

    - -
    - -
        x = dataBlock * (neccBlock1 + neccBlock2) + neccBlock2;
    -
    -    if (v >= x - 2) {
    -      v = x - 2;
    -
    -      if (version > 9) v--;
    -    }
    - -
  • - - -
  • -
    - -
    - -
    -

    Shift and re-pack to insert length prefix.

    - -
    - -
        i = v;
    -
    -    if (version > 9) {
    -      stringBuffer[i + 2] = 0;
    -      stringBuffer[i + 3] = 0;
    -
    -      while (i--) {
    -        t = stringBuffer[i];
    -
    -        stringBuffer[i + 3] |= 255 & (t << 4);
    -        stringBuffer[i + 2] = t >> 4;
    -      }
    -
    -      stringBuffer[2] |= 255 & (v << 4);
    -      stringBuffer[1] = v >> 4;
    -      stringBuffer[0] = 0x40 | (v >> 12);
    -    } else {
    -      stringBuffer[i + 1] = 0;
    -      stringBuffer[i + 2] = 0;
    -
    -      while (i--) {
    -        t = stringBuffer[i];
    -
    -        stringBuffer[i + 2] |= 255 & (t << 4);
    -        stringBuffer[i + 1] = t >> 4;
    -      }
    -
    -      stringBuffer[1] |= 255 & (v << 4);
    -      stringBuffer[0] = 0x40 | (v >> 4);
    -    }
    - -
  • - - -
  • -
    - -
    - -
    -

    Fill to end with pad pattern.

    - -
    - -
        i = v + 3 - (version < 10);
    -
    -    while (i < x) {
    -      stringBuffer[i++] = 0xec;
    -      stringBuffer[i++] = 0x11;
    -    }
    - -
  • - - -
  • -
    - -
    - -
    -

    Calculate generator polynomial.

    - -
    - -
        polynomial[0] = 1;
    -
    -    for (i = 0; i < eccBlock; i++) {
    -      polynomial[i + 1] = 1;
    -
    -      for (j = i; j > 0; j--) {
    -        polynomial[j] = polynomial[j] ? polynomial[j - 1] ^
    -            GALOIS_EXPONENT[modN(GALOIS_LOG[polynomial[j]] + i)] : polynomial[j - 1];
    -      }
    -
    -      polynomial[0] = GALOIS_EXPONENT[modN(GALOIS_LOG[polynomial[0]] + i)];
    -    }
    - -
  • - - -
  • -
    - -
    - -
    -

    Use logs for generator polynomial to save calculation step.

    - -
    - -
        for (i = 0; i <= eccBlock; i++) {
    -      polynomial[i] = GALOIS_LOG[polynomial[i]];
    -    }
    - -
  • - - -
  • -
    - -
    - -
    -

    Append ECC to data buffer.

    - -
    - -
        k = x;
    -    y = 0;
    -
    -    for (i = 0; i < neccBlock1; i++) {
    -      appendData(y, dataBlock, k, eccBlock);
    -
    -      y += dataBlock;
    -      k += eccBlock;
    -    }
    -
    -    for (i = 0; i < neccBlock2; i++) {
    -      appendData(y, dataBlock + 1, k, eccBlock);
    -
    -      y += dataBlock + 1;
    -      k += eccBlock;
    -    }
    - -
  • - - -
  • -
    - -
    - -
    -

    Interleave blocks.

    - -
    - -
        y = 0;
    -
    -    for (i = 0; i < dataBlock; i++) {
    -      for (j = 0; j < neccBlock1; j++) {
    -        eccBuffer[y++] = stringBuffer[i + j * dataBlock];
    -      }
    -
    -      for (j = 0; j < neccBlock2; j++) {
    -        eccBuffer[y++] = stringBuffer[(neccBlock1 * dataBlock) + i + (j * (dataBlock + 1))];
    -      }
    -    }
    -
    -    for (j = 0; j < neccBlock2; j++) {
    -      eccBuffer[y++] = stringBuffer[(neccBlock1 * dataBlock) + i + (j * (dataBlock + 1))];
    -    }
    -
    -    for (i = 0; i < eccBlock; i++) {
    -      for (j = 0; j < neccBlock1 + neccBlock2; j++) {
    -        eccBuffer[y++] = stringBuffer[x + i + j * eccBlock];
    -      }
    -    }
    -
    -    stringBuffer = eccBuffer;
    - -
  • - - -
  • -
    - -
    - -
    -

    Pack bits into frame avoiding masked area.

    - -
    - -
        x = y = width - 1;
    -    k = v = 1;
    - -
  • - - -
  • -
    - -
    - -
    -

    inteleaved data and ECC codes.

    - -
    - -
        m = (dataBlock + eccBlock) * (neccBlock1 + neccBlock2) + neccBlock2;
    -
    -    for (i = 0; i < m; i++) {
    -      t = stringBuffer[i];
    -
    -      for (j = 0; j < 8; j++, t <<= 1) {
    -        if (0x80 & t) {
    -          frameBuffer[x + width * y] = 1;
    -        }
    - -
  • - - -
  • -
    - -
    - -
    -

    Find next fill position.

    - -
    - -
            do {
    -          if (v) {
    -            x--;
    -          } else {
    -            x++;
    -
    -            if (k) {
    -              if (y !== 0) {
    -                y--;
    -              } else {
    -                x -= 2;
    -                k  = !k;
    -
    -                if (x === 6) {
    -                  x--;
    -                  y = 9;
    -                }
    -              }
    -            } else {
    -              if (y !== width - 1) {
    -                y++;
    -              } else {
    -                x -= 2;
    -                k  = !k;
    -
    -                if (x === 6) {
    -                  x--;
    -                  y -= 8;
    -                }
    -              }
    -            }
    -          }
    -
    -          v = !v;
    -        } while (isMasked(x, y));
    -      }
    -    }
    - -
  • - - -
  • -
    - -
    - -
    -

    Save pre-mask copy of frame.

    - -
    - -
        stringBuffer = frameBuffer.slice(0);
    -
    -    t = 0;
    -    y = 30000;
    - -
  • - - -
  • -
    - -
    - -
    -

    Using for instead of while since in original Arduino code if an early mask was good -enough it wouldn’t try for a better one since they get more complex and take longer.

    - -
    - -
        for (k = 0; k < 8; k++) {
    - -
  • - - -
  • -
    - -
    - -
    -

    Returns foreground-background imbalance.

    - -
    - -
          applyMask(k);
    -
    -      x = checkBadness();
    - -
  • - - -
  • -
    - -
    - -
    -

    Is current mask better than previous best?

    - -
    - -
          if (x < y) {
    -        y = x;
    -        t = k;
    -      }
    - -
  • - - -
  • -
    - -
    - -
    -

    Don’t increment i to a void redoing mask.

    - -
    - -
          if (t === 7) break;
    - -
  • - - -
  • -
    - -
    - -
    -

    Reset for next pass.

    - -
    - -
          frameBuffer = stringBuffer.slice(0);
    -    }
    - -
  • - - -
  • -
    - -
    - -
    -

    Redo best mask as none were good enough (i.e. last wasn’t t).

    - -
    - -
        if (t !== k) {
    -      applyMask(t);
    -    }
    - -
  • - - -
  • -
    - -
    - -
    -

    Add in final mask/ECC level bytes.

    - -
    - -
        y = FINAL_FORMAT[t + ((eccLevel - 1) << 3)];
    - -
  • - - -
  • -
    - -
    - -
    -

    Low byte.

    - -
    - -
        for (k = 0; k < 8; k++, y >>= 1) {
    -      if (y & 1) {
    -        frameBuffer[(width - 1 - k) + width * 8] = 1;
    -
    -        if (k < 6) {
    -          frameBuffer[8 + width * k] = 1;
    -        } else {
    -          frameBuffer[8 + width * (k + 1)] = 1;
    -        }
    -      }
    -    }
    - -
  • - - -
  • -
    - -
    - -
    -

    High byte.

    - -
    - -
        for (k = 0; k < 7; k++, y >>= 1) {
    -      if (y & 1) {
    -        frameBuffer[8 + width * (width - 7 + k)] = 1;
    -
    -        if (k) {
    -          frameBuffer[(6 - k) + width * 8] = 1;
    -        } else {
    -          frameBuffer[7 + width * 8] = 1;
    -        }
    -      }
    -    }
    - -
  • - - -
  • -
    - -
    - -
    -

    Finally, return the image data.

    - -
    - -
        return frameBuffer;
    -  }
    - -
  • - - -
  • -
    - -
    - -
    -

    qr.js setup

    - -
    - -
  • - - -
  • -
    - -
    - -
    - -
    - -
  • - - -
  • -
    - -
    - -
    -

    Build the publicly exposed API.

    - -
    - -
      var qr = {
    - -
  • - - -
  • -
    - -
    - -
    -

    Constants

    - -
    - -
  • - - -
  • -
    - -
    - -
    - -
    - -
  • - - -
  • -
    - -
    - -
    -

    Current version of qr.

    - -
    - -
        VERSION: '1.1.4',
    - -
  • - - -
  • -
    - -
    - -
    -

    QR functions

    - -
    - -
  • - - -
  • -
    - -
    - -
    - -
    - -
  • - - -
  • -
    - -
    - -
    -

    Generate the QR code using the data provided and render it on to a <canvas> element.
    If no <canvas> element is specified in the argument provided a new one will be created and -used.
    ECC (error correction capacity) determines how many intential errors are contained in the QR -code.

    - -
    - -
        canvas: function(data) {
    -      data = normalizeData(data);
    - -
  • - - -
  • -
    - -
    - -
    -

    Module size of the generated QR code (i.e. 1-10).

    - -
    - -
          var size = data.size >= 1 && data.size <= 10 ? data.size : 4;
    - -
  • - - -
  • -
    - -
    - -
    -

    Actual size of the QR code symbol and is scaled to 25 pixels (e.g. 1 = 25px, 3 = 75px).

    - -
    - -
          size *= 25;
    - -
  • - - -
  • -
    - -
    - -
    -

    <canvas> element used to render the QR code.

    - -
    - -
          var cvs = data.canvas || createCanvas();
    - -
  • - - -
  • -
    - -
    - -
    -

    Retreive the 2D context of the canvas.

    - -
    - -
          var c2d = cvs.getContext('2d');
    - -
  • - - -
  • -
    - -
    - -
    -

    Ensure the canvas has the correct dimensions.

    - -
    - -
          c2d.canvas.width  = size;
    -      c2d.canvas.height = size;
    - -
  • - - -
  • -
    - -
    - -
    -

    Fill the canvas with the correct background colour.

    - -
    - -
          c2d.fillStyle = data.background || '#fff';
    -      c2d.fillRect(0, 0, size, size);
    - -
  • - - -
  • -
    - -
    - -
    -

    Determine the ECC level to be applied.

    - -
    - -
          eccLevel = ECC_LEVELS[(data.level && data.level.toUpperCase()) || 'L'];
    - -
  • - - -
  • -
    - -
    - -
    -

    Generate the image frame for the given value.

    - -
    - -
          var frame = generateFrame(data.value || '');
    -
    -      c2d.lineWidth = 1;
    - -
  • - - -
  • -
    - -
    - -
    -

    Determine the pixel size.

    - -
    - -
          var px = size;
    -      px /= width;
    -      px  = Math.floor(px);
    -
    -      var offset = Math.floor((size - (px * width)) / 2);
    - -
  • - - -
  • -
    - -
    - -
    -

    Draw the QR code.

    - -
    - -
          c2d.clearRect(0, 0, size, size);
    -      c2d.fillStyle = data.background || '#fff';
    -      c2d.fillRect(0, 0, size, size);
    -      c2d.fillStyle = data.foreground || '#000';
    -
    -      var i, j;
    -
    -      for (i = 0; i < width; i++) {
    -        for (j = 0; j < width; j++) {
    -          if (frame[j * width + i]) {
    -            c2d.fillRect(px * i + offset, px * j + offset, px, px);
    -          }
    -        }
    -      }
    -
    -      return cvs;
    -    },
    - -
  • - - -
  • -
    - -
    - -
    -

    Generate the QR code using the data provided and render it on to a <img> element.
    If no <img> element is specified in the argument provided a new one will be created and -used.
    ECC (error correction capacity) determines how many intential errors are contained in the QR -code.

    - -
    - -
        image: function(data) {
    -      data = normalizeData(data);
    - -
  • - - -
  • -
    - -
    - -
    -

    <canvas> element only which the QR code is rendered.

    - -
    - -
          var cvs = this.canvas(data);
    - -
  • - - -
  • -
    - -
    - -
    -

    <img> element used to display the QR code.

    - -
    - -
          var img = data.image || createImage();
    - -
  • - - -
  • -
    - -
    - -
    -

    Apply the QR code to img.

    - -
    - -
          img.src    = cvs.toDataURL(data.mime || DEFAULT_MIME);
    -      img.height = cvs.height;
    -      img.width  = cvs.width;
    -
    -      return img;
    -    },
    - -
  • - - -
  • -
    - -
    - -
    -

    Generate the QR code using the data provided and render it on to a <canvas> element and -save it as an image file.
    If no <canvas> element is specified in the argument provided a new one will be created and -used.
    ECC (error correction capacity) determines how many intential errors are contained in the QR -code.
    If called in a browser the path property/argument is ignored and will simply prompt the -user to choose a location and file name. However, if called within node.js the file will be -saved to specified path.
    A callback function must be provided which will be called once the saving process has -started. If an error occurs it will be passed as the first argument to this function, -otherwise this argument will be null.

    - -
    - -
        save: function(data, path, callback) {
    -      data = normalizeData(data);
    -
    -      switch (typeof path) {
    -        case 'function':
    -          callback = path;
    -          path = null;
    -          break;
    -        case 'string':
    -          data.path = path;
    -          break;
    -      }
    - -
  • - - -
  • -
    - -
    - -
    -

    Callback function is required.

    - -
    - -
          if (typeof callback !== 'function') {
    -        throw new TypeError('Invalid callback type: ' + typeof callback);
    -      }
    -
    -      var completed = false;
    - -
  • - - -
  • -
    - -
    - -
    -

    <canvas> element only which the QR code is rendered.

    - -
    - -
          var cvs = this.canvas(data);
    - -
  • - - -
  • -
    - -
    - -
    -

    Simple function to try and ensure that the callback function is only called once.

    - -
    - -
          function done(error) {
    -        if (!completed) {
    -          completed = true;
    -
    -          callback(error);
    -        }
    -      }
    -
    -      if (inNode) {
    -        writeFile(cvs, data, done);
    -      } else {
    -        download(cvs, data, done);
    -      }
    -    },
    - -
  • - - -
  • -
    - -
    - -
    -

    Generate the QR code using the data provided and render it on to a <canvas> element and -save it as an image file.
    If no <canvas> element is specified in the argument provided a new one will be created and -used.
    ECC (error correction capacity) determines how many intential errors are contained in the QR -code.
    If called in a browser the path property/argument is ignored and will simply prompt the -user to choose a location and file name. However, if called within node.js the file will be -saved to specified path.

    - -
    - -
        saveSync: function(data, path) {
    -      data = normalizeData(data);
    -
    -      if (typeof path === 'string') data.path = path;
    - -
  • - - -
  • -
    - -
    - -
    -

    <canvas> element only which the QR code is rendered.

    - -
    - -
          var cvs = this.canvas(data);
    -
    -      if (inNode) {
    -        writeFileSync(cvs, data);
    -      } else {
    -        download(cvs, data);
    -      }
    -    },
    - -
  • - - -
  • -
    - -
    - -
    -

    Generate the QR code using the data provided and render it on to a <canvas> element before -returning its data URI.
    If no <canvas> element is specified in the argument provided a new one will be created and -used.
    ECC (error correction capacity) determines how many intential errors are contained in the QR -code.

    - -
    - -
        toDataURL: function(data) {
    -      data = normalizeData(data);
    -
    -      return this.canvas(data).toDataURL(data.mime || DEFAULT_MIME);
    -    },
    - -
  • - - -
  • -
    - -
    - -
    -

    Utility functions

    - -
    - -
  • - - -
  • -
    - -
    - -
    - -
    - -
  • - - -
  • -
    - -
    - -
    -

    Run qr.js in noConflict mode, returning the qr variable to its previous owner.
    Returns a reference to qr.

    - -
    - -
        noConflict: function() {
    -      root.qr = previousQr;
    -      return this;
    -    }
    -
    -  };
    - -
  • - - -
  • -
    - -
    - -
    -

    Support

    - -
    - -
  • - - -
  • -
    - -
    - -
    - -
    - -
  • - - -
  • -
    - -
    - -
    -

    Export qr for node.js and CommonJS.

    - -
    - -
      if (typeof exports !== 'undefined') {
    -    inNode = true;
    -
    -    if (typeof module !== 'undefined' && module.exports) {
    -      exports = module.exports = qr;
    -    }
    -    exports.qr = qr;
    - -
  • - - -
  • -
    - -
    - -
    -

    Import required node.js modules.

    - -
    - -
        Canvas = require('canvas');
    -    Image = Canvas.Image;
    -    fs = require('fs');
    -  } else if (typeof define === 'function' && define.amd) {
    -    define(function () {
    -      return qr;
    -    });
    -  } else {
    - -
  • - - -
  • -
    - -
    - -
    -

    In non-HTML5 browser so strip base functionality.

    - -
    - -
        if (!root.HTMLCanvasElement) {
    -      overrideAPI(qr);
    -    }
    -
    -    root.qr = qr;
    -  }
    -
    -})(this);
    - -
  • - -
-
- - diff --git a/package.json b/package.json index 5f8bc01..c3c1523 100644 --- a/package.json +++ b/package.json @@ -1,10 +1,10 @@ { - "name": "qr-js", - "version": "1.1.4", + "name": "qrious", + "version": "2.0.0", "description": "Library for QR code generation using canvas", - "homepage": "http://neocotic.com/qr.js", + "homepage": "https://github.com/neocotic/qrious", "bugs": { - "url": "https://github.com/neocotic/qr.js/issues" + "url": "https://github.com/neocotic/qrious/issues" }, "author": { "name": "Alasdair Mercer", @@ -21,20 +21,30 @@ ], "repository": { "type": "git", - "url": "https://github.com/neocotic/qr.js.git" + "url": "https://github.com/neocotic/qrious.git" }, - "dependencies": { - "canvas": "^1.3.1" + "optionalDependencies": { + "canvas": "^1.3.12" }, "devDependencies": { - "grunt": "^0.4.5", - "grunt-cli": "^0.1.13", - "grunt-contrib-jshint": "^0.11.3", - "grunt-contrib-uglify": "^0.10.0", - "grunt-docco": "^0.4.0" + "babel-eslint": "^6.1.0", + "babel-preset-es2015-rollup": "^1.1.1", + "grunt": "^1.0.1", + "grunt-cli": "^1.2.0", + "grunt-contrib-clean": "^1.0.0", + "grunt-contrib-watch": "^1.0.0", + "grunt-eslint": "^18.1.0", + "grunt-rollup": "^0.7.1", + "load-grunt-tasks": "^3.5.0", + "rollup-plugin-babel": "^2.6.1", + "rollup-plugin-node-resolve": "^1.7.1", + "rollup-plugin-uglify": "^1.0.1" }, - "main": "qr.js", + "browser": "dist/umd/qrious.js", + "main": "dist/cjs/qrious.js", + "jsnext:main": "src/runtime/node.js", "scripts": { + "build": "grunt build", "test": "grunt test" } } diff --git a/qr.js b/qr.js deleted file mode 100644 index e695bc1..0000000 --- a/qr.js +++ /dev/null @@ -1,1217 +0,0 @@ -// [qr.js](http://neocotic.com/qr.js) -// (c) 2015 Alasdair Mercer -// Licensed under the GPL Version 3 license. -// Based on [jsqrencode](http://code.google.com/p/jsqrencode/) -// (c) 2010 tz@execpc.com -// Licensed under the GPL Version 3 license. -// For all details and documentation: -// - -(function (root) { - - 'use strict'; - - // Private constants - // ----------------- - - // Alignment pattern. - var ALIGNMENT_DELTA = [ - 0, 11, 15, 19, 23, 27, 31, - 16, 18, 20, 22, 24, 26, 28, 20, 22, 24, 24, 26, 28, 28, 22, 24, 24, - 26, 26, 28, 28, 24, 24, 26, 26, 26, 28, 28, 24, 26, 26, 26, 28, 28 - ]; - // Default MIME type. - var DEFAULT_MIME = 'image/png'; - // MIME used to initiate a browser download prompt when `qr.save` is called. - var DOWNLOAD_MIME = 'image/octet-stream'; - // There are four elements per version. The first two indicate the number of blocks, then the - // data width, and finally the ECC width. - var ECC_BLOCKS = [ - 1, 0, 19, 7, 1, 0, 16, 10, 1, 0, 13, 13, 1, 0, 9, 17, - 1, 0, 34, 10, 1, 0, 28, 16, 1, 0, 22, 22, 1, 0, 16, 28, - 1, 0, 55, 15, 1, 0, 44, 26, 2, 0, 17, 18, 2, 0, 13, 22, - 1, 0, 80, 20, 2, 0, 32, 18, 2, 0, 24, 26, 4, 0, 9, 16, - 1, 0, 108, 26, 2, 0, 43, 24, 2, 2, 15, 18, 2, 2, 11, 22, - 2, 0, 68, 18, 4, 0, 27, 16, 4, 0, 19, 24, 4, 0, 15, 28, - 2, 0, 78, 20, 4, 0, 31, 18, 2, 4, 14, 18, 4, 1, 13, 26, - 2, 0, 97, 24, 2, 2, 38, 22, 4, 2, 18, 22, 4, 2, 14, 26, - 2, 0, 116, 30, 3, 2, 36, 22, 4, 4, 16, 20, 4, 4, 12, 24, - 2, 2, 68, 18, 4, 1, 43, 26, 6, 2, 19, 24, 6, 2, 15, 28, - 4, 0, 81, 20, 1, 4, 50, 30, 4, 4, 22, 28, 3, 8, 12, 24, - 2, 2, 92, 24, 6, 2, 36, 22, 4, 6, 20, 26, 7, 4, 14, 28, - 4, 0, 107, 26, 8, 1, 37, 22, 8, 4, 20, 24, 12, 4, 11, 22, - 3, 1, 115, 30, 4, 5, 40, 24, 11, 5, 16, 20, 11, 5, 12, 24, - 5, 1, 87, 22, 5, 5, 41, 24, 5, 7, 24, 30, 11, 7, 12, 24, - 5, 1, 98, 24, 7, 3, 45, 28, 15, 2, 19, 24, 3, 13, 15, 30, - 1, 5, 107, 28, 10, 1, 46, 28, 1, 15, 22, 28, 2, 17, 14, 28, - 5, 1, 120, 30, 9, 4, 43, 26, 17, 1, 22, 28, 2, 19, 14, 28, - 3, 4, 113, 28, 3, 11, 44, 26, 17, 4, 21, 26, 9, 16, 13, 26, - 3, 5, 107, 28, 3, 13, 41, 26, 15, 5, 24, 30, 15, 10, 15, 28, - 4, 4, 116, 28, 17, 0, 42, 26, 17, 6, 22, 28, 19, 6, 16, 30, - 2, 7, 111, 28, 17, 0, 46, 28, 7, 16, 24, 30, 34, 0, 13, 24, - 4, 5, 121, 30, 4, 14, 47, 28, 11, 14, 24, 30, 16, 14, 15, 30, - 6, 4, 117, 30, 6, 14, 45, 28, 11, 16, 24, 30, 30, 2, 16, 30, - 8, 4, 106, 26, 8, 13, 47, 28, 7, 22, 24, 30, 22, 13, 15, 30, - 10, 2, 114, 28, 19, 4, 46, 28, 28, 6, 22, 28, 33, 4, 16, 30, - 8, 4, 122, 30, 22, 3, 45, 28, 8, 26, 23, 30, 12, 28, 15, 30, - 3, 10, 117, 30, 3, 23, 45, 28, 4, 31, 24, 30, 11, 31, 15, 30, - 7, 7, 116, 30, 21, 7, 45, 28, 1, 37, 23, 30, 19, 26, 15, 30, - 5, 10, 115, 30, 19, 10, 47, 28, 15, 25, 24, 30, 23, 25, 15, 30, - 13, 3, 115, 30, 2, 29, 46, 28, 42, 1, 24, 30, 23, 28, 15, 30, - 17, 0, 115, 30, 10, 23, 46, 28, 10, 35, 24, 30, 19, 35, 15, 30, - 17, 1, 115, 30, 14, 21, 46, 28, 29, 19, 24, 30, 11, 46, 15, 30, - 13, 6, 115, 30, 14, 23, 46, 28, 44, 7, 24, 30, 59, 1, 16, 30, - 12, 7, 121, 30, 12, 26, 47, 28, 39, 14, 24, 30, 22, 41, 15, 30, - 6, 14, 121, 30, 6, 34, 47, 28, 46, 10, 24, 30, 2, 64, 15, 30, - 17, 4, 122, 30, 29, 14, 46, 28, 49, 10, 24, 30, 24, 46, 15, 30, - 4, 18, 122, 30, 13, 32, 46, 28, 48, 14, 24, 30, 42, 32, 15, 30, - 20, 4, 117, 30, 40, 7, 47, 28, 43, 22, 24, 30, 10, 67, 15, 30, - 19, 6, 118, 30, 18, 31, 47, 28, 34, 34, 24, 30, 20, 61, 15, 30 - ]; - // Map of human-readable ECC levels. - var ECC_LEVELS = { - L: 1, - M: 2, - Q: 3, - H: 4 - }; - // Final format bits with mask (level << 3 | mask). - var FINAL_FORMAT = [ - 0x77c4, 0x72f3, 0x7daa, 0x789d, 0x662f, 0x6318, 0x6c41, 0x6976, /* L */ - 0x5412, 0x5125, 0x5e7c, 0x5b4b, 0x45f9, 0x40ce, 0x4f97, 0x4aa0, /* M */ - 0x355f, 0x3068, 0x3f31, 0x3a06, 0x24b4, 0x2183, 0x2eda, 0x2bed, /* Q */ - 0x1689, 0x13be, 0x1ce7, 0x19d0, 0x0762, 0x0255, 0x0d0c, 0x083b /* H */ - ]; - // Galois field exponent table. - var GALOIS_EXPONENT = [ - 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1d, 0x3a, 0x74, 0xe8, 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x32, 0x64, 0xc8, 0x8d, 0x07, 0x0e, 0x1c, 0x38, 0x70, 0xe0, 0xdd, 0xa7, 0x53, 0xa6, - 0x51, 0xa2, 0x59, 0xb2, 0x79, 0xf2, 0xf9, 0xef, 0xc3, 0x9b, 0x2b, 0x56, 0xac, 0x45, 0x8a, 0x09, - 0x12, 0x24, 0x48, 0x90, 0x3d, 0x7a, 0xf4, 0xf5, 0xf7, 0xf3, 0xfb, 0xeb, 0xcb, 0x8b, 0x0b, 0x16, - 0x2c, 0x58, 0xb0, 0x7d, 0xfa, 0xe9, 0xcf, 0x83, 0x1b, 0x36, 0x6c, 0xd8, 0xad, 0x47, 0x8e, 0x00 - ]; - // Galois field log table. - var GALOIS_LOG = [ - 0xff, 0x00, 0x01, 0x19, 0x02, 0x32, 0x1a, 0xc6, 0x03, 0xdf, 0x33, 0xee, 0x1b, 0x68, 0xc7, 0x4b, - 0x04, 0x64, 0xe0, 0x0e, 0x34, 0x8d, 0xef, 0x81, 0x1c, 0xc1, 0x69, 0xf8, 0xc8, 0x08, 0x4c, 0x71, - 0x05, 0x8a, 0x65, 0x2f, 0xe1, 0x24, 0x0f, 0x21, 0x35, 0x93, 0x8e, 0xda, 0xf0, 0x12, 0x82, 0x45, - 0x1d, 0xb5, 0xc2, 0x7d, 0x6a, 0x27, 0xf9, 0xb9, 0xc9, 0x9a, 0x09, 0x78, 0x4d, 0xe4, 0x72, 0xa6, - 0x06, 0xbf, 0x8b, 0x62, 0x66, 0xdd, 0x30, 0xfd, 0xe2, 0x98, 0x25, 0xb3, 0x10, 0x91, 0x22, 0x88, - 0x36, 0xd0, 0x94, 0xce, 0x8f, 0x96, 0xdb, 0xbd, 0xf1, 0xd2, 0x13, 0x5c, 0x83, 0x38, 0x46, 0x40, - 0x1e, 0x42, 0xb6, 0xa3, 0xc3, 0x48, 0x7e, 0x6e, 0x6b, 0x3a, 0x28, 0x54, 0xfa, 0x85, 0xba, 0x3d, - 0xca, 0x5e, 0x9b, 0x9f, 0x0a, 0x15, 0x79, 0x2b, 0x4e, 0xd4, 0xe5, 0xac, 0x73, 0xf3, 0xa7, 0x57, - 0x07, 0x70, 0xc0, 0xf7, 0x8c, 0x80, 0x63, 0x0d, 0x67, 0x4a, 0xde, 0xed, 0x31, 0xc5, 0xfe, 0x18, - 0xe3, 0xa5, 0x99, 0x77, 0x26, 0xb8, 0xb4, 0x7c, 0x11, 0x44, 0x92, 0xd9, 0x23, 0x20, 0x89, 0x2e, - 0x37, 0x3f, 0xd1, 0x5b, 0x95, 0xbc, 0xcf, 0xcd, 0x90, 0x87, 0x97, 0xb2, 0xdc, 0xfc, 0xbe, 0x61, - 0xf2, 0x56, 0xd3, 0xab, 0x14, 0x2a, 0x5d, 0x9e, 0x84, 0x3c, 0x39, 0x53, 0x47, 0x6d, 0x41, 0xa2, - 0x1f, 0x2d, 0x43, 0xd8, 0xb7, 0x7b, 0xa4, 0x76, 0xc4, 0x17, 0x49, 0xec, 0x7f, 0x0c, 0x6f, 0xf6, - 0x6c, 0xa1, 0x3b, 0x52, 0x29, 0x9d, 0x55, 0xaa, 0xfb, 0x60, 0x86, 0xb1, 0xbb, 0xcc, 0x3e, 0x5a, - 0xcb, 0x59, 0x5f, 0xb0, 0x9c, 0xa9, 0xa0, 0x51, 0x0b, 0xf5, 0x16, 0xeb, 0x7a, 0x75, 0x2c, 0xd7, - 0x4f, 0xae, 0xd5, 0xe9, 0xe6, 0xe7, 0xad, 0xe8, 0x74, 0xd6, 0xf4, 0xea, 0xa8, 0x50, 0x58, 0xaf - ]; - // *Badness* coefficients. - var N1 = 3; - var N2 = 3; - var N3 = 40; - var N4 = 10; - // Version pattern. - var VERSION_BLOCK = [ - 0xc94, 0x5bc, 0xa99, 0x4d3, 0xbf6, 0x762, 0x847, 0x60d, 0x928, 0xb78, 0x45d, 0xa17, 0x532, - 0x9a6, 0x683, 0x8c9, 0x7ec, 0xec4, 0x1e1, 0xfab, 0x08e, 0xc1a, 0x33f, 0xd75, 0x250, 0x9d5, - 0x6f0, 0x8ba, 0x79f, 0xb0b, 0x42e, 0xa64, 0x541, 0xc69 - ]; - // Mode for node.js file system file writes. - var WRITE_MODE = parseInt('0666', 8); - - // Private variables - // ----------------- - - // Run lengths for badness. - var badBuffer = []; - // Constructor for `canvas` elements in the node.js environment. - var Canvas; - // Data block. - var dataBlock; - // ECC data blocks and tables. - var eccBlock, neccBlock1, neccBlock2; - // ECC buffer. - var eccBuffer = []; - // ECC level (defaults to **L**). - var eccLevel = 1; - // Image buffer. - var frameBuffer = []; - // Fixed part of the image. - var frameMask = []; - // File system within the node.js environment. - var fs; - // Constructor for `img` elements in the node.js environment. - var Image; - // Indicates whether or not this script is running in node.js. - var inNode = false; - // Generator polynomial. - var polynomial = []; - // Save the previous value of the `qr` variable. - var previousQr = root.qr; - // Data input buffer. - var stringBuffer = []; - // Version for the data. - var version; - // Data width is based on `version`. - var width; - - // Private functions - // ----------------- - - // Create a new canvas using `document.createElement` unless script is running in node.js, in - // which case the `canvas` module is used. - function createCanvas() { - return inNode ? new Canvas() : root.document.createElement('canvas'); - } - - // Create a new image using `document.createElement` unless script is running in node.js, in - // which case the `canvas` module is used. - function createImage() { - return inNode ? new Image() : root.document.createElement('img'); - } - - // Force the canvas image to be downloaded in the browser. - // Optionally, a `callback` function can be specified which will be called upon completed. Since - // this is not an asynchronous operation, this is merely convenient and helps simplify the - // calling code. - function download(cvs, data, callback) { - var mime = data.mime || DEFAULT_MIME; - - root.location.href = cvs.toDataURL(mime).replace(mime, DOWNLOAD_MIME); - - if (typeof callback === 'function') callback(); - } - - // Normalize the `data` that is provided to the main API. - function normalizeData(data) { - if (typeof data === 'string') data = { value: data }; - return data || {}; - } - - // Override the `qr` API methods that require HTML5 canvas support to throw a relevant error. - function overrideAPI(qr) { - var methods = [ 'canvas', 'image', 'save', 'saveSync', 'toDataURL' ]; - var i; - - function overrideMethod(name) { - qr[name] = function () { - throw new Error(name + ' requires HTML5 canvas element support'); - }; - } - - for (i = 0; i < methods.length; i++) { - overrideMethod(methods[i]); - } - } - - // Asynchronously write the data of the rendered canvas to a given file path. - function writeFile(cvs, data, callback) { - if (typeof data.path !== 'string') { - return callback(new TypeError('Invalid path type: ' + typeof data.path)); - } - - var fd, buff; - - // Write the buffer to the open file stream once both prerequisites are met. - function writeBuffer() { - fs.write(fd, buff, 0, buff.length, 0, function (error) { - fs.close(fd); - - callback(error); - }); - } - - // Create a buffer of the canvas' data. - cvs.toBuffer(function (error, _buff) { - if (error) return callback(error); - - buff = _buff; - if (fd) { - writeBuffer(); - } - }); - - // Open a stream for the file to be written. - fs.open(data.path, 'w', WRITE_MODE, function (error, _fd) { - if (error) return callback(error); - - fd = _fd; - if (buff) { - writeBuffer(); - } - }); - } - - // Write the data of the rendered canvas to a given file path. - function writeFileSync(cvs, data) { - if (typeof data.path !== 'string') { - throw new TypeError('Invalid path type: ' + typeof data.path); - } - - var buff = cvs.toBuffer(); - var fd = fs.openSync(data.path, 'w', WRITE_MODE); - - try { - fs.writeSync(fd, buff, 0, buff.length, 0); - } finally { - fs.closeSync(fd); - } - } - - // Set bit to indicate cell in frame is immutable (symmetric around diagonal). - function setMask(x, y) { - var bit; - - if (x > y) { - bit = x; - x = y; - y = bit; - } - - bit = y; - bit *= y; - bit += y; - bit >>= 1; - bit += x; - - frameMask[bit] = 1; - } - - // Enter alignment pattern. Foreground colour to frame, background to mask. Frame will be merged - // with mask later. - function addAlignment(x, y) { - var i; - - frameBuffer[x + width * y] = 1; - - for (i = -2; i < 2; i++) { - frameBuffer[(x + i) + width * (y - 2)] = 1; - frameBuffer[(x - 2) + width * (y + i + 1)] = 1; - frameBuffer[(x + 2) + width * (y + i)] = 1; - frameBuffer[(x + i + 1) + width * (y + 2)] = 1; - } - - for (i = 0; i < 2; i++) { - setMask(x - 1, y + i); - setMask(x + 1, y - i); - setMask(x - i, y - 1); - setMask(x + i, y + 1); - } - } - - // Exponentiation mod N. - function modN(x) { - while (x >= 255) { - x -= 255; - x = (x >> 8) + (x & 255); - } - - return x; - } - - // Calculate and append `ecc` data to the `data` block. If block is in the string buffer the - // indices to buffers are used. - function appendData(data, dataLength, ecc, eccLength) { - var bit, i, j; - - for (i = 0; i < eccLength; i++) { - stringBuffer[ecc + i] = 0; - } - - for (i = 0; i < dataLength; i++) { - bit = GALOIS_LOG[stringBuffer[data + i] ^ stringBuffer[ecc]]; - - if (bit !== 255) { - for (j = 1; j < eccLength; j++) { - stringBuffer[ecc + j - 1] = stringBuffer[ecc + j] ^ - GALOIS_EXPONENT[modN(bit + polynomial[eccLength - j])]; - } - } else { - for (j = ecc; j < ecc + eccLength; j++) { - stringBuffer[j] = stringBuffer[j + 1]; - } - } - - stringBuffer[ecc + eccLength - 1] = bit === 255 ? 0 : - GALOIS_EXPONENT[modN(bit + polynomial[0])]; - } - } - - // Check mask since symmetricals use half. - function isMasked(x, y) { - var bit; - - if (x > y) { - bit = x; - x = y; - y = bit; - } - - bit = y; - bit += y * y; - bit >>= 1; - bit += x; - - return frameMask[bit] === 1; - } - - // Apply the selected mask out of the 8 options. - function applyMask(mask) { - var x, y, r3x, r3y; - - switch (mask) { - case 0: - for (y = 0; y < width; y++) { - for (x = 0; x < width; x++) { - if (!((x + y) & 1) && !isMasked(x, y)) { - frameBuffer[x + y * width] ^= 1; - } - } - } - - break; - case 1: - for (y = 0; y < width; y++) { - for (x = 0; x < width; x++) { - if (!(y & 1) && !isMasked(x, y)) { - frameBuffer[x + y * width] ^= 1; - } - } - } - - break; - case 2: - for (y = 0; y < width; y++) { - for (r3x = 0, x = 0; x < width; x++, r3x++) { - if (r3x === 3) r3x = 0; - - if (!r3x && !isMasked(x, y)) { - frameBuffer[x + y * width] ^= 1; - } - } - } - - break; - case 3: - for (r3y = 0, y = 0; y < width; y++, r3y++) { - if (r3y === 3) r3y = 0; - - for (r3x = r3y, x = 0; x < width; x++, r3x++) { - if (r3x === 3) r3x = 0; - - if (!r3x && !isMasked(x, y)) { - frameBuffer[x + y * width] ^= 1; - } - } - } - - break; - case 4: - for (y = 0; y < width; y++) { - for (r3x = 0, r3y = ((y >> 1) & 1), x = 0; x < width; x++, r3x++) { - if (r3x === 3) { - r3x = 0; - r3y = !r3y; - } - - if (!r3y && !isMasked(x, y)) { - frameBuffer[x + y * width] ^= 1; - } - } - } - - break; - case 5: - for (r3y = 0, y = 0; y < width; y++, r3y++) { - if (r3y === 3) r3y = 0; - - for (r3x = 0, x = 0; x < width; x++, r3x++) { - if (r3x === 3) r3x = 0; - - if (!((x & y & 1) + !(!r3x | !r3y)) && !isMasked(x, y)) { - frameBuffer[x + y * width] ^= 1; - } - } - } - - break; - case 6: - for (r3y = 0, y = 0; y < width; y++, r3y++) { - if (r3y === 3) r3y = 0; - - for (r3x = 0, x = 0; x < width; x++, r3x++) { - if (r3x === 3) r3x = 0; - - if (!(((x & y & 1) + (r3x && (r3x === r3y))) & 1) && !isMasked(x, y)) { - frameBuffer[x + y * width] ^= 1; - } - } - } - - break; - case 7: - for (r3y = 0, y = 0; y < width; y++, r3y++) { - if (r3y === 3) r3y = 0; - - for (r3x = 0, x = 0; x < width; x++, r3x++) { - if (r3x === 3) r3x = 0; - - if (!(((r3x && (r3x === r3y)) + ((x + y) & 1)) & 1) && !isMasked(x, y)) { - frameBuffer[x + y * width] ^= 1; - } - } - } - - break; - } - } - - // Using the table for the length of each run, calculate the amount of bad image. Long runs or - // those that look like finders are called twice; once for X and Y. - function getBadRuns(length) { - var badRuns = 0; - var i; - - for (i = 0; i <= length; i++) { - if (badBuffer[i] >= 5) { - badRuns += N1 + badBuffer[i] - 5; - } - } - - // FBFFFBF as in finder. - for (i = 3; i < length - 1; i += 2) { - if (badBuffer[i - 2] === badBuffer[i + 2] && - badBuffer[i + 2] === badBuffer[i - 1] && - badBuffer[i - 1] === badBuffer[i + 1] && - badBuffer[i - 1] * 3 === badBuffer[i] && - // Background around the foreground pattern? Not part of the specs. - (badBuffer[i - 3] === 0 || i + 3 > length || - badBuffer[i - 3] * 3 >= badBuffer[i] * 4 || - badBuffer[i + 3] * 3 >= badBuffer[i] * 4)) { - badRuns += N3; - } - } - - return badRuns; - } - - // Calculate how bad the masked image is (e.g. blocks, imbalance, runs, or finders). - function checkBadness() { - var b, b1, bad, big, bw, count, h, x, y; - bad = bw = count = 0; - - // Blocks of same colour. - for (y = 0; y < width - 1; y++) { - for (x = 0; x < width - 1; x++) { - // All foreground colour. - if ((frameBuffer[x + width * y] && - frameBuffer[(x + 1) + width * y] && - frameBuffer[x + width * (y + 1)] && - frameBuffer[(x + 1) + width * (y + 1)]) || - // All background colour. - !(frameBuffer[x + width * y] || - frameBuffer[(x + 1) + width * y] || - frameBuffer[x + width * (y + 1)] || - frameBuffer[(x + 1) + width * (y + 1)])) { - bad += N2; - } - } - } - - // X runs. - for (y = 0; y < width; y++) { - badBuffer[0] = 0; - - for (h = b = x = 0; x < width; x++) { - if ((b1 = frameBuffer[x + width * y]) === b) { - badBuffer[h]++; - } else { - badBuffer[++h] = 1; - } - - b = b1; - bw += b ? 1 : -1; - } - - bad += getBadRuns(h); - } - - if (bw < 0) bw = -bw; - - big = bw; - big += big << 2; - big <<= 1; - - while (big > width * width) { - big -= width * width; - count++; - } - - bad += count * N4; - - // Y runs. - for (x = 0; x < width; x++) { - badBuffer[0] = 0; - - for (h = b = y = 0; y < width; y++) { - if ((b1 = frameBuffer[x + width * y]) === b) { - badBuffer[h]++; - } else { - badBuffer[++h] = 1; - } - - b = b1; - } - - bad += getBadRuns(h); - } - - return bad; - } - - // Generate the encoded QR image for the string provided. - function generateFrame(str) { - var i, j, k, m, t, v, x, y; - - // Find the smallest version that fits the string. - t = str.length; - - version = 0; - - do { - version++; - - k = (eccLevel - 1) * 4 + (version - 1) * 16; - - neccBlock1 = ECC_BLOCKS[k++]; - neccBlock2 = ECC_BLOCKS[k++]; - dataBlock = ECC_BLOCKS[k++]; - eccBlock = ECC_BLOCKS[k]; - - k = dataBlock * (neccBlock1 + neccBlock2) + neccBlock2 - 3 + (version <= 9); - - if (t <= k) break; - } while (version < 40); - - // FIXME: Ensure that it fits insted of being truncated. - width = 17 + 4 * version; - - // Allocate, clear and setup data structures. - v = dataBlock + (dataBlock + eccBlock) * (neccBlock1 + neccBlock2) + neccBlock2; - - for (t = 0; t < v; t++) { - eccBuffer[t] = 0; - } - - stringBuffer = str.slice(0); - - for (t = 0; t < width * width; t++) { - frameBuffer[t] = 0; - } - - for (t = 0; t < (width * (width + 1) + 1) / 2; t++) { - frameMask[t] = 0; - } - - // Insert finders: Foreground colour to frame and background to mask. - for (t = 0; t < 3; t++) { - k = y = 0; - - if (t === 1) k = (width - 7); - if (t === 2) y = (width - 7); - - frameBuffer[(y + 3) + width * (k + 3)] = 1; - - for (x = 0; x < 6; x++) { - frameBuffer[(y + x) + width * k] = 1; - frameBuffer[y + width * (k + x + 1)] = 1; - frameBuffer[(y + 6) + width * (k + x)] = 1; - frameBuffer[(y + x + 1) + width * (k + 6)] = 1; - } - - for (x = 1; x < 5; x++) { - setMask(y + x, k + 1); - setMask(y + 1, k + x + 1); - setMask(y + 5, k + x); - setMask(y + x + 1, k + 5); - } - - for (x = 2; x < 4; x++) { - frameBuffer[(y + x) + width * (k + 2)] = 1; - frameBuffer[(y + 2) + width * (k + x + 1)] = 1; - frameBuffer[(y + 4) + width * (k + x)] = 1; - frameBuffer[(y + x + 1) + width * (k + 4)] = 1; - } - } - - // Alignment blocks. - if (version > 1) { - t = ALIGNMENT_DELTA[version]; - y = width - 7; - - for (;;) { - x = width - 7; - - while (x > t - 3) { - addAlignment(x, y); - - if (x < t) break; - - x -= t; - } - - if (y <= t + 9) break; - - y -= t; - - addAlignment(6, y); - addAlignment(y, 6); - } - } - - // Single foreground cell. - frameBuffer[8 + width * (width - 8)] = 1; - - // Timing gap (mask only). - for (y = 0; y < 7; y++) { - setMask(7, y); - setMask(width - 8, y); - setMask(7, y + width - 7); - } - - for (x = 0; x < 8; x++) { - setMask(x, 7); - setMask(x + width - 8, 7); - setMask(x, width - 8); - } - - // Reserve mask, format area. - for (x = 0; x < 9; x++) { - setMask(x, 8); - } - - for (x = 0; x < 8; x++) { - setMask(x + width - 8, 8); - setMask(8, x); - } - - for (y = 0; y < 7; y++) { - setMask(8, y + width - 7); - } - - // Timing row/column. - for (x = 0; x < width - 14; x++) { - if (x & 1) { - setMask(8 + x, 6); - setMask(6, 8 + x); - } else { - frameBuffer[(8 + x) + width * 6] = 1; - frameBuffer[6 + width * (8 + x)] = 1; - } - } - - // Version block. - if (version > 6) { - t = VERSION_BLOCK[version - 7]; - k = 17; - - for (x = 0; x < 6; x++) { - for (y = 0; y < 3; y++, k--) { - if (1 & (k > 11 ? version >> (k - 12) : t >> k)) { - frameBuffer[(5 - x) + width * (2 - y + width - 11)] = 1; - frameBuffer[(2 - y + width - 11) + width * (5 - x)] = 1; - } else { - setMask(5 - x, 2 - y + width - 11); - setMask(2 - y + width - 11, 5 - x); - } - } - } - } - - // Sync mask bits. Only set above for background cells, so now add the foreground. - for (y = 0; y < width; y++) { - for (x = 0; x <= y; x++) { - if (frameBuffer[x + width * y]) { - setMask(x, y); - } - } - } - - // Convert string to bit stream. 8-bit data to QR-coded 8-bit data (numeric, alphanum, or kanji - // not supported). - v = stringBuffer.length; - - // String to array. - for (i = 0; i < v; i++) { - eccBuffer[i] = stringBuffer.charCodeAt(i); - } - - stringBuffer = eccBuffer.slice(0); - - // Calculate max string length. - x = dataBlock * (neccBlock1 + neccBlock2) + neccBlock2; - - if (v >= x - 2) { - v = x - 2; - - if (version > 9) v--; - } - - // Shift and re-pack to insert length prefix. - i = v; - - if (version > 9) { - stringBuffer[i + 2] = 0; - stringBuffer[i + 3] = 0; - - while (i--) { - t = stringBuffer[i]; - - stringBuffer[i + 3] |= 255 & (t << 4); - stringBuffer[i + 2] = t >> 4; - } - - stringBuffer[2] |= 255 & (v << 4); - stringBuffer[1] = v >> 4; - stringBuffer[0] = 0x40 | (v >> 12); - } else { - stringBuffer[i + 1] = 0; - stringBuffer[i + 2] = 0; - - while (i--) { - t = stringBuffer[i]; - - stringBuffer[i + 2] |= 255 & (t << 4); - stringBuffer[i + 1] = t >> 4; - } - - stringBuffer[1] |= 255 & (v << 4); - stringBuffer[0] = 0x40 | (v >> 4); - } - - // Fill to end with pad pattern. - i = v + 3 - (version < 10); - - while (i < x) { - stringBuffer[i++] = 0xec; - stringBuffer[i++] = 0x11; - } - - // Calculate generator polynomial. - polynomial[0] = 1; - - for (i = 0; i < eccBlock; i++) { - polynomial[i + 1] = 1; - - for (j = i; j > 0; j--) { - polynomial[j] = polynomial[j] ? polynomial[j - 1] ^ - GALOIS_EXPONENT[modN(GALOIS_LOG[polynomial[j]] + i)] : polynomial[j - 1]; - } - - polynomial[0] = GALOIS_EXPONENT[modN(GALOIS_LOG[polynomial[0]] + i)]; - } - - // Use logs for generator polynomial to save calculation step. - for (i = 0; i <= eccBlock; i++) { - polynomial[i] = GALOIS_LOG[polynomial[i]]; - } - - // Append ECC to data buffer. - k = x; - y = 0; - - for (i = 0; i < neccBlock1; i++) { - appendData(y, dataBlock, k, eccBlock); - - y += dataBlock; - k += eccBlock; - } - - for (i = 0; i < neccBlock2; i++) { - appendData(y, dataBlock + 1, k, eccBlock); - - y += dataBlock + 1; - k += eccBlock; - } - - // Interleave blocks. - y = 0; - - for (i = 0; i < dataBlock; i++) { - for (j = 0; j < neccBlock1; j++) { - eccBuffer[y++] = stringBuffer[i + j * dataBlock]; - } - - for (j = 0; j < neccBlock2; j++) { - eccBuffer[y++] = stringBuffer[(neccBlock1 * dataBlock) + i + (j * (dataBlock + 1))]; - } - } - - for (j = 0; j < neccBlock2; j++) { - eccBuffer[y++] = stringBuffer[(neccBlock1 * dataBlock) + i + (j * (dataBlock + 1))]; - } - - for (i = 0; i < eccBlock; i++) { - for (j = 0; j < neccBlock1 + neccBlock2; j++) { - eccBuffer[y++] = stringBuffer[x + i + j * eccBlock]; - } - } - - stringBuffer = eccBuffer; - - // Pack bits into frame avoiding masked area. - x = y = width - 1; - k = v = 1; - - // inteleaved data and ECC codes. - m = (dataBlock + eccBlock) * (neccBlock1 + neccBlock2) + neccBlock2; - - for (i = 0; i < m; i++) { - t = stringBuffer[i]; - - for (j = 0; j < 8; j++, t <<= 1) { - if (0x80 & t) { - frameBuffer[x + width * y] = 1; - } - - // Find next fill position. - do { - if (v) { - x--; - } else { - x++; - - if (k) { - if (y !== 0) { - y--; - } else { - x -= 2; - k = !k; - - if (x === 6) { - x--; - y = 9; - } - } - } else { - if (y !== width - 1) { - y++; - } else { - x -= 2; - k = !k; - - if (x === 6) { - x--; - y -= 8; - } - } - } - } - - v = !v; - } while (isMasked(x, y)); - } - } - - // Save pre-mask copy of frame. - stringBuffer = frameBuffer.slice(0); - - t = 0; - y = 30000; - - // Using `for` instead of `while` since in original Arduino code if an early mask was *good - // enough* it wouldn't try for a better one since they get more complex and take longer. - for (k = 0; k < 8; k++) { - // Returns foreground-background imbalance. - applyMask(k); - - x = checkBadness(); - - // Is current mask better than previous best? - if (x < y) { - y = x; - t = k; - } - - // Don't increment `i` to a void redoing mask. - if (t === 7) break; - - // Reset for next pass. - frameBuffer = stringBuffer.slice(0); - } - - // Redo best mask as none were *good enough* (i.e. last wasn't `t`). - if (t !== k) { - applyMask(t); - } - - // Add in final mask/ECC level bytes. - y = FINAL_FORMAT[t + ((eccLevel - 1) << 3)]; - - // Low byte. - for (k = 0; k < 8; k++, y >>= 1) { - if (y & 1) { - frameBuffer[(width - 1 - k) + width * 8] = 1; - - if (k < 6) { - frameBuffer[8 + width * k] = 1; - } else { - frameBuffer[8 + width * (k + 1)] = 1; - } - } - } - - // High byte. - for (k = 0; k < 7; k++, y >>= 1) { - if (y & 1) { - frameBuffer[8 + width * (width - 7 + k)] = 1; - - if (k) { - frameBuffer[(6 - k) + width * 8] = 1; - } else { - frameBuffer[7 + width * 8] = 1; - } - } - } - - // Finally, return the image data. - return frameBuffer; - } - - // qr.js setup - // ----------- - - // Build the publicly exposed API. - var qr = { - - // Constants - // --------- - - // Current version of `qr`. - VERSION: '1.1.4', - - // QR functions - // ------------ - - // Generate the QR code using the data provided and render it on to a `` element. - // If no `` element is specified in the argument provided a new one will be created and - // used. - // ECC (error correction capacity) determines how many intential errors are contained in the QR - // code. - canvas: function(data) { - data = normalizeData(data); - - // Module size of the generated QR code (i.e. 1-10). - var size = data.size >= 1 && data.size <= 10 ? data.size : 4; - // Actual size of the QR code symbol and is scaled to 25 pixels (e.g. 1 = 25px, 3 = 75px). - size *= 25; - - // `` element used to render the QR code. - var cvs = data.canvas || createCanvas(); - // Retreive the 2D context of the canvas. - var c2d = cvs.getContext('2d'); - // Ensure the canvas has the correct dimensions. - c2d.canvas.width = size; - c2d.canvas.height = size; - // Fill the canvas with the correct background colour. - c2d.fillStyle = data.background || '#fff'; - c2d.fillRect(0, 0, size, size); - - // Determine the ECC level to be applied. - eccLevel = ECC_LEVELS[(data.level && data.level.toUpperCase()) || 'L']; - - // Generate the image frame for the given `value`. - var frame = generateFrame(data.value || ''); - - c2d.lineWidth = 1; - - // Determine the *pixel* size. - var px = size; - px /= width; - px = Math.floor(px); - - var offset = Math.floor((size - (px * width)) / 2); - - // Draw the QR code. - c2d.clearRect(0, 0, size, size); - c2d.fillStyle = data.background || '#fff'; - c2d.fillRect(0, 0, size, size); - c2d.fillStyle = data.foreground || '#000'; - - var i, j; - - for (i = 0; i < width; i++) { - for (j = 0; j < width; j++) { - if (frame[j * width + i]) { - c2d.fillRect(px * i + offset, px * j + offset, px, px); - } - } - } - - return cvs; - }, - - // Generate the QR code using the data provided and render it on to a `` element. - // If no `` element is specified in the argument provided a new one will be created and - // used. - // ECC (error correction capacity) determines how many intential errors are contained in the QR - // code. - image: function(data) { - data = normalizeData(data); - - // `` element only which the QR code is rendered. - var cvs = this.canvas(data); - // `` element used to display the QR code. - var img = data.image || createImage(); - - // Apply the QR code to `img`. - img.src = cvs.toDataURL(data.mime || DEFAULT_MIME); - img.height = cvs.height; - img.width = cvs.width; - - return img; - }, - - // Generate the QR code using the data provided and render it on to a `` element and - // save it as an image file. - // If no `` element is specified in the argument provided a new one will be created and - // used. - // ECC (error correction capacity) determines how many intential errors are contained in the QR - // code. - // If called in a browser the `path` property/argument is ignored and will simply prompt the - // user to choose a location and file name. However, if called within node.js the file will be - // saved to specified path. - // A `callback` function must be provided which will be called once the saving process has - // started. If an error occurs it will be passed as the first argument to this function, - // otherwise this argument will be `null`. - save: function(data, path, callback) { - data = normalizeData(data); - - switch (typeof path) { - case 'function': - callback = path; - path = null; - break; - case 'string': - data.path = path; - break; - } - - // Callback function is required. - if (typeof callback !== 'function') { - throw new TypeError('Invalid callback type: ' + typeof callback); - } - - var completed = false; - // `` element only which the QR code is rendered. - var cvs = this.canvas(data); - - // Simple function to try and ensure that the `callback` function is only called once. - function done(error) { - if (!completed) { - completed = true; - - callback(error); - } - } - - if (inNode) { - writeFile(cvs, data, done); - } else { - download(cvs, data, done); - } - }, - - // Generate the QR code using the data provided and render it on to a `` element and - // save it as an image file. - // If no `` element is specified in the argument provided a new one will be created and - // used. - // ECC (error correction capacity) determines how many intential errors are contained in the QR - // code. - // If called in a browser the `path` property/argument is ignored and will simply prompt the - // user to choose a location and file name. However, if called within node.js the file will be - // saved to specified path. - saveSync: function(data, path) { - data = normalizeData(data); - - if (typeof path === 'string') data.path = path; - - // `` element only which the QR code is rendered. - var cvs = this.canvas(data); - - if (inNode) { - writeFileSync(cvs, data); - } else { - download(cvs, data); - } - }, - - // Generate the QR code using the data provided and render it on to a `` element before - // returning its data URI. - // If no `` element is specified in the argument provided a new one will be created and - // used. - // ECC (error correction capacity) determines how many intential errors are contained in the QR - // code. - toDataURL: function(data) { - data = normalizeData(data); - - return this.canvas(data).toDataURL(data.mime || DEFAULT_MIME); - }, - - // Utility functions - // ----------------- - - // Run qr.js in *noConflict* mode, returning the `qr` variable to its previous owner. - // Returns a reference to `qr`. - noConflict: function() { - root.qr = previousQr; - return this; - } - - }; - - // Support - // ------- - - // Export `qr` for node.js and CommonJS. - if (typeof exports !== 'undefined') { - inNode = true; - - if (typeof module !== 'undefined' && module.exports) { - exports = module.exports = qr; - } - exports.qr = qr; - - // Import required node.js modules. - Canvas = require('canvas'); - Image = Canvas.Image; - fs = require('fs'); - } else if (typeof define === 'function' && define.amd) { - define(function () { - return qr; - }); - } else { - // In non-HTML5 browser so strip base functionality. - if (!root.HTMLCanvasElement) { - overrideAPI(qr); - } - - root.qr = qr; - } - -})(this); diff --git a/qr.min.js b/qr.min.js deleted file mode 100644 index 01d79b2..0000000 --- a/qr.min.js +++ /dev/null @@ -1,5 +0,0 @@ -/*! qr-js v1.1.4 | (c) 2015 Alasdair Mercer | GPL v3 License -jsqrencode | (c) 2010 tz@execpc.com | GPL v3 License -*/ -!function(a){"use strict";function b(){return T?new r:a.document.createElement("canvas")}function c(){return T?new x:a.document.createElement("img")}function d(b,c,d){var e=c.mime||B;a.location.href=b.toDataURL(e).replace(e,C),"function"==typeof d&&d()}function e(a){return"string"==typeof a&&(a={value:a}),a||{}}function f(a){function b(b){a[b]=function(){throw new Error(b+" requires HTML5 canvas element support")}}var c,d=["canvas","image","save","saveSync","toDataURL"];for(c=0;cb&&(c=a,a=b,b=c),c=b,c*=b,c+=b,c>>=1,c+=a,S[c]=1}function j(a,b){var c;for(R[a+z*b]=1,c=-2;2>c;c++)R[a+c+z*(b-2)]=1,R[a-2+z*(b+c+1)]=1,R[a+2+z*(b+c)]=1,R[a+c+1+z*(b+2)]=1;for(c=0;2>c;c++)i(a-1,b+c),i(a+1,b-c),i(a-c,b-1),i(a+c,b+1)}function k(a){for(;a>=255;)a-=255,a=(a>>8)+(255&a);return a}function l(a,b,c,d){var e,f,g;for(f=0;d>f;f++)W[c+f]=0;for(f=0;b>f;f++){if(e=H[W[a+f]^W[c]],255!==e)for(g=1;d>g;g++)W[c+g-1]=W[c+g]^G[k(e+U[d-g])];else for(g=c;c+d>g;g++)W[g]=W[g+1];W[c+d-1]=255===e?0:G[k(e+U[0])]}}function m(a,b){var c;return a>b&&(c=a,a=b,b=c),c=b,c+=b*b,c>>=1,c+=a,1===S[c]}function n(a){var b,c,d,e;switch(a){case 0:for(c=0;z>c;c++)for(b=0;z>b;b++)b+c&1||m(b,c)||(R[b+c*z]^=1);break;case 1:for(c=0;z>c;c++)for(b=0;z>b;b++)1&c||m(b,c)||(R[b+c*z]^=1);break;case 2:for(c=0;z>c;c++)for(d=0,b=0;z>b;b++,d++)3===d&&(d=0),d||m(b,c)||(R[b+c*z]^=1);break;case 3:for(e=0,c=0;z>c;c++,e++)for(3===e&&(e=0),d=e,b=0;z>b;b++,d++)3===d&&(d=0),d||m(b,c)||(R[b+c*z]^=1);break;case 4:for(c=0;z>c;c++)for(d=0,e=c>>1&1,b=0;z>b;b++,d++)3===d&&(d=0,e=!e),e||m(b,c)||(R[b+c*z]^=1);break;case 5:for(e=0,c=0;z>c;c++,e++)for(3===e&&(e=0),d=0,b=0;z>b;b++,d++)3===d&&(d=0),(b&c&1)+!(!d|!e)||m(b,c)||(R[b+c*z]^=1);break;case 6:for(e=0,c=0;z>c;c++,e++)for(3===e&&(e=0),d=0,b=0;z>b;b++,d++)3===d&&(d=0),(b&c&1)+(d&&d===e)&1||m(b,c)||(R[b+c*z]^=1);break;case 7:for(e=0,c=0;z>c;c++,e++)for(3===e&&(e=0),d=0,b=0;z>b;b++,d++)3===d&&(d=0),(d&&d===e)+(b+c&1)&1||m(b,c)||(R[b+c*z]^=1)}}function o(a){var b,c=0;for(b=0;a>=b;b++)O[b]>=5&&(c+=I+O[b]-5);for(b=3;a-1>b;b+=2)O[b-2]===O[b+2]&&O[b+2]===O[b-1]&&O[b-1]===O[b+1]&&3*O[b-1]===O[b]&&(0===O[b-3]||b+3>a||3*O[b-3]>=4*O[b]||3*O[b+3]>=4*O[b])&&(c+=K);return c}function p(){var a,b,c,d,e,f,g,h,i;for(c=e=f=0,i=0;z-1>i;i++)for(h=0;z-1>h;h++)(R[h+z*i]&&R[h+1+z*i]&&R[h+z*(i+1)]&&R[h+1+z*(i+1)]||!(R[h+z*i]||R[h+1+z*i]||R[h+z*(i+1)]||R[h+1+z*(i+1)]))&&(c+=J);for(i=0;z>i;i++){for(O[0]=0,g=a=h=0;z>h;h++)(b=R[h+z*i])===a?O[g]++:O[++g]=1,a=b,e+=a?1:-1;c+=o(g)}for(0>e&&(e=-e),d=e,d+=d<<2,d<<=1;d>z*z;)d-=z*z,f++;for(c+=f*L,h=0;z>h;h++){for(O[0]=0,g=a=i=0;z>i;i++)(b=R[h+z*i])===a?O[g]++:O[++g]=1,a=b;c+=o(g)}return c}function q(a){var b,c,d,e,f,g,h,o;f=a.length,y=0;do if(y++,d=4*(Q-1)+16*(y-1),u=D[d++],v=D[d++],s=D[d++],t=D[d],d=s*(u+v)+v-3+(9>=y),d>=f)break;while(40>y);for(z=17+4*y,g=s+(s+t)*(u+v)+v,f=0;g>f;f++)P[f]=0;for(W=a.slice(0),f=0;z*z>f;f++)R[f]=0;for(f=0;(z*(z+1)+1)/2>f;f++)S[f]=0;for(f=0;3>f;f++){for(d=o=0,1===f&&(d=z-7),2===f&&(o=z-7),R[o+3+z*(d+3)]=1,h=0;6>h;h++)R[o+h+z*d]=1,R[o+z*(d+h+1)]=1,R[o+6+z*(d+h)]=1,R[o+h+1+z*(d+6)]=1;for(h=1;5>h;h++)i(o+h,d+1),i(o+1,d+h+1),i(o+5,d+h),i(o+h+1,d+5);for(h=2;4>h;h++)R[o+h+z*(d+2)]=1,R[o+2+z*(d+h+1)]=1,R[o+4+z*(d+h)]=1,R[o+h+1+z*(d+4)]=1}if(y>1)for(f=A[y],o=z-7;;){for(h=z-7;h>f-3&&(j(h,o),!(f>h));)h-=f;if(f+9>=o)break;o-=f,j(6,o),j(o,6)}for(R[8+z*(z-8)]=1,o=0;7>o;o++)i(7,o),i(z-8,o),i(7,o+z-7);for(h=0;8>h;h++)i(h,7),i(h+z-8,7),i(h,z-8);for(h=0;9>h;h++)i(h,8);for(h=0;8>h;h++)i(h+z-8,8),i(8,h);for(o=0;7>o;o++)i(8,o+z-7);for(h=0;z-14>h;h++)1&h?(i(8+h,6),i(6,8+h)):(R[8+h+6*z]=1,R[6+z*(8+h)]=1);if(y>6)for(f=M[y-7],d=17,h=0;6>h;h++)for(o=0;3>o;o++,d--)1&(d>11?y>>d-12:f>>d)?(R[5-h+z*(2-o+z-11)]=1,R[2-o+z-11+z*(5-h)]=1):(i(5-h,2-o+z-11),i(2-o+z-11,5-h));for(o=0;z>o;o++)for(h=0;o>=h;h++)R[h+z*o]&&i(h,o);for(g=W.length,b=0;g>b;b++)P[b]=W.charCodeAt(b);if(W=P.slice(0),h=s*(u+v)+v,g>=h-2&&(g=h-2,y>9&&g--),b=g,y>9){for(W[b+2]=0,W[b+3]=0;b--;)f=W[b],W[b+3]|=255&f<<4,W[b+2]=f>>4;W[2]|=255&g<<4,W[1]=g>>4,W[0]=64|g>>12}else{for(W[b+1]=0,W[b+2]=0;b--;)f=W[b],W[b+2]|=255&f<<4,W[b+1]=f>>4;W[1]|=255&g<<4,W[0]=64|g>>4}for(b=g+3-(10>y);h>b;)W[b++]=236,W[b++]=17;for(U[0]=1,b=0;t>b;b++){for(U[b+1]=1,c=b;c>0;c--)U[c]=U[c]?U[c-1]^G[k(H[U[c]]+b)]:U[c-1];U[0]=G[k(H[U[0]]+b)]}for(b=0;t>=b;b++)U[b]=H[U[b]];for(d=h,o=0,b=0;u>b;b++)l(o,s,d,t),o+=s,d+=t;for(b=0;v>b;b++)l(o,s+1,d,t),o+=s+1,d+=t;for(o=0,b=0;s>b;b++){for(c=0;u>c;c++)P[o++]=W[b+c*s];for(c=0;v>c;c++)P[o++]=W[u*s+b+c*(s+1)]}for(c=0;v>c;c++)P[o++]=W[u*s+b+c*(s+1)];for(b=0;t>b;b++)for(c=0;u+v>c;c++)P[o++]=W[h+b+c*t];for(W=P,h=o=z-1,d=g=1,e=(s+t)*(u+v)+v,b=0;e>b;b++)for(f=W[b],c=0;8>c;c++,f<<=1){128&f&&(R[h+z*o]=1);do g?h--:(h++,d?0!==o?o--:(h-=2,d=!d,6===h&&(h--,o=9)):o!==z-1?o++:(h-=2,d=!d,6===h&&(h--,o-=8))),g=!g;while(m(h,o))}for(W=R.slice(0),f=0,o=3e4,d=0;8>d&&(n(d),h=p(),o>h&&(o=h,f=d),7!==f);d++)R=W.slice(0);for(f!==d&&n(f),o=F[f+(Q-1<<3)],d=0;8>d;d++,o>>=1)1&o&&(R[z-1-d+8*z]=1,6>d?R[8+z*d]=1:R[8+z*(d+1)]=1);for(d=0;7>d;d++,o>>=1)1&o&&(R[8+z*(z-7+d)]=1,d?R[6-d+8*z]=1:R[7+8*z]=1);return R}var r,s,t,u,v,w,x,y,z,A=[0,11,15,19,23,27,31,16,18,20,22,24,26,28,20,22,24,24,26,28,28,22,24,24,26,26,28,28,24,24,26,26,26,28,28,24,26,26,26,28,28],B="image/png",C="image/octet-stream",D=[1,0,19,7,1,0,16,10,1,0,13,13,1,0,9,17,1,0,34,10,1,0,28,16,1,0,22,22,1,0,16,28,1,0,55,15,1,0,44,26,2,0,17,18,2,0,13,22,1,0,80,20,2,0,32,18,2,0,24,26,4,0,9,16,1,0,108,26,2,0,43,24,2,2,15,18,2,2,11,22,2,0,68,18,4,0,27,16,4,0,19,24,4,0,15,28,2,0,78,20,4,0,31,18,2,4,14,18,4,1,13,26,2,0,97,24,2,2,38,22,4,2,18,22,4,2,14,26,2,0,116,30,3,2,36,22,4,4,16,20,4,4,12,24,2,2,68,18,4,1,43,26,6,2,19,24,6,2,15,28,4,0,81,20,1,4,50,30,4,4,22,28,3,8,12,24,2,2,92,24,6,2,36,22,4,6,20,26,7,4,14,28,4,0,107,26,8,1,37,22,8,4,20,24,12,4,11,22,3,1,115,30,4,5,40,24,11,5,16,20,11,5,12,24,5,1,87,22,5,5,41,24,5,7,24,30,11,7,12,24,5,1,98,24,7,3,45,28,15,2,19,24,3,13,15,30,1,5,107,28,10,1,46,28,1,15,22,28,2,17,14,28,5,1,120,30,9,4,43,26,17,1,22,28,2,19,14,28,3,4,113,28,3,11,44,26,17,4,21,26,9,16,13,26,3,5,107,28,3,13,41,26,15,5,24,30,15,10,15,28,4,4,116,28,17,0,42,26,17,6,22,28,19,6,16,30,2,7,111,28,17,0,46,28,7,16,24,30,34,0,13,24,4,5,121,30,4,14,47,28,11,14,24,30,16,14,15,30,6,4,117,30,6,14,45,28,11,16,24,30,30,2,16,30,8,4,106,26,8,13,47,28,7,22,24,30,22,13,15,30,10,2,114,28,19,4,46,28,28,6,22,28,33,4,16,30,8,4,122,30,22,3,45,28,8,26,23,30,12,28,15,30,3,10,117,30,3,23,45,28,4,31,24,30,11,31,15,30,7,7,116,30,21,7,45,28,1,37,23,30,19,26,15,30,5,10,115,30,19,10,47,28,15,25,24,30,23,25,15,30,13,3,115,30,2,29,46,28,42,1,24,30,23,28,15,30,17,0,115,30,10,23,46,28,10,35,24,30,19,35,15,30,17,1,115,30,14,21,46,28,29,19,24,30,11,46,15,30,13,6,115,30,14,23,46,28,44,7,24,30,59,1,16,30,12,7,121,30,12,26,47,28,39,14,24,30,22,41,15,30,6,14,121,30,6,34,47,28,46,10,24,30,2,64,15,30,17,4,122,30,29,14,46,28,49,10,24,30,24,46,15,30,4,18,122,30,13,32,46,28,48,14,24,30,42,32,15,30,20,4,117,30,40,7,47,28,43,22,24,30,10,67,15,30,19,6,118,30,18,31,47,28,34,34,24,30,20,61,15,30],E={L:1,M:2,Q:3,H:4},F=[30660,29427,32170,30877,26159,25368,27713,26998,21522,20773,24188,23371,17913,16590,20375,19104,13663,12392,16177,14854,9396,8579,11994,11245,5769,5054,7399,6608,1890,597,3340,2107],G=[1,2,4,8,16,32,64,128,29,58,116,232,205,135,19,38,76,152,45,90,180,117,234,201,143,3,6,12,24,48,96,192,157,39,78,156,37,74,148,53,106,212,181,119,238,193,159,35,70,140,5,10,20,40,80,160,93,186,105,210,185,111,222,161,95,190,97,194,153,47,94,188,101,202,137,15,30,60,120,240,253,231,211,187,107,214,177,127,254,225,223,163,91,182,113,226,217,175,67,134,17,34,68,136,13,26,52,104,208,189,103,206,129,31,62,124,248,237,199,147,59,118,236,197,151,51,102,204,133,23,46,92,184,109,218,169,79,158,33,66,132,21,42,84,168,77,154,41,82,164,85,170,73,146,57,114,228,213,183,115,230,209,191,99,198,145,63,126,252,229,215,179,123,246,241,255,227,219,171,75,150,49,98,196,149,55,110,220,165,87,174,65,130,25,50,100,200,141,7,14,28,56,112,224,221,167,83,166,81,162,89,178,121,242,249,239,195,155,43,86,172,69,138,9,18,36,72,144,61,122,244,245,247,243,251,235,203,139,11,22,44,88,176,125,250,233,207,131,27,54,108,216,173,71,142,0],H=[255,0,1,25,2,50,26,198,3,223,51,238,27,104,199,75,4,100,224,14,52,141,239,129,28,193,105,248,200,8,76,113,5,138,101,47,225,36,15,33,53,147,142,218,240,18,130,69,29,181,194,125,106,39,249,185,201,154,9,120,77,228,114,166,6,191,139,98,102,221,48,253,226,152,37,179,16,145,34,136,54,208,148,206,143,150,219,189,241,210,19,92,131,56,70,64,30,66,182,163,195,72,126,110,107,58,40,84,250,133,186,61,202,94,155,159,10,21,121,43,78,212,229,172,115,243,167,87,7,112,192,247,140,128,99,13,103,74,222,237,49,197,254,24,227,165,153,119,38,184,180,124,17,68,146,217,35,32,137,46,55,63,209,91,149,188,207,205,144,135,151,178,220,252,190,97,242,86,211,171,20,42,93,158,132,60,57,83,71,109,65,162,31,45,67,216,183,123,164,118,196,23,73,236,127,12,111,246,108,161,59,82,41,157,85,170,251,96,134,177,187,204,62,90,203,89,95,176,156,169,160,81,11,245,22,235,122,117,44,215,79,174,213,233,230,231,173,232,116,214,244,234,168,80,88,175],I=3,J=3,K=40,L=10,M=[3220,1468,2713,1235,3062,1890,2119,1549,2344,2936,1117,2583,1330,2470,1667,2249,2028,3780,481,4011,142,3098,831,3445,592,2517,1776,2234,1951,2827,1070,2660,1345,3177],N=parseInt("0666",8),O=[],P=[],Q=1,R=[],S=[],T=!1,U=[],V=a.qr,W=[],X={VERSION:"1.1.4",canvas:function(a){a=e(a);var c=a.size>=1&&a.size<=10?a.size:4;c*=25;var d=a.canvas||b(),f=d.getContext("2d");f.canvas.width=c,f.canvas.height=c,f.fillStyle=a.background||"#fff",f.fillRect(0,0,c,c),Q=E[a.level&&a.level.toUpperCase()||"L"];var g=q(a.value||"");f.lineWidth=1;var h=c;h/=z,h=Math.floor(h);var i=Math.floor((c-h*z)/2);f.clearRect(0,0,c,c),f.fillStyle=a.background||"#fff",f.fillRect(0,0,c,c),f.fillStyle=a.foreground||"#000";var j,k;for(j=0;z>j;j++)for(k=0;z>k;k++)g[k*z+j]&&f.fillRect(h*j+i,h*k+i,h,h);return d},image:function(a){a=e(a);var b=this.canvas(a),d=a.image||c();return d.src=b.toDataURL(a.mime||B),d.height=b.height,d.width=b.width,d},save:function(a,b,c){function f(a){h||(h=!0,c(a))}switch(a=e(a),typeof b){case"function":c=b,b=null;break;case"string":a.path=b}if("function"!=typeof c)throw new TypeError("Invalid callback type: "+typeof c);var h=!1,i=this.canvas(a);T?g(i,a,f):d(i,a,f)},saveSync:function(a,b){a=e(a),"string"==typeof b&&(a.path=b);var c=this.canvas(a);T?h(c,a):d(c,a)},toDataURL:function(a){return a=e(a),this.canvas(a).toDataURL(a.mime||B)},noConflict:function(){return a.qr=V,this}};"undefined"!=typeof exports?(T=!0,"undefined"!=typeof module&&module.exports&&(exports=module.exports=X),exports.qr=X,r=require("canvas"),x=r.Image,w=require("fs")):"function"==typeof define&&define.amd?define(function(){return X}):(a.HTMLCanvasElement||f(X),a.qr=X)}(this); -//# sourceMappingURL=qr.min.map \ No newline at end of file diff --git a/qr.min.map b/qr.min.map deleted file mode 100644 index 7886d1e..0000000 --- a/qr.min.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["qr.js"],"names":["root","createCanvas","inNode","Canvas","document","createElement","createImage","Image","download","cvs","data","callback","mime","DEFAULT_MIME","location","href","toDataURL","replace","DOWNLOAD_MIME","normalizeData","value","overrideAPI","qr","overrideMethod","name","Error","i","methods","length","writeFile","writeBuffer","fs","write","fd","buff","error","close","path","TypeError","toBuffer","_buff","open","WRITE_MODE","_fd","writeFileSync","openSync","writeSync","closeSync","setMask","x","y","bit","frameMask","addAlignment","frameBuffer","width","modN","appendData","dataLength","ecc","eccLength","j","stringBuffer","GALOIS_LOG","GALOIS_EXPONENT","polynomial","isMasked","applyMask","mask","r3x","r3y","getBadRuns","badRuns","badBuffer","N1","N3","checkBadness","b","b1","bad","big","bw","count","h","N2","N4","generateFrame","str","k","m","t","v","version","eccLevel","neccBlock1","ECC_BLOCKS","neccBlock2","dataBlock","eccBlock","eccBuffer","slice","ALIGNMENT_DELTA","VERSION_BLOCK","charCodeAt","FINAL_FORMAT","ECC_LEVELS","L","M","Q","H","parseInt","previousQr","VERSION","canvas","size","c2d","getContext","height","fillStyle","background","fillRect","level","toUpperCase","frame","lineWidth","px","Math","floor","offset","clearRect","foreground","image","this","img","src","save","done","completed","saveSync","noConflict","exports","module","require","define","amd","HTMLCanvasElement"],"mappings":";;;CASA,SAAWA,GAET,YAsKA,SAASC,KACP,MAAOC,GAAS,GAAIC,GAAWH,EAAKI,SAASC,cAAc,UAK7D,QAASC,KACP,MAAOJ,GAAS,GAAIK,GAAUP,EAAKI,SAASC,cAAc,OAO5D,QAASG,GAASC,EAAKC,EAAMC,GAC3B,GAAIC,GAAOF,EAAKE,MAAQC,CAExBb,GAAKc,SAASC,KAAON,EAAIO,UAAUJ,GAAMK,QAAQL,EAAMM,GAE/B,kBAAbP,IAAyBA,IAItC,QAASQ,GAAcT,GAErB,MADoB,gBAATA,KAAmBA,GAASU,MAAOV,IACvCA,MAIT,QAASW,GAAYC,GAInB,QAASC,GAAeC,GACtBF,EAAGE,GAAQ,WACT,KAAM,IAAIC,OAAMD,EAAO,2CAL3B,GACIE,GADAC,GAAY,SAAU,QAAS,OAAQ,WAAY,YASvD,KAAKD,EAAI,EAAGA,EAAIC,EAAQC,OAAQF,IAC9BH,EAAeI,EAAQD,IAK3B,QAASG,GAAUpB,EAAKC,EAAMC,GAQ5B,QAASmB,KACPC,EAAGC,MAAMC,EAAIC,EAAM,EAAGA,EAAKN,OAAQ,EAAG,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GAGzD,IAAI8H,IAAY,EAEZhI,EAAM2H,KAAKnB,OAAOvG,EAWlBR,GACF2B,EAAUpB,EAAKC,EAAM8H,GAErBhI,EAASC,EAAKC,EAAM8H,IAaxBE,SAAU,SAAShI,EAAM2B,GACvB3B,EAAOS,EAAcT,GAED,gBAAT2B,KAAmB3B,EAAK2B,KAAOA,EAG1C,IAAI5B,GAAM2H,KAAKnB,OAAOvG,EAElBR,GACF0C,EAAcnC,EAAKC,GAEnBF,EAASC,EAAKC,IAUlBM,UAAW,SAASN,GAGlB,MAFAA,GAAOS,EAAcT,GAEd0H,KAAKnB,OAAOvG,GAAMM,UAAUN,EAAKE,MAAQC,IAQlD8H,WAAY,WAEV,MADA3I,GAAKsB,GAAKyF,EACHqB,MASY,oBAAZQ,UACT1I,GAAS,EAEa,mBAAX2I,SAA0BA,OAAOD,UAC1CA,QAAUC,OAAOD,QAAUtH,GAE7BsH,QAAQtH,GAAKA,EAGbnB,EAAS2I,QAAQ,UACjBvI,EAAQJ,EAAOI,MACfwB,EAAK+G,QAAQ,OACc,kBAAXC,SAAyBA,OAAOC,IAChDD,OAAO,WACL,MAAOzH,MAIJtB,EAAKiJ,mBACR5H,EAAYC,GAGdtB,EAAKsB,GAAKA,IAGX8G","file":"qr.min.js"} \ No newline at end of file diff --git a/src/Alignment.js b/src/Alignment.js new file mode 100644 index 0000000..08bc867 --- /dev/null +++ b/src/Alignment.js @@ -0,0 +1,45 @@ +/* + * QRious + * Copyright (C) 2016 Alasdair Mercer + * Copyright (C) 2010 Tom Zerucha + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* eslint no-multi-spaces: 0 */ + +/** + * Contains alignment pattern information. + * + * @public + */ +class Alignment { + + /** + * Returns the alignment pattern block. + * + * @return {Number[]} The alignment pattern block. + * @public + * @static + */ + static get BLOCK() { + return [ + 0, 11, 15, 19, 23, 27, 31, + 16, 18, 20, 22, 24, 26, 28, 20, 22, 24, 24, 26, 28, 28, 22, 24, 24, + 26, 26, 28, 28, 24, 24, 26, 26, 26, 28, 28, 24, 26, 26, 26, 28, 28 + ] + } +} + +export default Alignment diff --git a/src/ErrorCorrection.js b/src/ErrorCorrection.js new file mode 100644 index 0000000..d7e4dbc --- /dev/null +++ b/src/ErrorCorrection.js @@ -0,0 +1,121 @@ +/* + * QRious + * Copyright (C) 2016 Alasdair Mercer + * Copyright (C) 2010 Tom Zerucha + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* eslint no-multi-spaces: 0 */ + +/** + * Contains error correction information. + * + * @public + */ +class ErrorCorrection { + + /** + * Returns the error correction blocks. + * + * There are four elements per version. The first two indicate the number of blocks, then the data width, and finally + * the ECC width. + * + * @return {Number[]} The ECC blocks. + * @public + * @static + */ + static get BLOCKS() { + return [ + 1, 0, 19, 7, 1, 0, 16, 10, 1, 0, 13, 13, 1, 0, 9, 17, + 1, 0, 34, 10, 1, 0, 28, 16, 1, 0, 22, 22, 1, 0, 16, 28, + 1, 0, 55, 15, 1, 0, 44, 26, 2, 0, 17, 18, 2, 0, 13, 22, + 1, 0, 80, 20, 2, 0, 32, 18, 2, 0, 24, 26, 4, 0, 9, 16, + 1, 0, 108, 26, 2, 0, 43, 24, 2, 2, 15, 18, 2, 2, 11, 22, + 2, 0, 68, 18, 4, 0, 27, 16, 4, 0, 19, 24, 4, 0, 15, 28, + 2, 0, 78, 20, 4, 0, 31, 18, 2, 4, 14, 18, 4, 1, 13, 26, + 2, 0, 97, 24, 2, 2, 38, 22, 4, 2, 18, 22, 4, 2, 14, 26, + 2, 0, 116, 30, 3, 2, 36, 22, 4, 4, 16, 20, 4, 4, 12, 24, + 2, 2, 68, 18, 4, 1, 43, 26, 6, 2, 19, 24, 6, 2, 15, 28, + 4, 0, 81, 20, 1, 4, 50, 30, 4, 4, 22, 28, 3, 8, 12, 24, + 2, 2, 92, 24, 6, 2, 36, 22, 4, 6, 20, 26, 7, 4, 14, 28, + 4, 0, 107, 26, 8, 1, 37, 22, 8, 4, 20, 24, 12, 4, 11, 22, + 3, 1, 115, 30, 4, 5, 40, 24, 11, 5, 16, 20, 11, 5, 12, 24, + 5, 1, 87, 22, 5, 5, 41, 24, 5, 7, 24, 30, 11, 7, 12, 24, + 5, 1, 98, 24, 7, 3, 45, 28, 15, 2, 19, 24, 3, 13, 15, 30, + 1, 5, 107, 28, 10, 1, 46, 28, 1, 15, 22, 28, 2, 17, 14, 28, + 5, 1, 120, 30, 9, 4, 43, 26, 17, 1, 22, 28, 2, 19, 14, 28, + 3, 4, 113, 28, 3, 11, 44, 26, 17, 4, 21, 26, 9, 16, 13, 26, + 3, 5, 107, 28, 3, 13, 41, 26, 15, 5, 24, 30, 15, 10, 15, 28, + 4, 4, 116, 28, 17, 0, 42, 26, 17, 6, 22, 28, 19, 6, 16, 30, + 2, 7, 111, 28, 17, 0, 46, 28, 7, 16, 24, 30, 34, 0, 13, 24, + 4, 5, 121, 30, 4, 14, 47, 28, 11, 14, 24, 30, 16, 14, 15, 30, + 6, 4, 117, 30, 6, 14, 45, 28, 11, 16, 24, 30, 30, 2, 16, 30, + 8, 4, 106, 26, 8, 13, 47, 28, 7, 22, 24, 30, 22, 13, 15, 30, + 10, 2, 114, 28, 19, 4, 46, 28, 28, 6, 22, 28, 33, 4, 16, 30, + 8, 4, 122, 30, 22, 3, 45, 28, 8, 26, 23, 30, 12, 28, 15, 30, + 3, 10, 117, 30, 3, 23, 45, 28, 4, 31, 24, 30, 11, 31, 15, 30, + 7, 7, 116, 30, 21, 7, 45, 28, 1, 37, 23, 30, 19, 26, 15, 30, + 5, 10, 115, 30, 19, 10, 47, 28, 15, 25, 24, 30, 23, 25, 15, 30, + 13, 3, 115, 30, 2, 29, 46, 28, 42, 1, 24, 30, 23, 28, 15, 30, + 17, 0, 115, 30, 10, 23, 46, 28, 10, 35, 24, 30, 19, 35, 15, 30, + 17, 1, 115, 30, 14, 21, 46, 28, 29, 19, 24, 30, 11, 46, 15, 30, + 13, 6, 115, 30, 14, 23, 46, 28, 44, 7, 24, 30, 59, 1, 16, 30, + 12, 7, 121, 30, 12, 26, 47, 28, 39, 14, 24, 30, 22, 41, 15, 30, + 6, 14, 121, 30, 6, 34, 47, 28, 46, 10, 24, 30, 2, 64, 15, 30, + 17, 4, 122, 30, 29, 14, 46, 28, 49, 10, 24, 30, 24, 46, 15, 30, + 4, 18, 122, 30, 13, 32, 46, 28, 48, 14, 24, 30, 42, 32, 15, 30, + 20, 4, 117, 30, 40, 7, 47, 28, 43, 22, 24, 30, 10, 67, 15, 30, + 19, 6, 118, 30, 18, 31, 47, 28, 34, 34, 24, 30, 20, 61, 15, 30 + ] + } + + /** + * Returns the final format bits with mask (level << 3 | mask). + * + * @return {Number[]} The final format bits. + * @public + * @static + */ + static get FINAL_FORMAT() { + return [ + // L + 0x77c4, 0x72f3, 0x7daa, 0x789d, 0x662f, 0x6318, 0x6c41, 0x6976, + // M + 0x5412, 0x5125, 0x5e7c, 0x5b4b, 0x45f9, 0x40ce, 0x4f97, 0x4aa0, + // Q + 0x355f, 0x3068, 0x3f31, 0x3a06, 0x24b4, 0x2183, 0x2eda, 0x2bed, + // H + 0x1689, 0x13be, 0x1ce7, 0x19d0, 0x0762, 0x0255, 0x0d0c, 0x083b + ] + } + + /** + * Returns a map of human-readable ECC levels. + * + * @return {Object} A ECC level mapping. + * @public + * @static + */ + static get LEVELS() { + return { + L: 1, + M: 2, + Q: 3, + H: 4 + } + } +} + +export default ErrorCorrection diff --git a/src/Frame.js b/src/Frame.js new file mode 100644 index 0000000..b9256b0 --- /dev/null +++ b/src/Frame.js @@ -0,0 +1,869 @@ +/* + * QRious + * Copyright (C) 2016 Alasdair Mercer + * Copyright (C) 2010 Tom Zerucha + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +import Alignment from './Alignment' +import ErrorCorrection from './ErrorCorrection' +import Galois from './Galois' +import Version from './Version' + +/** + * Generates information for a QR code frame based on a specific value to be encoded. + * + * @public + */ +class Frame { + + static _createArray(length) { + const array = [] + + for (let i = 0; i < length; i++) { + array[i] = 0 + } + + return array + } + + static _getMaskBit(x, y) { + let bit + + if (x > y) { + bit = x + x = y + y = bit + } + + bit = y + bit += y * y + bit >>= 1 + bit += x + + return bit + } + + static _modN(x) { + while (x >= 255) { + x -= 255 + x = (x >> 8) + (x & 255) + } + + return x + } + + // *Badness* coefficients. + static get N1() { + return 3 + } + static get N2() { + return 3 + } + static get N3() { + return 40 + } + static get N4() { + return 10 + } + + /** + * Creates an instance of {@link Frame} based on the options provided. + * + * @param {Frame~Options} options - the options to be used + * @public + */ + constructor(options) { + this._badness = [] + this._level = ErrorCorrection.LEVELS[options.level] + this._polynomial = [] + this._value = options.value + this._valueLength = this._value.length + this._version = 0 + this._stringBuffer = this._value.slice(0) + + let dataBlock + let eccBlock + let neccBlock1 + let neccBlock2 + + while (this._version < 40) { + this._version++ + + let index = (this._level - 1) * 4 + (this._version - 1) * 16 + + neccBlock1 = ErrorCorrection.BLOCKS[index++] + neccBlock2 = ErrorCorrection.BLOCKS[index++] + dataBlock = ErrorCorrection.BLOCKS[index++] + eccBlock = ErrorCorrection.BLOCKS[index] + + index = dataBlock * (neccBlock1 + neccBlock2) + neccBlock2 - 3 + (this._version <= 9) + + if (this._valueLength <= index) { + break + } + } + + this._dataBlock = dataBlock + this._eccBlock = eccBlock + this._neccBlock1 = neccBlock1 + this._neccBlock2 = neccBlock2 + + /** + * The data width is based on version. + * + * @public + * @type {Number} + */ + // FIXME: Ensure that it fits instead of being truncated. + this.width = 17 + 4 * this._version + + /** + * The image buffer. + * + * @public + * @type {Number[]} + */ + this.buffer = Frame._createArray(this.width * this.width) + + this._ecc = Frame._createArray(this._dataBlock + (this._dataBlock + this._eccBlock) * (this._neccBlock1 + this._neccBlock2) + this._neccBlock2) + this._mask = Frame._createArray((this.width * (this.width + 1) + 1) / 2) + + this._insertFinders() + this._insertAlignments() + + // Insert single foreground cell. + this.buffer[8 + this.width * (this.width - 8)] = 1 + + this._insertTimingGap() + this._reverseMask() + this._insertTimingRowAndColumn() + this._insertVersion() + this._syncMask() + this._convertBitStream(this._stringBuffer.length) + this._calculatePolynomial() + this._appendEccToData() + this._interleaveBlocks() + this._pack() + this._finish() + } + + _addAlignment(x, y) { + this.buffer[x + this.width * y] = 1 + + for (let i = -2; i < 2; i++) { + this.buffer[x + i + this.width * (y - 2)] = 1 + this.buffer[x - 2 + this.width * (y + i + 1)] = 1 + this.buffer[x + 2 + this.width * (y + i)] = 1 + this.buffer[x + i + 1 + this.width * (y + 2)] = 1 + } + + for (let i = 0; i < 2; i++) { + this._setMask(x - 1, y + i) + this._setMask(x + 1, y - i) + this._setMask(x - i, y - 1) + this._setMask(x + i, y + 1) + } + } + + _appendData(data, dataLength, ecc, eccLength) { + for (let i = 0; i < eccLength; i++) { + this._stringBuffer[ecc + i] = 0 + } + + for (let i = 0; i < dataLength; i++) { + const bit = Galois.LOG[this._stringBuffer[data + i] ^ this._stringBuffer[ecc]] + + if (bit !== 255) { + for (let j = 1; j < eccLength; j++) { + this._stringBuffer[ecc + j - 1] = this._stringBuffer[ecc + j] ^ Galois.EXPONENT[Frame._modN(bit + this._polynomial[eccLength - j])] + } + } else { + for (let j = ecc; j < ecc + eccLength; j++) { + this._stringBuffer[j] = this._stringBuffer[j + 1] + } + } + + this._stringBuffer[ecc + eccLength - 1] = bit === 255 ? 0 : Galois.EXPONENT[Frame._modN(bit + this._polynomial[0])] + } + } + + _appendEccToData() { + let data = 0 + let ecc = this._calculateMaxLength() + + for (let i = 0; i < this._neccBlock1; i++) { + this._appendData(data, this._dataBlock, ecc, this._eccBlock) + + data += this._dataBlock + ecc += this._eccBlock + } + + for (let i = 0; i < this._neccBlock2; i++) { + this._appendData(data, this._dataBlock + 1, ecc, this._eccBlock) + + data += this._dataBlock + 1 + ecc += this._eccBlock + } + } + + _applyMask(mask) { + const width = this.width + + switch (mask) { + case 0: + for (let y = 0; y < width; y++) { + for (let x = 0; x < width; x++) { + if (!(x + y & 1) && !this._isMasked(x, y)) { + this.buffer[x + y * width] ^= 1 + } + } + } + + break + case 1: + for (let y = 0; y < width; y++) { + for (let x = 0; x < width; x++) { + if (!(y & 1) && !this._isMasked(x, y)) { + this.buffer[x + y * width] ^= 1 + } + } + } + + break + case 2: + for (let y = 0; y < width; y++) { + for (let r3x = 0, x = 0; x < width; x++, r3x++) { + if (r3x === 3) { + r3x = 0 + } + + if (!r3x && !this._isMasked(x, y)) { + this.buffer[x + y * width] ^= 1 + } + } + } + + break + case 3: + for (let r3y = 0, y = 0; y < width; y++, r3y++) { + if (r3y === 3) { + r3y = 0 + } + + for (let r3x = r3y, x = 0; x < width; x++, r3x++) { + if (r3x === 3) { + r3x = 0 + } + + if (!r3x && !this._isMasked(x, y)) { + this.buffer[x + y * width] ^= 1 + } + } + } + + break + case 4: + for (let y = 0; y < width; y++) { + for (let r3x = 0, r3y = y >> 1 & 1, x = 0; x < width; x++, r3x++) { + if (r3x === 3) { + r3x = 0 + r3y = !r3y + } + + if (!r3y && !this._isMasked(x, y)) { + this.buffer[x + y * width] ^= 1 + } + } + } + + break + case 5: + for (let r3y = 0, y = 0; y < width; y++, r3y++) { + if (r3y === 3) { + r3y = 0 + } + + for (let r3x = 0, x = 0; x < width; x++, r3x++) { + if (r3x === 3) { + r3x = 0 + } + + if (!((x & y & 1) + !(!r3x | !r3y)) && !this._isMasked(x, y)) { + this.buffer[x + y * width] ^= 1 + } + } + } + + break + case 6: + for (let r3y = 0, y = 0; y < width; y++, r3y++) { + if (r3y === 3) { + r3y = 0 + } + + for (let r3x = 0, x = 0; x < width; x++, r3x++) { + if (r3x === 3) { + r3x = 0 + } + + if (!(x & y & 1 + (r3x && r3x === r3y) & 1) && !this._isMasked(x, y)) { + this.buffer[x + y * width] ^= 1 + } + } + } + + break + case 7: + for (let r3y = 0, y = 0; y < width; y++, r3y++) { + if (r3y === 3) { + r3y = 0 + } + + for (let r3x = 0, x = 0; x < width; x++, r3x++) { + if (r3x === 3) { + r3x = 0 + } + + if (!((r3x && r3x === r3y) + (x + y & 1) & 1) && !this._isMasked(x, y)) { + this.buffer[x + y * width] ^= 1 + } + } + } + + break + } + } + + _calculateMaxLength() { + return this._dataBlock * (this._neccBlock1 + this._neccBlock2) + this._neccBlock2 + } + + _calculatePolynomial() { + this._polynomial[0] = 1 + + for (let i = 0; i < this._eccBlock; i++) { + this._polynomial[i + 1] = 1 + + for (let j = i; j > 0; j--) { + this._polynomial[j] = this._polynomial[j] ? this._polynomial[j - 1] ^ Galois.EXPONENT[Frame._modN(Galois.LOG[this._polynomial[j]] + i)] : this._polynomial[j - 1] + } + + this._polynomial[0] = Galois.EXPONENT[Frame._modN(Galois.LOG[this._polynomial[0]] + i)] + } + + // Use logs for generator polynomial to save calculation step. + for (let i = 0; i <= this._eccBlock; i++) { + this._polynomial[i] = Galois.LOG[this._polynomial[i]] + } + } + + _checkBadness() { + let bad = 0 + const width = this.width + + // Blocks of same colour. + for (let y = 0; y < width - 1; y++) { + for (let x = 0; x < width - 1; x++) { + // All foreground colour. + if (this.buffer[x + width * y] && + this.buffer[x + 1 + width * y] && + this.buffer[x + width * (y + 1)] && + this.buffer[x + 1 + width * (y + 1)] || + // All background colour. + !(this.buffer[x + width * y] || + this.buffer[x + 1 + width * y] || + this.buffer[x + width * (y + 1)] || + this.buffer[x + 1 + width * (y + 1)])) { + bad += Frame.N2 + } + } + } + + let bw = 0 + + // X runs. + for (let y = 0; y < width; y++) { + let h = 0 + + this._badness[0] = 0 + + for (let b = 0, x = 0; x < width; x++) { + let b1 = this.buffer[x + width * y] + + if (b === b1) { + this._badness[h]++ + } else { + this._badness[++h] = 1 + } + + b = b1 + bw += b ? 1 : -1 + } + + bad += this._getBadness(h) + } + + if (bw < 0) { + bw = -bw + } + + let count = 0 + let big = bw + big += big << 2 + big <<= 1 + + while (big > width * width) { + big -= width * width + count++ + } + + bad += count * Frame.N4 + + // Y runs. + for (let x = 0; x < width; x++) { + let h = 0 + + this._badness[0] = 0 + + for (let b = 0, y = 0; y < width; y++) { + let b1 = this.buffer[x + width * y] + + if (b === b1) { + this._badness[h]++ + } else { + this._badness[++h] = 1 + } + + b = b1 + } + + bad += this._getBadness(h) + } + + return bad + } + + _convertBitStream(length) { + // Convert string to bit stream. 8-bit data to QR-coded 8-bit data (numeric, alphanum, or kanji + // not supported). + + for (let i = 0; i < length; i++) { + this._ecc[i] = this._stringBuffer.charCodeAt(i) + } + + this._stringBuffer = this._ecc.slice(0) + + const maxLength = this._calculateMaxLength() + + if (length >= maxLength - 2) { + length = maxLength - 2 + + if (this._version > 9) { + length-- + } + } + + // Shift and re-pack to insert length prefix. + let index = length + + if (this._version > 9) { + this._stringBuffer[index + 2] = 0 + this._stringBuffer[index + 3] = 0 + + while (index--) { + const bit = this._stringBuffer[index] + + this._stringBuffer[index + 3] |= 255 & bit << 4 + this._stringBuffer[index + 2] = bit >> 4 + } + + this._stringBuffer[2] |= 255 & length << 4 + this._stringBuffer[1] = length >> 4 + this._stringBuffer[0] = 0x40 | length >> 12 + } else { + this._stringBuffer[index + 1] = 0 + this._stringBuffer[index + 2] = 0 + + while (index--) { + const bit = this._stringBuffer[index] + + this._stringBuffer[index + 2] |= 255 & bit << 4 + this._stringBuffer[index + 1] = bit >> 4 + } + + this._stringBuffer[1] |= 255 & length << 4 + this._stringBuffer[0] = 0x40 | length >> 4 + } + + // Fill to end with pad pattern. + index = length + 3 - (this._version < 10) + + while (index < maxLength) { + this._stringBuffer[index++] = 0xec + this._stringBuffer[index++] = 0x11 + } + } + + _getBadness(length) { + let badRuns = 0 + + for (let i = 0; i <= length; i++) { + if (this._badness[i] >= 5) { + badRuns += Frame.N1 + this._badness[i] - 5 + } + } + + // FBFFFBF as in finder. + for (let i = 3; i < length - 1; i += 2) { + if (this._badness[i - 2] === this._badness[i + 2] && + this._badness[i + 2] === this._badness[i - 1] && + this._badness[i - 1] === this._badness[i + 1] && + this._badness[i - 1] * 3 === this._badness[i] && + // Background around the foreground pattern? Not part of the specs. + (this._badness[i - 3] === 0 || i + 3 > length || + this._badness[i - 3] * 3 >= this._badness[i] * 4 || + this._badness[i + 3] * 3 >= this._badness[i] * 4)) { + badRuns += Frame.N3 + } + } + + return badRuns + } + + _finish() { + // Save pre-mask copy of frame. + this._stringBuffer = this.buffer.slice(0) + + let bit = 0 + let i + let mask = 30000 + + /* + * Using for instead of while since in original Arduino code if an early mask was "good enough" it wouldn't try for + * a better one since they get more complex and take longer. + */ + for (i = 0; i < 8; i++) { + // Returns foreground-background imbalance. + this._applyMask(i) + + const currentMask = this._checkBadness() + + // Is current mask better than previous best? + if (currentMask < mask) { + mask = currentMask + bit = i + } + + // Don't increment "i" to a void redoing mask. + if (bit === 7) { + break + } + + // Reset for next pass. + this.buffer = this._stringBuffer.slice(0) + } + + // Redo best mask as none were "good enough" (i.e. last wasn't bit). + if (bit !== i) { + this._applyMask(bit) + } + + // Add in final mask/ECC level bytes. + mask = ErrorCorrection.FINAL_FORMAT[bit + (this._level - 1 << 3)] + + // Low byte. + for (i = 0; i < 8; i++, mask >>= 1) { + if (mask & 1) { + this.buffer[this.width - 1 - i + this.width * 8] = 1 + + if (i < 6) { + this.buffer[8 + this.width * i] = 1 + } else { + this.buffer[8 + this.width * (i + 1)] = 1 + } + } + } + + // High byte. + for (i = 0; i < 7; i++, mask >>= 1) { + if (mask & 1) { + this.buffer[8 + this.width * (this.width - 7 + i)] = 1 + + if (i) { + this.buffer[6 - i + this.width * 8] = 1 + } else { + this.buffer[7 + this.width * 8] = 1 + } + } + } + } + + _interleaveBlocks() { + const maxLength = this._calculateMaxLength() + let i + let k = 0 + + for (i = 0; i < this._dataBlock; i++) { + for (let j = 0; j < this._neccBlock1; j++) { + this._ecc[k++] = this._stringBuffer[i + j * this._dataBlock] + } + + for (let j = 0; j < this._neccBlock2; j++) { + this._ecc[k++] = this._stringBuffer[this._neccBlock1 * this._dataBlock + i + j * (this._dataBlock + 1)] + } + } + + for (let j = 0; j < this._neccBlock2; j++) { + this._ecc[k++] = this._stringBuffer[this._neccBlock1 * this._dataBlock + i + j * (this._dataBlock + 1)] + } + + for (i = 0; i < this._eccBlock; i++) { + for (let j = 0; j < this._neccBlock1 + this._neccBlock2; j++) { + this._ecc[k++] = this._stringBuffer[maxLength + i + j * this._eccBlock] + } + } + + this._stringBuffer = this._ecc + } + + _insertAlignments() { + const width = this.width + + if (this._version > 1) { + const i = Alignment.BLOCK[this._version] + let y = width - 7 + + for (;;) { + let x = width - 7 + + while (x > i - 3) { + this._addAlignment(x, y) + + if (x < i) { + break + } + + x -= i + } + + if (y <= i + 9) { + break + } + + y -= i + + this._addAlignment(6, y) + this._addAlignment(y, 6) + } + } + } + + _insertFinders() { + const width = this.width + + for (let i = 0; i < 3; i++) { + let j = 0 + let y = 0 + + if (i === 1) { + j = width - 7 + } + if (i === 2) { + y = width - 7 + } + + this.buffer[y + 3 + width * (j + 3)] = 1 + + for (let x = 0; x < 6; x++) { + this.buffer[y + x + width * j] = 1 + this.buffer[y + width * (j + x + 1)] = 1 + this.buffer[y + 6 + width * (j + x)] = 1 + this.buffer[y + x + 1 + width * (j + 6)] = 1 + } + + for (let x = 1; x < 5; x++) { + this._setMask(y + x, j + 1) + this._setMask(y + 1, j + x + 1) + this._setMask(y + 5, j + x) + this._setMask(y + x + 1, j + 5) + } + + for (let x = 2; x < 4; x++) { + this.buffer[y + x + width * (j + 2)] = 1 + this.buffer[y + 2 + width * (j + x + 1)] = 1 + this.buffer[y + 4 + width * (j + x)] = 1 + this.buffer[y + x + 1 + width * (j + 4)] = 1 + } + } + } + + _insertTimingGap() { + const width = this.width + + for (let y = 0; y < 7; y++) { + this._setMask(7, y) + this._setMask(width - 8, y) + this._setMask(7, y + width - 7) + } + + for (let x = 0; x < 8; x++) { + this._setMask(x, 7) + this._setMask(x + width - 8, 7) + this._setMask(x, width - 8) + } + } + + _insertTimingRowAndColumn() { + const width = this.width + + for (let x = 0; x < width - 14; x++) { + if (x & 1) { + this._setMask(8 + x, 6) + this._setMask(6, 8 + x) + } else { + this.buffer[8 + x + width * 6] = 1 + this.buffer[6 + width * (8 + x)] = 1 + } + } + } + + _insertVersion() { + const width = this.width + + if (this._version > 6) { + let i = Version.BLOCK[this._version - 7] + let j = 17 + + for (let x = 0; x < 6; x++) { + for (let y = 0; y < 3; y++, j--) { + if (1 & (j > 11 ? this._version >> j - 12 : i >> j)) { + this.buffer[5 - x + width * (2 - y + width - 11)] = 1 + this.buffer[2 - y + width - 11 + width * (5 - x)] = 1 + } else { + this._setMask(5 - x, 2 - y + width - 11) + this._setMask(2 - y + width - 11, 5 - x) + } + } + } + } + } + + _isMasked(x, y) { + const bit = Frame._getMaskBit(x, y) + + return this._mask[bit] === 1 + } + + _pack() { + let x = this.width - 1 + let y = this.width - 1 + let k = 1 + let v = 1 + + // Interleaved data and ECC codes. + const length = (this._dataBlock + this._eccBlock) * (this._neccBlock1 + this._neccBlock2) + this._neccBlock2 + + for (let i = 0; i < length; i++) { + let bit = this._stringBuffer[i] + + for (let j = 0; j < 8; j++, bit <<= 1) { + if (0x80 & bit) { + this.buffer[x + this.width * y] = 1 + } + + // Find next fill position. + do { + if (v) { + x-- + } else { + x++ + + if (k) { + if (y !== 0) { + y-- + } else { + x -= 2 + k = !k + + if (x === 6) { + x-- + y = 9 + } + } + } else if (y !== this.width - 1) { + y++ + } else { + x -= 2 + k = !k + + if (x === 6) { + x-- + y -= 8 + } + } + } + + v = !v + } while (this._isMasked(x, y)) + } + } + } + + _reverseMask() { + const width = this.width + + for (let x = 0; x < 9; x++) { + this._setMask(x, 8) + } + + for (let x = 0; x < 8; x++) { + this._setMask(x + width - 8, 8) + this._setMask(8, x) + } + + for (let y = 0; y < 7; y++) { + this._setMask(8, y + width - 7) + } + } + + _setMask(x, y) { + const bit = Frame._getMaskBit(x, y) + + this._mask[bit] = 1 + } + + _syncMask() { + const width = this.width + + for (let y = 0; y < width; y++) { + for (let x = 0; x <= y; x++) { + if (this.buffer[x + width * y]) { + this._setMask(x, y) + } + } + } + } +} + +export default Frame + +/** + * The options used by {@link Frame}. + * + * @typedef {Object} Frame~Options + * @property {String} level - The ECC level to be used. + * @property {String} value - The value to be encoded. + */ diff --git a/src/Galois.js b/src/Galois.js new file mode 100644 index 0000000..c854bc0 --- /dev/null +++ b/src/Galois.js @@ -0,0 +1,84 @@ +/* + * QRious + * Copyright (C) 2016 Alasdair Mercer + * Copyright (C) 2010 Tom Zerucha + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * Contains Galois field information. + * + * @public + */ +class Galois { + + /** + * Returns the Galois field exponent table. + * + * @return {Number[]} The Galois field exponent table. + * @public + * @static + */ + static get EXPONENT() { + return [ + 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x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a5, 0x57, 0xae, 0x41, + 0x82, 0x19, 0x32, 0x64, 0xc8, 0x8d, 0x07, 0x0e, 0x1c, 0x38, 0x70, 0xe0, 0xdd, 0xa7, 0x53, 0xa6, + 0x51, 0xa2, 0x59, 0xb2, 0x79, 0xf2, 0xf9, 0xef, 0xc3, 0x9b, 0x2b, 0x56, 0xac, 0x45, 0x8a, 0x09, + 0x12, 0x24, 0x48, 0x90, 0x3d, 0x7a, 0xf4, 0xf5, 0xf7, 0xf3, 0xfb, 0xeb, 0xcb, 0x8b, 0x0b, 0x16, + 0x2c, 0x58, 0xb0, 0x7d, 0xfa, 0xe9, 0xcf, 0x83, 0x1b, 0x36, 0x6c, 0xd8, 0xad, 0x47, 0x8e, 0x00 + ] + } + + /** + * Returns the Galois field log table. + * + * @return {Number[]} The Galois field log table. + * @public + * @static + */ + static get LOG() { + return [ + 0xff, 0x00, 0x01, 0x19, 0x02, 0x32, 0x1a, 0xc6, 0x03, 0xdf, 0x33, 0xee, 0x1b, 0x68, 0xc7, 0x4b, + 0x04, 0x64, 0xe0, 0x0e, 0x34, 0x8d, 0xef, 0x81, 0x1c, 0xc1, 0x69, 0xf8, 0xc8, 0x08, 0x4c, 0x71, + 0x05, 0x8a, 0x65, 0x2f, 0xe1, 0x24, 0x0f, 0x21, 0x35, 0x93, 0x8e, 0xda, 0xf0, 0x12, 0x82, 0x45, + 0x1d, 0xb5, 0xc2, 0x7d, 0x6a, 0x27, 0xf9, 0xb9, 0xc9, 0x9a, 0x09, 0x78, 0x4d, 0xe4, 0x72, 0xa6, + 0x06, 0xbf, 0x8b, 0x62, 0x66, 0xdd, 0x30, 0xfd, 0xe2, 0x98, 0x25, 0xb3, 0x10, 0x91, 0x22, 0x88, + 0x36, 0xd0, 0x94, 0xce, 0x8f, 0x96, 0xdb, 0xbd, 0xf1, 0xd2, 0x13, 0x5c, 0x83, 0x38, 0x46, 0x40, + 0x1e, 0x42, 0xb6, 0xa3, 0xc3, 0x48, 0x7e, 0x6e, 0x6b, 0x3a, 0x28, 0x54, 0xfa, 0x85, 0xba, 0x3d, + 0xca, 0x5e, 0x9b, 0x9f, 0x0a, 0x15, 0x79, 0x2b, 0x4e, 0xd4, 0xe5, 0xac, 0x73, 0xf3, 0xa7, 0x57, + 0x07, 0x70, 0xc0, 0xf7, 0x8c, 0x80, 0x63, 0x0d, 0x67, 0x4a, 0xde, 0xed, 0x31, 0xc5, 0xfe, 0x18, + 0xe3, 0xa5, 0x99, 0x77, 0x26, 0xb8, 0xb4, 0x7c, 0x11, 0x44, 0x92, 0xd9, 0x23, 0x20, 0x89, 0x2e, + 0x37, 0x3f, 0xd1, 0x5b, 0x95, 0xbc, 0xcf, 0xcd, 0x90, 0x87, 0x97, 0xb2, 0xdc, 0xfc, 0xbe, 0x61, + 0xf2, 0x56, 0xd3, 0xab, 0x14, 0x2a, 0x5d, 0x9e, 0x84, 0x3c, 0x39, 0x53, 0x47, 0x6d, 0x41, 0xa2, + 0x1f, 0x2d, 0x43, 0xd8, 0xb7, 0x7b, 0xa4, 0x76, 0xc4, 0x17, 0x49, 0xec, 0x7f, 0x0c, 0x6f, 0xf6, + 0x6c, 0xa1, 0x3b, 0x52, 0x29, 0x9d, 0x55, 0xaa, 0xfb, 0x60, 0x86, 0xb1, 0xbb, 0xcc, 0x3e, 0x5a, + 0xcb, 0x59, 0x5f, 0xb0, 0x9c, 0xa9, 0xa0, 0x51, 0x0b, 0xf5, 0x16, 0xeb, 0x7a, 0x75, 0x2c, 0xd7, + 0x4f, 0xae, 0xd5, 0xe9, 0xe6, 0xe7, 0xad, 0xe8, 0x74, 0xd6, 0xf4, 0xea, 0xa8, 0x50, 0x58, 0xaf + ] + } +} + +export default Galois diff --git a/src/QRious.js b/src/QRious.js new file mode 100644 index 0000000..d7c0558 --- /dev/null +++ b/src/QRious.js @@ -0,0 +1,313 @@ +/* + * QRious + * Copyright (C) 2016 Alasdair Mercer + * Copyright (C) 2010 Tom Zerucha + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +import CanvasRenderer from './renderer/CanvasRenderer' +import Frame from './Frame' +import ImageRenderer from './renderer/ImageRenderer' +import ServiceManager from './service/ServiceManager' +import Utilities from './util/Utilities' + +/** + * Enables configuration of a QR code generator which uses HTML5 canvas for rendering. + * + * @public + */ +class QRious { + + /** + * Returns the default options for {@link QRious}. + * + * @return {QRious~Options} The default options. + * @public + * @static + */ + static get DEFAULTS() { + return { + background: 'white', + foreground: 'black', + level: 'L', + mime: 'image/png', + size: 100, + value: '' + } + } + + /** + * Returns the current version of {@link QRious}. + * + * @return {String} The current version. + * @public + * @static + */ + static get VERSION() { + return '2.0.0' + } + + /** + * Configures the service provided to be used by all {@link QRious} instances. + * + * @param {Service} service - the {@link Service} to be configured + * @throws {Error} If a {@link Service} has already been configured with the same name. + * @public + * @static + */ + static use(service) { + QRious._serviceManager.setService(service.getName(), service) + } + + static _parseOptions(options) { + options = Object.assign({}, QRious.DEFAULTS, options) + options.level = Utilities.toUpperCase(options.level) + options.size = Math.abs(options.size) + + return options + } + + /** + * Creates a new instance of {@link QRious} based on the options provided. + * + * @param {QRious~Options} [options] - the options to be used + * @public + */ + constructor(options) { + options = QRious._parseOptions(options) + + Utilities.privatize(this, options) + + let element = this._element + let elementService = QRious._serviceManager.getService('element') + + /** + * The canvas being used to render the QR code for this {@link QRious}. + * + * @public + * @type {*} + */ + this.canvas = element && elementService.isCanvas(element) ? element : elementService.createCanvas() + this.canvas.qrious = this + + /** + * The img to contain the rendered QR code for this {@link QRious}. + * + * @public + * @type {*} + */ + this.image = element && elementService.isImage(element) ? element : elementService.createImage() + this.image.qrious = this + + this._renderers = [ + new CanvasRenderer(this), + new ImageRenderer(this) + ] + + this.update() + } + + /** + * Returns the image data URI for the generated QR code using the mime provided. + * + * @param {String} [mime] - the MIME type for the image + * @return {String} The image data URI for the QR code. + * @public + */ + toDataURL(mime) { + return this.canvas.toDataURL(mime || this.mime) + } + + /** + * Updates this {@link QRious} by generating a new {@link Frame} and re-rendering the QR code. + * + * @protected + */ + update() { + const frame = new Frame({ + level: this.level, + value: this.value + }) + + this._renderers.forEach((renderer) => renderer.render(frame)) + } + + /** + * Returns the background color for the QR code. + * + * @return {String} The background color. + * @public + */ + get background() { + return this._background + } + + /** + * Sets the background color for the QR code to background. + * + * @param {String} [background="white"] - the background color to be set + * @public + */ + set background(background) { + const changed = Utilities.setter(this, '_background', background, QRious.DEFAULTS.background) + + if (changed) { + this.update() + } + } + + /** + * Returns the foreground color for the QR code. + * + * @return {String} The foreground color. + * @public + */ + get foreground() { + return this._foreground + } + + /** + * Sets the foreground color for the QR code to foreground. + * + * @param {String} [foreground="black"] - the foreground color to be set + * @public + */ + set foreground(foreground) { + const changed = Utilities.setter(this, '_foreground', foreground, QRious.DEFAULTS.foreground) + + if (changed) { + this.update() + } + } + + /** + * Returns the error correction level for the QR code. + * + * @return {String} The ECC level. + * @public + */ + get level() { + return this._level + } + + /** + * Sets the error correction level for the QR code to level. + * + * level will be transformed to upper case to aid mapping to known ECC level blocks. + * + * @param {String} [level="L"] - the ECC level to be set + * @public + */ + set level(level) { + const changed = Utilities.setter(this, '_level', level, QRious.DEFAULTS.level, Utilities.toUpperCase) + + if (changed) { + this.update() + } + } + + /** + * Returns the MIME type for the image rendered for the QR code. + * + * @return {String} The image MIME type. + * @public + */ + get mime() { + return this._mime + } + + /** + * Sets the MIME type for the image rendered for the QR code to mime. + * + * @param {String} [mime="image/png"] - the image MIME type to be set + * @public + */ + set mime(mime) { + const changed = Utilities.setter(this, '_mime', mime, QRious.DEFAULTS.mime) + + if (changed) { + this.update() + } + } + + /** + * Returns the size of the QR code. + * + * @return {Number} The size in pixels. + * @public + */ + get size() { + return this._size + } + + /** + * Sets the size of the QR code to size. + * + * size will be transformed to ensure that it is always an absolute positive numbers (e.g. + * -100 would become 100). + * + * @param {Number} [size=100] - the size in pixels to be set + * @public + */ + set size(size) { + const changed = Utilities.setter(this, '_size', size, QRious.DEFAULTS.size, Math.abs) + + if (changed) { + this.update() + } + } + + /** + * Returns the value of the QR code. + * + * @return {String} The value. + * @public + */ + get value() { + return this._value + } + + /** + * Sets the value of the QR code to value. + * + * @param {String} [value=""] - the value to be set + * @public + */ + set value(value) { + const changed = Utilities.setter(this, '_value', value, QRious.DEFAULTS.value) + + if (changed) { + this.update() + } + } +} + +QRious._serviceManager = new ServiceManager() + +export default QRious + +/** + * The options used by {@link QRious}. + * + * @typedef {Object} QRious~Options + * @property {String} [background="white"] - The background color to be applied to the QR code. + * @property {*} [element] - The element to be used to render the QR code which may either be an canvas or + * img. The element(s) will be created if needed. + * @property {String} [foreground="black"] - The foreground color to be applied to the QR code. + * @property {String} [level="L"] - The error correction level to be applied to the QR code. + * @property {String} [mime="image/png"] - The MIME type to be used to render the image for the QR code. + * @property {Number} [size=100] - The size of the QR code in pixels. + * @property {String} [value=""] - The value to be encoded within the QR code. + */ diff --git a/src/Version.js b/src/Version.js new file mode 100644 index 0000000..cf59c4d --- /dev/null +++ b/src/Version.js @@ -0,0 +1,43 @@ +/* + * QRious + * Copyright (C) 2016 Alasdair Mercer + * Copyright (C) 2010 Tom Zerucha + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * Contains version pattern information. + * + * @public + */ +class Version { + + /** + * Returns the version pattern block. + * + * @return {Number[]} The version pattern block. + * @public + * @static + */ + static get BLOCK() { + return [ + 0xc94, 0x5bc, 0xa99, 0x4d3, 0xbf6, 0x762, 0x847, 0x60d, 0x928, 0xb78, 0x45d, 0xa17, 0x532, + 0x9a6, 0x683, 0x8c9, 0x7ec, 0xec4, 0x1e1, 0xfab, 0x08e, 0xc1a, 0x33f, 0xd75, 0x250, 0x9d5, + 0x6f0, 0x8ba, 0x79f, 0xb0b, 0x42e, 0xa64, 0x541, 0xc69 + ] + } +} + +export default Version diff --git a/src/renderer/CanvasRenderer.js b/src/renderer/CanvasRenderer.js new file mode 100644 index 0000000..853e6c2 --- /dev/null +++ b/src/renderer/CanvasRenderer.js @@ -0,0 +1,75 @@ +/* + * QRious + * Copyright (C) 2016 Alasdair Mercer + * Copyright (C) 2010 Tom Zerucha + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +import Renderer from './Renderer' + +/** + * An implementation of {@link Renderer} for working with canvas elements. + * + * @public + * @extends Renderer + */ +class CanvasRenderer extends Renderer { + + /** + * @override + */ + draw(frame) { + const qrious = this.qrious + const moduleSize = this.getModuleSize(frame) + const offset = this.getOffset(frame) + const context = qrious.canvas.getContext('2d') + + context.fillStyle = qrious.foreground + + for (let i = 0; i < frame.width; i++) { + for (let j = 0; j < frame.width; j++) { + if (frame.buffer[j * frame.width + i]) { + context.fillRect(moduleSize * i + offset, moduleSize * j + offset, moduleSize, moduleSize) + } + } + } + } + + /** + * @override + */ + reset() { + const qrious = this.qrious + const context = qrious.canvas.getContext('2d') + + context.lineWidth = 1 + context.clearRect(0, 0, qrious.size, qrious.size) + context.fillStyle = qrious.background + context.fillRect(0, 0, qrious.size, qrious.size) + } + + /** + * @override + */ + resize() { + const qrious = this.qrious + const canvas = qrious.canvas + + canvas.width = qrious.size + canvas.height = qrious.size + } +} + +export default CanvasRenderer diff --git a/src/renderer/ImageRenderer.js b/src/renderer/ImageRenderer.js new file mode 100644 index 0000000..b581043 --- /dev/null +++ b/src/renderer/ImageRenderer.js @@ -0,0 +1,63 @@ +/* + * QRious + * Copyright (C) 2016 Alasdair Mercer + * Copyright (C) 2010 Tom Zerucha + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +import Renderer from './Renderer' + +/** + * An implementation of {@link Renderer} for working with img elements. + * + * This depends on {@link CanvasRenderer} being executed first as this implementation simply applies the data URL from + * the rendered canvas element as the src for the img element being rendered. + * + * @public + * @extends Renderer + */ +class ImageRenderer extends Renderer { + + /** + * @override + */ + draw() { + const qrious = this.qrious + + qrious.image.src = qrious.toDataURL() + } + + /** + * @override + */ + reset() { + const qrious = this.qrious + + qrious.image.src = '' + } + + /** + * @override + */ + resize() { + const qrious = this.qrious + const image = qrious.image + + image.width = qrious.size + image.height = qrious.size + } +} + +export default ImageRenderer diff --git a/src/renderer/Renderer.js b/src/renderer/Renderer.js new file mode 100644 index 0000000..66edb33 --- /dev/null +++ b/src/renderer/Renderer.js @@ -0,0 +1,131 @@ +/* + * QRious + * Copyright (C) 2016 Alasdair Mercer + * Copyright (C) 2010 Tom Zerucha + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +import Utilities from '../util/Utilities' + +/** + * Responsible for rendering a QR code {@link Frame} on a specific type of element. + * + * A renderer may be dependant on the rendering of another element, so ordering of their execution is important. + * + * @public + */ +class Renderer { + + /** + * Creates a new instance of {@link Renderer} for the qrious instance provided. + * + * @param {QRious} qrious - the {@link QRious} instance to be used + * @public + */ + constructor(qrious) { + /** + * The {@link QRious} instance. + * + * @protected + * @type {QRious} + */ + this.qrious = qrious + } + + /** + * Draws the specified QR code frame on the underlying element. + * + * Implementations of {@link Renderer} must override this method with their own specific logic. + * + * @param {Frame} frame - the {@link Frame} to be drawn + * @protected + */ + draw(frame) { + Utilities.throwUnimplemented('Renderer', 'draw') + } + + /** + * Calculates the size (in pixel units) to represent an individual module within the QR code based on the + * frame provided. + * + * The returned value will be at least one, even in cases where the size of the QR code does not fit its contents. + * This is done so that the inevitable clipping is handled more gracefully since this way at least something is + * displayed instead of just a blank space filled by the background color. + * + * @param {Frame} frame - the {@link Frame} from which the module size is to be derived + * @return {Number} The pixel size for each module in the QR code which will be no less than one. + * @protected + */ + getModuleSize(frame) { + const pixels = Math.floor(this.qrious.size / frame.width) + + return Math.max(1, pixels) + } + + /** + * Calculates the offset/padding (in pixel units) to be inserted before the QR code based on the frame + * provided. + * + * The returned value will be zero if there is no available offset or if the size of the QR code does not fit its + * contents. It will never be a negative value. This is done so that the inevitable clipping appears more naturally + * and it is not clipped from all directions. + * + * @param {Frame} frame - the {@link Frame} from which the offset is to be derived + * @return {Number} The pixel offset for the QR code which will be no less than zero. + * @protected + */ + getOffset(frame) { + const moduleSize = this.getModuleSize(frame) + const offset = Math.floor((this.qrious.size - moduleSize * frame.width) / 2) + + return Math.max(0, offset) + } + + /** + * Renders a QR code on the underlying element based on the frame provided. + * + * @param {Frame} frame - the {@link Frame} to be rendered + * @public + */ + render(frame) { + this.resize() + this.reset() + this.draw(frame) + } + + /** + * Resets the underlying element, effectively clearing any previously rendered QR code. + * + * Implementations of {@link Renderer} must override this method with their own specific logic. + * + * @protected + */ + reset() { + Utilities.throwUnimplemented('Renderer', 'reset') + } + + /** + * Ensures that the size of the underlying element matches that defined on the associated {@link QRious} instance. + * + * Implementations of {@link Renderer} must override this method with their own specific logic. + * + * @protected + */ + resize() { + Utilities.throwUnimplemented('Renderer', 'resize') + } +} + +export default Renderer diff --git a/src/runtime/browser.js b/src/runtime/browser.js new file mode 100644 index 0000000..3897c57 --- /dev/null +++ b/src/runtime/browser.js @@ -0,0 +1,25 @@ +/* + * QRious + * Copyright (C) 2016 Alasdair Mercer + * Copyright (C) 2010 Tom Zerucha + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +import BrowserElementService from '../service/element/BrowserElementService' +import QRious from '../QRious' + +QRious.use(new BrowserElementService()) + +export default QRious diff --git a/src/runtime/node.js b/src/runtime/node.js new file mode 100644 index 0000000..bf9cae7 --- /dev/null +++ b/src/runtime/node.js @@ -0,0 +1,25 @@ +/* + * QRious + * Copyright (C) 2016 Alasdair Mercer + * Copyright (C) 2010 Tom Zerucha + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +import NodeElementService from '../service/element/NodeElementService' +import QRious from '../QRious' + +QRious.use(new NodeElementService()) + +export default QRious diff --git a/src/service/Service.js b/src/service/Service.js new file mode 100644 index 0000000..bd9e4cd --- /dev/null +++ b/src/service/Service.js @@ -0,0 +1,40 @@ +/* + * QRious + * Copyright (C) 2016 Alasdair Mercer + * Copyright (C) 2010 Tom Zerucha + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +import Utilities from '../util/Utilities' + +/** + * Defines a service contract that must be met by all implementations. + * + * @public + */ +class Service { + + /** + * Returns the name of this {@link Service}. + * + * @return {String} The service name. + * @public + */ + getName() { + Utilities.throwUnimplemented('Service', 'getName') + } +} + +export default Service diff --git a/src/service/ServiceManager.js b/src/service/ServiceManager.js new file mode 100644 index 0000000..bc593f5 --- /dev/null +++ b/src/service/ServiceManager.js @@ -0,0 +1,73 @@ +/* + * QRious + * Copyright (C) 2016 Alasdair Mercer + * Copyright (C) 2010 Tom Zerucha + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * A basic manager for {@link Service} implementations that are mapped to simple names. + * + * @public + */ +class ServiceManager { + + /** + * Creates a new instance of {@link ServiceManager}. + * + * @public + */ + constructor() { + this._services = {} + } + + /** + * Returns the {@link Service} being managed with the specified name. + * + * @param {String} name - the name of the {@link Service} to be returned + * @return {Service} The {@link Service} is being managed with name. + * @throws {Error} If no {@link Service} is being managed with name. + * @public + */ + getService(name) { + const service = this._services[name] + if (!service) { + throw new Error(`Service is not being managed with name: ${name}`) + } + + return service + } + + /** + * Sets the {@link Service} implementation to be managed for the specified name to the + * service provided. + * + * @param {String} name - the name of the {@link Service} to be managed with name + * @param {Service} service - the {@link Service} implementation to be managed + * @throws {Error} If a {@link Service} is already being managed with the same name. + * @public + */ + setService(name, service) { + if (this._services[name]) { + throw new Error(`Service is already managed with name: ${name}`) + } + + if (service) { + this._services[name] = service + } + } +} + +export default ServiceManager diff --git a/src/service/element/BrowserElementService.js b/src/service/element/BrowserElementService.js new file mode 100644 index 0000000..4eeabce --- /dev/null +++ b/src/service/element/BrowserElementService.js @@ -0,0 +1,59 @@ +/* + * QRious + * Copyright (C) 2016 Alasdair Mercer + * Copyright (C) 2010 Tom Zerucha + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +import ElementService from './ElementService' + +/** + * An implementation of {@link ElementService} intended for use within a browser environment. + * + * @public + * @extends ElementService + */ +class BrowserElementService extends ElementService { + + /** + * @override + */ + createCanvas() { + return document.createElement('canvas') + } + + /** + * @override + */ + createImage() { + return document.createElement('img') + } + + /** + * @override + */ + isCanvas(element) { + return element instanceof HTMLCanvasElement + } + + /** + * @override + */ + isImage(element) { + return element instanceof HTMLImageElement + } +} + +export default BrowserElementService diff --git a/src/service/element/ElementService.js b/src/service/element/ElementService.js new file mode 100644 index 0000000..30fe5ac --- /dev/null +++ b/src/service/element/ElementService.js @@ -0,0 +1,81 @@ +/* + * QRious + * Copyright (C) 2016 Alasdair Mercer + * Copyright (C) 2010 Tom Zerucha + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +import Service from '../Service' +import Utilities from '../../util/Utilities' + +/** + * A service for working with elements. + * + * @public + * @extends Service + */ +class ElementService extends Service { + + /** + * Creates an instance of a canvas element. + * + * @return {*} The newly created canvas element. + * @public + */ + createCanvas() { + Utilities.throwUnimplemented('ElementService', 'createCanvas') + } + + /** + * Creates an instance of a image element. + * + * @return {*} The newly created image element. + * @public + */ + createImage() { + Utilities.throwUnimplemented('ElementService', 'createImage') + } + + /** + * @override + */ + getName() { + return 'element' + } + + /** + * Returns whether the specified element is a canvas. + * + * @param {*} element - the element to be checked + * @return {Boolean} true if element is a canvas; otherwise false. + * @public + */ + isCanvas(element) { + Utilities.throwUnimplemented('ElementService', 'isCanvas') + } + + /** + * Returns whether the specified element is an image. + * + * @param {*} element - the element to be checked + * @return {Boolean} true if element is an image; otherwise false. + * @public + */ + isImage(element) { + Utilities.throwUnimplemented('ElementService', 'isImage') + } +} + +export default ElementService diff --git a/src/service/element/NodeElementService.js b/src/service/element/NodeElementService.js new file mode 100644 index 0000000..136cfcf --- /dev/null +++ b/src/service/element/NodeElementService.js @@ -0,0 +1,69 @@ +/* + * QRious + * Copyright (C) 2016 Alasdair Mercer + * Copyright (C) 2010 Tom Zerucha + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +import Canvas, { Image } from 'canvas' + +import ElementService from './ElementService' + +/** + * An implementation of {@link ElementService} intended for use within a Node.js environment but is only supported when + * the canvas module has also been depended on. + * + * @public + * @extends ElementService + */ +class NodeElementService extends ElementService { + + /** + * @override + */ + static isSupported() { + return Canvas != null + } + + /** + * @override + */ + createCanvas() { + return new Canvas() + } + + /** + * @override + */ + createImage() { + return new Image() + } + + /** + * @override + */ + isCanvas(element) { + return element instanceof Canvas + } + + /** + * @override + */ + isImage(element) { + return element instanceof Image + } +} + +export default NodeElementService diff --git a/src/util/Utilities.js b/src/util/Utilities.js new file mode 100644 index 0000000..2ed77bf --- /dev/null +++ b/src/util/Utilities.js @@ -0,0 +1,103 @@ +/* + * QRious + * Copyright (C) 2016 Alasdair Mercer + * Copyright (C) 2010 Tom Zerucha + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * Contains utility methods that are useful throughout the library. + * + * @public + */ +class Utilities { + + /** + * Copies all properties from the source object to the target object, however, all property + * names on the target will be prefixed with an underscore, used to indicate that they are private. + * + * @param {Object} target - the object to which the private fields are to be copied + * @param {Object} source - the object from which the fields are to be copied + * @return {Object} A reference to the target object. + * @public + * @static + */ + static privatize(target, source) { + for (let key in source) { + if (source.hasOwnProperty(key)) { + target[`_${key}`] = source[key] + } + } + + return target + } + + /** + * Sets the specified value on a given field on the object provided. + * + * If value is null, the specified default value will be used instead. + * + * An optional transformer can be specified which will be used to transform the value (or default value) + * before it is assigned to the field. + * + * @param {Object} object - the object whose field is to be set with value + * @param {String} fieldName - the field to be set with value + * @param {*} value - the value to be set on the named field + * @param {*} [defaultValue] - the value to be used if value is null + * @param {Function} [transformer] - a function used to transform the value before it is assigned to the named field + * @return {Boolean} true if the value of the field has changed as a result of the assignment; otherwise + * false. + * @public + * @static + */ + static setter(object, fieldName, value, defaultValue, transformer) { + const oldValue = object[fieldName] + let newValue = value != null ? value : defaultValue + if (typeof transformer === 'function') { + newValue = transformer(newValue) + } + + object[fieldName] = newValue + + return newValue !== oldValue + } + + /** + * Throws an error indicating that the a given method on a specific class has not been implemented. + * + * @param {String} className - the name of the class on which the method has not been implemented + * @param {String} methodName - the name of the method which has not been implemented + * @throws {Error} The error describing the class method which has not been implemented. + * @public + * @static + */ + static throwUnimplemented(className, methodName) { + throw new Error(`"${methodName}" method must be implemented on the ${className} class`) + } + + /** + * Transforms the specified string to upper case while remaining null-safe. + * + * @param {String} string - the string to be transformed to upper case + * @return {String} string transformed to upper case if string is not null. + * @public + * @static + */ + static toUpperCase(string) { + return string != null && string.toUpperCase() + } +} + +export default Utilities