bumping version to 2 to start integrating api changes
This commit is contained in:
parent
52e3cd537b
commit
245bb692f0
5 changed files with 25 additions and 15 deletions
|
@ -30,6 +30,7 @@ QRCodeDraw.prototype = {
|
|||
scale:4,//4 px module size
|
||||
defaultMargin:20,
|
||||
marginScaleFactor:5,
|
||||
Array:(typeof Uint32Array == 'undefined'?Uint32Array:Array),
|
||||
// you may configure the error behavior for input string too long
|
||||
errorBehavior:{
|
||||
length:'trim'
|
||||
|
@ -162,7 +163,7 @@ QRCodeDraw.prototype = {
|
|||
qr.make();
|
||||
|
||||
width = this.dataWidth(qr,1);
|
||||
bits = new Array(width*width);
|
||||
bits = new this.Array(width*width);
|
||||
|
||||
|
||||
for (var r = 0,rl=qr.getModuleCount(); r < rl; r++) {
|
||||
|
|
|
@ -35,13 +35,15 @@
|
|||
|
||||
exports.QRCode = QRCode;
|
||||
|
||||
var QRDataArray = (typeof Uint32Array == 'undefined'?Uint32Array:Array);
|
||||
|
||||
function QRCode(typeNumber, errorCorrectLevel) {
|
||||
this.typeNumber = typeNumber;
|
||||
this.errorCorrectLevel = errorCorrectLevel;
|
||||
this.modules = null;
|
||||
this.moduleCount = 0;
|
||||
this.dataCache = null;
|
||||
this.dataList = new Array();
|
||||
this.dataList = new QRDataArray();
|
||||
}
|
||||
|
||||
QRCode.prototype = {
|
||||
|
@ -70,11 +72,11 @@ QRCode.prototype = {
|
|||
makeImpl : function(test, maskPattern) {
|
||||
|
||||
this.moduleCount = this.typeNumber * 4 + 17;
|
||||
this.modules = new Array(this.moduleCount);
|
||||
this.modules = new QRDataArray(this.moduleCount);
|
||||
|
||||
for (var row = 0; row < this.moduleCount; row++) {
|
||||
|
||||
this.modules[row] = new Array(this.moduleCount);
|
||||
this.modules[row] = new QRDataArray(this.moduleCount);
|
||||
|
||||
for (var col = 0; col < this.moduleCount; col++) {
|
||||
this.modules[row][col] = null;//(col + row) % 3;
|
||||
|
@ -358,8 +360,8 @@ QRCode.createBytes = function(buffer, rsBlocks) {
|
|||
var maxDcCount = 0;
|
||||
var maxEcCount = 0;
|
||||
|
||||
var dcdata = new Array(rsBlocks.length);
|
||||
var ecdata = new Array(rsBlocks.length);
|
||||
var dcdata = new QRDataArray(rsBlocks.length);
|
||||
var ecdata = new QRDataArray(rsBlocks.length);
|
||||
|
||||
for (var r = 0; r < rsBlocks.length; r++) {
|
||||
|
||||
|
@ -369,7 +371,7 @@ QRCode.createBytes = function(buffer, rsBlocks) {
|
|||
maxDcCount = Math.max(maxDcCount, dcCount);
|
||||
maxEcCount = Math.max(maxEcCount, ecCount);
|
||||
|
||||
dcdata[r] = new Array(dcCount);
|
||||
dcdata[r] = new QRDataArray(dcCount);
|
||||
|
||||
for (var i = 0; i < dcdata[r].length; i++) {
|
||||
dcdata[r][i] = 0xff & buffer.buffer[i + offset];
|
||||
|
@ -380,7 +382,7 @@ QRCode.createBytes = function(buffer, rsBlocks) {
|
|||
var rawPoly = new QRPolynomial(dcdata[r], rsPoly.getLength() - 1);
|
||||
|
||||
var modPoly = rawPoly.mod(rsPoly);
|
||||
ecdata[r] = new Array(rsPoly.getLength() - 1);
|
||||
ecdata[r] = new QRDataArray(rsPoly.getLength() - 1);
|
||||
for (var i = 0; i < ecdata[r].length; i++) {
|
||||
var modIndex = i + modPoly.getLength() - ecdata[r].length;
|
||||
ecdata[r][i] = (modIndex >= 0)? modPoly.get(modIndex) : 0;
|
||||
|
@ -393,7 +395,7 @@ QRCode.createBytes = function(buffer, rsBlocks) {
|
|||
totalCodeCount += rsBlocks[i].totalCount;
|
||||
}
|
||||
|
||||
var data = new Array(totalCodeCount);
|
||||
var data = new QRDataArray(totalCodeCount);
|
||||
var index = 0;
|
||||
|
||||
for (var i = 0; i < maxDcCount; i++) {
|
||||
|
|
|
@ -8,7 +8,7 @@ function renderBits(bits,width,inverse){
|
|||
var bottom = '▄';
|
||||
var both = '█';
|
||||
var top = '▀';
|
||||
|
||||
|
||||
var bit = 0,nextRow,_b,_t,out = ' ',_debug = [],row = 0,i,j;
|
||||
//add one row to out for top framing
|
||||
for(i=0;i<width;++i) {
|
||||
|
@ -30,7 +30,7 @@ function renderBits(bits,width,inverse){
|
|||
|
||||
if(bits[bit]) {
|
||||
_t = 1;
|
||||
c = top.bold;
|
||||
c = '\033[53m'+top;
|
||||
}
|
||||
|
||||
if(bits[nextRow]){
|
||||
|
@ -40,7 +40,7 @@ function renderBits(bits,width,inverse){
|
|||
|
||||
|
||||
if(_b && _t) {
|
||||
c = both.underline;
|
||||
c = '\033[53m'+(both.underline);
|
||||
}
|
||||
//_debug[row].push(_t+'');
|
||||
//_debug[row+1].push(_b+'');
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{ "name": "qrcode"
|
||||
,"description": "QRCode / 2d Barcode api with both server side and client side support using canvas"
|
||||
,"version": "0.1.1"
|
||||
,"version": "0.2.0"
|
||||
,"author": "Ryan Day <soldair@gmail.com>"
|
||||
,"keywords": ["canvas", "qrcode", "barcode"]
|
||||
,"main": "./qrcode.js"
|
||||
|
@ -10,15 +10,18 @@
|
|||
,"prepublish":"node build.js"
|
||||
,"test":"./test.sh"
|
||||
}
|
||||
,"bin":{
|
||||
"qrcode":"./bin/qrcode"
|
||||
}
|
||||
,"dependencies": {
|
||||
"canvas": ">= 0.4.3"
|
||||
"canvas": ">= 0.4.3",
|
||||
"colors":"*"
|
||||
}
|
||||
,"devDependencies":{
|
||||
"express":"2.5.x"
|
||||
,"browserify":"1.9.x"
|
||||
,"uglify-js":"1.2.x"
|
||||
,"connect":"1.8.x"
|
||||
,"colors":"*"
|
||||
}
|
||||
,"repository":{
|
||||
"type":"git"
|
||||
|
|
4
qrcodeclient.js
Normal file
4
qrcodeclient.js
Normal file
|
@ -0,0 +1,4 @@
|
|||
|
||||
var QRCodeLib = require('./lib/qrcode-draw.js');
|
||||
|
||||
if(typeof window !== "undefined") window.QRCodeLib = QRCodeLib;
|
Loading…
Reference in a new issue