From 52f597d1103a5f5875edf9d6d46e04976c94a6a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8F=B6=E8=A8=80?= Date: Wed, 21 Oct 2015 11:09:27 +0800 Subject: [PATCH 01/10] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=8D=E8=83=BD?= =?UTF-8?q?=E6=B8=B2=E6=9F=93=E5=B0=8F=E6=95=B0=E7=82=B9=E5=83=8F=E7=B4=A0?= =?UTF-8?q?=E5=80=BC=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dist/arale-qrcode/3.0.5/index.js | 1 - dist/arale-qrcode/3.0.6/index.js | 1 + package.json | 2 +- src/index.js | 24 ++++++++++++++++-------- 4 files changed, 18 insertions(+), 10 deletions(-) delete mode 100644 dist/arale-qrcode/3.0.5/index.js create mode 100644 dist/arale-qrcode/3.0.6/index.js diff --git a/dist/arale-qrcode/3.0.5/index.js b/dist/arale-qrcode/3.0.5/index.js deleted file mode 100644 index 4f08742..0000000 --- a/dist/arale-qrcode/3.0.5/index.js +++ /dev/null @@ -1 +0,0 @@ -this.AraleQRCode=function(t){function e(o){if(r[o])return r[o].exports;var i=r[o]={exports:{},id:o,loaded:!1};return t[o].call(i.exports,i,i.exports,e),i.loaded=!0,i.exports}var r={};return e.m=t,e.c=r,e.p="",e(0)}([function(t,e,r){t.exports=r(1)},function(t,e,r){"use strict";t.exports=r(2)},function(t,e,r){"use strict";var o=r(4),i=[],n=r(3),s=function(t){var e=t.options;return e.pdground&&(t.row>1&&t.row<5&&t.col>1&&t.col<5||t.row>t.count-6&&t.row1&&t.col<5||t.row>1&&t.row<5&&t.col>t.count-6&&t.colr;r++)if(i[r].text==this.options.text&&i[r].text.correctLevel==this.options.correctLevel){e=i[r].obj;break}if(r==s&&(e=new n(this.options.text,this.options.correctLevel),i.push({text:this.options.text,correctLevel:this.options.correctLevel,obj:e})),this.options.render)switch(this.options.render){case"canvas":return this.createCanvas(e);case"table":return this.createTable(e);case"svg":return this.createSVG(e);default:return this.createDefault(e)}return this.createDefault(e)};o(a.prototype,{createDefault:function(t){var e=document.createElement("canvas");if(e.getContext)return this.createCanvas(t);var r="http://www.w3.org/2000/svg";return document.createElementNS&&document.createElementNS(r,"svg").createSVGRect?this.createSVG(t):this.createTable(t)},createCanvas:function(t){var e=this.options,r=document.createElement("canvas"),o=r.getContext("2d"),i=t.getModuleCount(),n=u(o),a=e.size,l=a*n,h=e.imageSize*n,g=function(t,e){var r=new Image;r.src=t,r.onload=function(){e(this),r.onload=null}},c=(l/i).toPrecision(4),f=(l/i).toPrecision(4);r.width=l,r.height=l;for(var d=0;i>d;d++)for(var m=0;i>m;m++){var p=Math.ceil((m+1)*c)-Math.floor(m*c),v=Math.ceil((d+1)*c)-Math.floor(d*c),b=s({row:d,col:m,count:i,options:e});o.fillStyle=t.modules[d][m]?b:e.background,o.fillRect(Math.round(m*c),Math.round(d*f),p,v)}return e.image&&g(e.image,function(t){var e=((l-h)/2).toFixed(2),r=((l-h)/2).toFixed(2);o.drawImage(t,e,r,h,h)}),r.style.width=a+"px",r.style.height=a+"px",r},createTable:function(t){var e=this.options,r=t.getModuleCount(),o=Math.floor(e.size/r),i=Math.floor(e.size/r);0>=o&&(o=80>r?2:1),0>=i&&(i=80>r?2:1);var n=[];n.push('');for(var u=0;r>u;u++){n.push('');for(var a=0;r>a;a++){var l=s({row:u,col:a,count:r,options:e});t.modules[u][a]?n.push(''):n.push('')}n.push("")}if(n.push("
"),e.image){var h=o*r,g=i*r,c=((h-e.imageSize)/2).toFixed(2),f=((g-e.imageSize)/2).toFixed(2);n.unshift("
"),n.push(""),n.push("
")}var d=document.createElement("span");return d.innerHTML=n.join(""),d.firstChild},createSVG:function(t){var e=this.options,r=t.getModuleCount(),o=r/e.size,i=document.createElementNS("http://www.w3.org/2000/svg","svg");i.setAttribute("width",e.size),i.setAttribute("height",e.size),i.setAttribute("viewBox","0 0 "+r+" "+r);for(var n=0;r>n;n++)for(var u=0;r>u;u++){var a=document.createElementNS("http://www.w3.org/2000/svg","rect"),l=s({row:n,col:u,count:r,options:e});a.setAttribute("x",u),a.setAttribute("y",n),a.setAttribute("width",1),a.setAttribute("height",1),a.setAttribute("stroke-width",0),t.modules[n][u]?a.setAttribute("fill",l):a.setAttribute("fill",e.background),i.appendChild(a)}if(e.image){var h=document.createElementNS("http://www.w3.org/2000/svg","image");h.setAttributeNS("http://www.w3.org/1999/xlink","href",e.image),h.setAttribute("x",((r-e.imageSize*o)/2).toFixed(2)),h.setAttribute("y",((r-e.imageSize*o)/2).toFixed(2)),h.setAttribute("width",e.imageSize*o),h.setAttribute("height",e.imageSize*o),i.appendChild(h)}return i}}),t.exports=a},function(t,e){"use strict";function r(t){var e,r,o;return 128>t?[t]:2048>t?(e=192+(t>>6),r=128+(63&t),[e,r]):(e=224+(t>>12),r=128+(t>>6&63),o=128+(63&t),[e,r,o])}function o(t){for(var e=[],o=0;o=7&&this.setupTypeNumber(!0),this.mapData(this.dataCache,t)},setupPositionProbePattern:function(t,e){for(var r=-1;7>=r;r++)if(!(-1>=t+r||this.moduleCount<=t+r))for(var o=-1;7>=o;o++)-1>=e+o||this.moduleCount<=e+o||(r>=0&&6>=r&&(0==o||6==o)||o>=0&&6>=o&&(0==r||6==r)||r>=2&&4>=r&&o>=2&&4>=o?this.modules[t+r][e+o]=!0:this.modules[t+r][e+o]=!1)},createQrcode:function(){for(var t=0,e=0,r=null,o=0;8>o;o++){this.makeImpl(o);var i=l.getLostPoint(this);(0==o||t>i)&&(t=i,e=o,r=this.modules)}this.modules=r,this.setupTypeInfo(!1,e),this.typeNumber>=7&&this.setupTypeNumber(!1)},setupTimingPattern:function(){for(var t=8;t=n;n++)for(var s=-2;2>=s;s++)-2==n||2==n||-2==s||2==s||0==n&&0==s?this.modules[o+n][i+s]=!0:this.modules[o+n][i+s]=!1}},setupTypeNumber:function(t){for(var e=l.getBCHTypeNumber(this.typeNumber),r=0;18>r;r++){var o=!t&&1==(e>>r&1);this.modules[Math.floor(r/3)][r%3+this.moduleCount-8-3]=o,this.modules[r%3+this.moduleCount-8-3][Math.floor(r/3)]=o}},setupTypeInfo:function(t,e){for(var r=u[this.errorCorrectLevel]<<3|e,o=l.getBCHTypeInfo(r),i=0;15>i;i++){var n=!t&&1==(o>>i&1);6>i?this.modules[i][8]=n:8>i?this.modules[i+1][8]=n:this.modules[this.moduleCount-15+i][8]=n;var n=!t&&1==(o>>i&1);8>i?this.modules[8][this.moduleCount-i-1]=n:9>i?this.modules[8][15-i-1+1]=n:this.modules[8][15-i-1]=n}this.modules[this.moduleCount-8][8]=!t},createData:function(){var t=new s,e=this.typeNumber>9?16:8;t.put(4,4),t.put(this.utf8bytes.length,e);for(var r=0,o=this.utf8bytes.length;o>r;r++)t.put(this.utf8bytes[r],8);for(t.length+4<=8*this.totalDataCount&&t.put(0,4);t.length%8!=0;)t.putBit(!1);for(;;){if(t.length>=8*this.totalDataCount)break;if(t.put(i.PAD0,8),t.length>=8*this.totalDataCount)break;t.put(i.PAD1,8)}return this.createBytes(t)},createBytes:function(t){for(var e=0,r=0,o=0,i=this.rsBlock.length/3,s=new Array,u=0;i>u;u++)for(var a=this.rsBlock[3*u+0],h=this.rsBlock[3*u+1],g=this.rsBlock[3*u+2],c=0;a>c;c++)s.push([g,h]);for(var f=new Array(s.length),d=new Array(s.length),m=0;m=0?A.get(T):0}}for(var P=new Array(this.totalDataCount),y=0,u=0;r>u;u++)for(var m=0;mu;u++)for(var m=0;m0;s-=2)for(6==s&&s--;;){for(var u=0;2>u;u++)if(null==this.modules[o][s-u]){var a=!1;n>>i&1));var h=l.getMask(e,o,s-u);h&&(a=!a),this.modules[o][s-u]=a,i--,-1==i&&(n++,i=7)}if(o+=r,0>o||this.moduleCount<=o){o-=r,r=-r;break}}}},i.PAD0=236,i.PAD1=17;for(var u=[1,0,3,2],a={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7},l={PATTERN_POSITION_TABLE:[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58],[6,34,62],[6,26,46,66],[6,26,48,70],[6,26,50,74],[6,30,54,78],[6,30,56,82],[6,30,58,86],[6,34,62,90],[6,28,50,72,94],[6,26,50,74,98],[6,30,54,78,102],[6,28,54,80,106],[6,32,58,84,110],[6,30,58,86,114],[6,34,62,90,118],[6,26,50,74,98,122],[6,30,54,78,102,126],[6,26,52,78,104,130],[6,30,56,82,108,134],[6,34,60,86,112,138],[6,30,58,86,114,142],[6,34,62,90,118,146],[6,30,54,78,102,126,150],[6,24,50,76,102,128,154],[6,28,54,80,106,132,158],[6,32,58,84,110,136,162],[6,26,54,82,110,138,166],[6,30,58,86,114,142,170]],G15:1335,G18:7973,G15_MASK:21522,getBCHTypeInfo:function(t){for(var e=t<<10;l.getBCHDigit(e)-l.getBCHDigit(l.G15)>=0;)e^=l.G15<=0;)e^=l.G18<>>=1;return e},getPatternPosition:function(t){return l.PATTERN_POSITION_TABLE[t-1]},getMask:function(t,e,r){switch(t){case a.PATTERN000:return(e+r)%2==0;case a.PATTERN001:return e%2==0;case a.PATTERN010:return r%3==0;case a.PATTERN011:return(e+r)%3==0;case a.PATTERN100:return(Math.floor(e/2)+Math.floor(r/3))%2==0;case a.PATTERN101:return e*r%2+e*r%3==0;case a.PATTERN110:return(e*r%2+e*r%3)%2==0;case a.PATTERN111:return(e*r%3+(e+r)%2)%2==0;default:throw new Error("bad maskPattern:"+t)}},getErrorCorrectPolynomial:function(t){for(var e=new n([1],0),r=0;t>r;r++)e=e.multiply(new n([1,h.gexp(r)],0));return e},getLostPoint:function(t){for(var e=t.getModuleCount(),r=0,o=0,i=0;e>i;i++)for(var n=0,s=t.modules[i][0],u=0;e>u;u++){var a=t.modules[i][u];if(e-6>u&&a&&!t.modules[i][u+1]&&t.modules[i][u+2]&&t.modules[i][u+3]&&t.modules[i][u+4]&&!t.modules[i][u+5]&&t.modules[i][u+6]&&(e-10>u?t.modules[i][u+7]&&t.modules[i][u+8]&&t.modules[i][u+9]&&t.modules[i][u+10]&&(r+=40):u>3&&t.modules[i][u-1]&&t.modules[i][u-2]&&t.modules[i][u-3]&&t.modules[i][u-4]&&(r+=40)),e-1>i&&e-1>u){var l=0;a&&l++,t.modules[i+1][u]&&l++,t.modules[i][u+1]&&l++,t.modules[i+1][u+1]&&l++,(0==l||4==l)&&(r+=3)}s^a?n++:(s=a,n>=5&&(r+=3+n-5),n=1),a&&o++}for(var u=0;e>u;u++)for(var n=0,s=t.modules[0][u],i=0;e>i;i++){var a=t.modules[i][u];e-6>i&&a&&!t.modules[i+1][u]&&t.modules[i+2][u]&&t.modules[i+3][u]&&t.modules[i+4][u]&&!t.modules[i+5][u]&&t.modules[i+6][u]&&(e-10>i?t.modules[i+7][u]&&t.modules[i+8][u]&&t.modules[i+9][u]&&t.modules[i+10][u]&&(r+=40):i>3&&t.modules[i-1][u]&&t.modules[i-2][u]&&t.modules[i-3][u]&&t.modules[i-4][u]&&(r+=40)),s^a?n++:(s=a,n>=5&&(r+=3+n-5),n=1)}var h=Math.abs(100*o/e/e-50)/5;return r+=10*h}},h={glog:function(t){if(1>t)throw new Error("glog("+t+")");return h.LOG_TABLE[t]},gexp:function(t){for(;0>t;)t+=255;for(;t>=256;)t-=255;return h.EXP_TABLE[t]},EXP_TABLE:new Array(256),LOG_TABLE:new Array(256)},g=0;8>g;g++)h.EXP_TABLE[g]=1<g;g++)h.EXP_TABLE[g]=h.EXP_TABLE[g-4]^h.EXP_TABLE[g-5]^h.EXP_TABLE[g-6]^h.EXP_TABLE[g-8];for(var g=0;255>g;g++)h.LOG_TABLE[h.EXP_TABLE[g]]=g;n.prototype={get:function(t){return this.num[t]},getLength:function(){return this.num.length},multiply:function(t){for(var e=new Array(this.getLength()+t.getLength()-1),r=0;re-r)return this;for(var o=new Array(e),i=0;e>i;i++)o[i]=this.get(i);for(;o.length>=r;){for(var s=h.glog(o[0])-h.glog(t.get(0)),i=0;it;t++){var e=c[4*(t-1)+this.errorCorrectLevel];if(void 0==e)throw new Error("bad rs block @ typeNumber:"+t+"/errorCorrectLevel:"+this.errorCorrectLevel);for(var r=e.length/3,o=0,i=0;r>i;i++){var n=e[3*i+0],s=e[3*i+2];o+=s*n}var u=t>9?2:1;if(this.utf8bytes.length+u>>7-t%8&1},put:function(t,e){for(var r=0;e>r;r++)this.putBit(t>>>e-r-1&1)},putBit:function(t){var e=Math.floor(this.length/8);this.buffer.length<=e&&this.buffer.push(0),t&&(this.buffer[e]|=128>>>this.length%8),this.length++}},t.exports=i},function(t,e){t.exports=function(t){for(var e,r=Array.prototype.slice.call(arguments,1),o=0;e=r[o];o++)if(e)for(var i in e)t[i]=e[i];return t}}]); \ No newline at end of file diff --git a/dist/arale-qrcode/3.0.6/index.js b/dist/arale-qrcode/3.0.6/index.js new file mode 100644 index 0000000..153b31b --- /dev/null +++ b/dist/arale-qrcode/3.0.6/index.js @@ -0,0 +1 @@ +this.AraleQRCode=function(t){function e(o){if(r[o])return r[o].exports;var i=r[o]={exports:{},id:o,loaded:!1};return t[o].call(i.exports,i,i.exports,e),i.loaded=!0,i.exports}var r={};return e.m=t,e.c=r,e.p="",e(0)}([function(t,e,r){t.exports=r(1)},function(t,e,r){"use strict";t.exports=r(2)},function(t,e,r){"use strict";var o=r(4),i=[],n=r(3),s=function(t){var e=t.options;return e.pdground&&(t.row>1&&t.row<5&&t.col>1&&t.col<5||t.row>t.count-6&&t.row1&&t.col<5||t.row>1&&t.row<5&&t.col>t.count-6&&t.colr;r++)if(i[r].text==this.options.text&&i[r].text.correctLevel==this.options.correctLevel){e=i[r].obj;break}if(r==s&&(e=new n(this.options.text,this.options.correctLevel),i.push({text:this.options.text,correctLevel:this.options.correctLevel,obj:e})),this.options.render)switch(this.options.render){case"canvas":return this.createCanvas(e);case"table":return this.createTable(e);case"svg":return this.createSVG(e);default:return this.createDefault(e)}return this.createDefault(e)};o(a.prototype,{createDefault:function(t){var e=document.createElement("canvas");if(e.getContext)return this.createCanvas(t);var r="http://www.w3.org/2000/svg";return document.createElementNS&&document.createElementNS(r,"svg").createSVGRect?this.createSVG(t):this.createTable(t)},createCanvas:function(t){var e=this.options,r=document.createElement("canvas"),o=r.getContext("2d"),i=t.getModuleCount(),n=u(o),a=e.size,l=a*n,h=e.imageSize*n,g=function(t,e){var r=new Image;r.src=t,r.onload=function(){e(this),r.onload=null}},f=Math.floor(l/i),c=Math.floor(l/i);0>=f&&(f=80>i?2:1),0>=c&&(c=80>i?2:1),r.width=f*i,r.height=c*i;for(var d=0;i>d;d++)for(var m=0;i>m;m++){var p=Math.ceil((m+1)*f)-Math.floor(m*f),v=Math.ceil((d+1)*f)-Math.floor(d*f),b=s({row:d,col:m,count:i,options:e});o.fillStyle=t.modules[d][m]?b:e.background,o.fillRect(Math.round(m*f),Math.round(d*c),p,v)}return e.image&&g(e.image,function(t){var e=((l-h)/2).toFixed(2),r=((l-h)/2).toFixed(2);o.drawImage(t,e,r,h,h)}),r.style.width=a+"px",r.style.height=a+"px",r},createTable:function(t){var e=this.options,r=t.getModuleCount(),o=Math.floor(e.size/r),i=Math.floor(e.size/r);0>=o&&(o=80>r?2:1),0>=i&&(i=80>r?2:1);var n=[];n.push('');for(var u=0;r>u;u++){n.push('');for(var a=0;r>a;a++){var l=s({row:u,col:a,count:r,options:e});t.modules[u][a]?n.push(''):n.push('')}n.push("")}if(n.push("
"),e.image){var h=o*r,g=i*r,f=((h-e.imageSize)/2).toFixed(2),c=((g-e.imageSize)/2).toFixed(2);n.unshift("
"),n.push(""),n.push("
")}var d=document.createElement("span");return d.innerHTML=n.join(""),d.firstChild},createSVG:function(t){var e=this.options,r=t.getModuleCount(),o=r/e.size,i=document.createElementNS("http://www.w3.org/2000/svg","svg");i.setAttribute("width",e.size),i.setAttribute("height",e.size),i.setAttribute("viewBox","0 0 "+r+" "+r);for(var n=0;r>n;n++)for(var u=0;r>u;u++){var a=document.createElementNS("http://www.w3.org/2000/svg","rect"),l=s({row:n,col:u,count:r,options:e});a.setAttribute("x",u),a.setAttribute("y",n),a.setAttribute("width",1),a.setAttribute("height",1),a.setAttribute("stroke-width",0),t.modules[n][u]?a.setAttribute("fill",l):a.setAttribute("fill",e.background),i.appendChild(a)}if(e.image){var h=document.createElementNS("http://www.w3.org/2000/svg","image");h.setAttributeNS("http://www.w3.org/1999/xlink","href",e.image),h.setAttribute("x",((r-e.imageSize*o)/2).toFixed(2)),h.setAttribute("y",((r-e.imageSize*o)/2).toFixed(2)),h.setAttribute("width",e.imageSize*o),h.setAttribute("height",e.imageSize*o),i.appendChild(h)}return i}}),t.exports=a},function(t,e){"use strict";function r(t){var e,r,o;return 128>t?[t]:2048>t?(e=192+(t>>6),r=128+(63&t),[e,r]):(e=224+(t>>12),r=128+(t>>6&63),o=128+(63&t),[e,r,o])}function o(t){for(var e=[],o=0;o=7&&this.setupTypeNumber(!0),this.mapData(this.dataCache,t)},setupPositionProbePattern:function(t,e){for(var r=-1;7>=r;r++)if(!(-1>=t+r||this.moduleCount<=t+r))for(var o=-1;7>=o;o++)-1>=e+o||this.moduleCount<=e+o||(r>=0&&6>=r&&(0==o||6==o)||o>=0&&6>=o&&(0==r||6==r)||r>=2&&4>=r&&o>=2&&4>=o?this.modules[t+r][e+o]=!0:this.modules[t+r][e+o]=!1)},createQrcode:function(){for(var t=0,e=0,r=null,o=0;8>o;o++){this.makeImpl(o);var i=l.getLostPoint(this);(0==o||t>i)&&(t=i,e=o,r=this.modules)}this.modules=r,this.setupTypeInfo(!1,e),this.typeNumber>=7&&this.setupTypeNumber(!1)},setupTimingPattern:function(){for(var t=8;t=n;n++)for(var s=-2;2>=s;s++)-2==n||2==n||-2==s||2==s||0==n&&0==s?this.modules[o+n][i+s]=!0:this.modules[o+n][i+s]=!1}},setupTypeNumber:function(t){for(var e=l.getBCHTypeNumber(this.typeNumber),r=0;18>r;r++){var o=!t&&1==(e>>r&1);this.modules[Math.floor(r/3)][r%3+this.moduleCount-8-3]=o,this.modules[r%3+this.moduleCount-8-3][Math.floor(r/3)]=o}},setupTypeInfo:function(t,e){for(var r=u[this.errorCorrectLevel]<<3|e,o=l.getBCHTypeInfo(r),i=0;15>i;i++){var n=!t&&1==(o>>i&1);6>i?this.modules[i][8]=n:8>i?this.modules[i+1][8]=n:this.modules[this.moduleCount-15+i][8]=n;var n=!t&&1==(o>>i&1);8>i?this.modules[8][this.moduleCount-i-1]=n:9>i?this.modules[8][15-i-1+1]=n:this.modules[8][15-i-1]=n}this.modules[this.moduleCount-8][8]=!t},createData:function(){var t=new s,e=this.typeNumber>9?16:8;t.put(4,4),t.put(this.utf8bytes.length,e);for(var r=0,o=this.utf8bytes.length;o>r;r++)t.put(this.utf8bytes[r],8);for(t.length+4<=8*this.totalDataCount&&t.put(0,4);t.length%8!=0;)t.putBit(!1);for(;;){if(t.length>=8*this.totalDataCount)break;if(t.put(i.PAD0,8),t.length>=8*this.totalDataCount)break;t.put(i.PAD1,8)}return this.createBytes(t)},createBytes:function(t){for(var e=0,r=0,o=0,i=this.rsBlock.length/3,s=new Array,u=0;i>u;u++)for(var a=this.rsBlock[3*u+0],h=this.rsBlock[3*u+1],g=this.rsBlock[3*u+2],f=0;a>f;f++)s.push([g,h]);for(var c=new Array(s.length),d=new Array(s.length),m=0;m=0?A.get(T):0}}for(var P=new Array(this.totalDataCount),y=0,u=0;r>u;u++)for(var m=0;mu;u++)for(var m=0;m0;s-=2)for(6==s&&s--;;){for(var u=0;2>u;u++)if(null==this.modules[o][s-u]){var a=!1;n>>i&1));var h=l.getMask(e,o,s-u);h&&(a=!a),this.modules[o][s-u]=a,i--,-1==i&&(n++,i=7)}if(o+=r,0>o||this.moduleCount<=o){o-=r,r=-r;break}}}},i.PAD0=236,i.PAD1=17;for(var u=[1,0,3,2],a={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7},l={PATTERN_POSITION_TABLE:[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58],[6,34,62],[6,26,46,66],[6,26,48,70],[6,26,50,74],[6,30,54,78],[6,30,56,82],[6,30,58,86],[6,34,62,90],[6,28,50,72,94],[6,26,50,74,98],[6,30,54,78,102],[6,28,54,80,106],[6,32,58,84,110],[6,30,58,86,114],[6,34,62,90,118],[6,26,50,74,98,122],[6,30,54,78,102,126],[6,26,52,78,104,130],[6,30,56,82,108,134],[6,34,60,86,112,138],[6,30,58,86,114,142],[6,34,62,90,118,146],[6,30,54,78,102,126,150],[6,24,50,76,102,128,154],[6,28,54,80,106,132,158],[6,32,58,84,110,136,162],[6,26,54,82,110,138,166],[6,30,58,86,114,142,170]],G15:1335,G18:7973,G15_MASK:21522,getBCHTypeInfo:function(t){for(var e=t<<10;l.getBCHDigit(e)-l.getBCHDigit(l.G15)>=0;)e^=l.G15<=0;)e^=l.G18<>>=1;return e},getPatternPosition:function(t){return l.PATTERN_POSITION_TABLE[t-1]},getMask:function(t,e,r){switch(t){case a.PATTERN000:return(e+r)%2==0;case a.PATTERN001:return e%2==0;case a.PATTERN010:return r%3==0;case a.PATTERN011:return(e+r)%3==0;case a.PATTERN100:return(Math.floor(e/2)+Math.floor(r/3))%2==0;case a.PATTERN101:return e*r%2+e*r%3==0;case a.PATTERN110:return(e*r%2+e*r%3)%2==0;case a.PATTERN111:return(e*r%3+(e+r)%2)%2==0;default:throw new Error("bad maskPattern:"+t)}},getErrorCorrectPolynomial:function(t){for(var e=new n([1],0),r=0;t>r;r++)e=e.multiply(new n([1,h.gexp(r)],0));return e},getLostPoint:function(t){for(var e=t.getModuleCount(),r=0,o=0,i=0;e>i;i++)for(var n=0,s=t.modules[i][0],u=0;e>u;u++){var a=t.modules[i][u];if(e-6>u&&a&&!t.modules[i][u+1]&&t.modules[i][u+2]&&t.modules[i][u+3]&&t.modules[i][u+4]&&!t.modules[i][u+5]&&t.modules[i][u+6]&&(e-10>u?t.modules[i][u+7]&&t.modules[i][u+8]&&t.modules[i][u+9]&&t.modules[i][u+10]&&(r+=40):u>3&&t.modules[i][u-1]&&t.modules[i][u-2]&&t.modules[i][u-3]&&t.modules[i][u-4]&&(r+=40)),e-1>i&&e-1>u){var l=0;a&&l++,t.modules[i+1][u]&&l++,t.modules[i][u+1]&&l++,t.modules[i+1][u+1]&&l++,(0==l||4==l)&&(r+=3)}s^a?n++:(s=a,n>=5&&(r+=3+n-5),n=1),a&&o++}for(var u=0;e>u;u++)for(var n=0,s=t.modules[0][u],i=0;e>i;i++){var a=t.modules[i][u];e-6>i&&a&&!t.modules[i+1][u]&&t.modules[i+2][u]&&t.modules[i+3][u]&&t.modules[i+4][u]&&!t.modules[i+5][u]&&t.modules[i+6][u]&&(e-10>i?t.modules[i+7][u]&&t.modules[i+8][u]&&t.modules[i+9][u]&&t.modules[i+10][u]&&(r+=40):i>3&&t.modules[i-1][u]&&t.modules[i-2][u]&&t.modules[i-3][u]&&t.modules[i-4][u]&&(r+=40)),s^a?n++:(s=a,n>=5&&(r+=3+n-5),n=1)}var h=Math.abs(100*o/e/e-50)/5;return r+=10*h}},h={glog:function(t){if(1>t)throw new Error("glog("+t+")");return h.LOG_TABLE[t]},gexp:function(t){for(;0>t;)t+=255;for(;t>=256;)t-=255;return h.EXP_TABLE[t]},EXP_TABLE:new Array(256),LOG_TABLE:new Array(256)},g=0;8>g;g++)h.EXP_TABLE[g]=1<g;g++)h.EXP_TABLE[g]=h.EXP_TABLE[g-4]^h.EXP_TABLE[g-5]^h.EXP_TABLE[g-6]^h.EXP_TABLE[g-8];for(var g=0;255>g;g++)h.LOG_TABLE[h.EXP_TABLE[g]]=g;n.prototype={get:function(t){return this.num[t]},getLength:function(){return this.num.length},multiply:function(t){for(var e=new Array(this.getLength()+t.getLength()-1),r=0;re-r)return this;for(var o=new Array(e),i=0;e>i;i++)o[i]=this.get(i);for(;o.length>=r;){for(var s=h.glog(o[0])-h.glog(t.get(0)),i=0;it;t++){var e=f[4*(t-1)+this.errorCorrectLevel];if(void 0==e)throw new Error("bad rs block @ typeNumber:"+t+"/errorCorrectLevel:"+this.errorCorrectLevel);for(var r=e.length/3,o=0,i=0;r>i;i++){var n=e[3*i+0],s=e[3*i+2];o+=s*n}var u=t>9?2:1;if(this.utf8bytes.length+u>>7-t%8&1},put:function(t,e){for(var r=0;e>r;r++)this.putBit(t>>>e-r-1&1)},putBit:function(t){var e=Math.floor(this.length/8);this.buffer.length<=e&&this.buffer.push(0),t&&(this.buffer[e]|=128>>>this.length%8),this.length++}},t.exports=i},function(t,e){t.exports=function(t){for(var e,r=Array.prototype.slice.call(arguments,1),o=0;e=r[o];o++)if(e)for(var i in e)t[i]=e[i];return t}}]); \ No newline at end of file diff --git a/package.json b/package.json index ae027f7..b1d3a4c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "arale-qrcode", - "version": "3.0.5", + "version": "3.0.6", "description": "二维码绘制模块", "homepage": "http://aralejs.org/qrcode/", "author": "倚松 ", diff --git a/src/index.js b/src/index.js index c2ef794..4763c3d 100644 --- a/src/index.js +++ b/src/index.js @@ -140,12 +140,20 @@ extend(qrcode.prototype,{ }; } - //计算每个点的长宽 - var tileW = (ratioSize / count).toPrecision(4); - var tileH = (ratioSize / count).toPrecision(4); + // 计算每个节点的长宽;取整,防止点之间出现分离 + var tileW = Math.floor(ratioSize / count); + var tileH = Math.floor(ratioSize / count); + if(tileW <= 0){ + tileW = count < 80 ? 2 : 1; + } + if(tileH <= 0){ + tileH = count < 80 ? 2 : 1; + } + + canvas.width = tileW * count; + canvas.height = tileH * count; - canvas.width = ratioSize; - canvas.height = ratioSize; + var currImageSize = ratioImgSize * (canvas.width / ratioSize); //绘制 for (var row = 0; row < count; row++) { @@ -164,9 +172,9 @@ extend(qrcode.prototype,{ } if(options.image){ loadImage(options.image, function(img){ - var x = ((ratioSize - ratioImgSize)/2).toFixed(2); - var y = ((ratioSize - ratioImgSize)/2).toFixed(2); - ctx.drawImage(img, x, y, ratioImgSize, ratioImgSize); + var x = ((canvas.width - currImageSize)/2).toFixed(2); + var y = ((canvas.height - currImageSize)/2).toFixed(2); + ctx.drawImage(img, x, y, currImageSize, currImageSize); }); } canvas.style.width = size + 'px'; From 3222267637618295d6c3ea56510a0018b7eb81e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8F=B6=E8=A8=80?= Date: Mon, 26 Oct 2015 19:34:05 +0800 Subject: [PATCH 02/10] tag: fixed 3.0.6 --- HISTORY.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/HISTORY.md b/HISTORY.md index 607068e..43e96c5 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,6 +1,9 @@ # History - --- +## 3.0.6 + +`tag:fixed` 修复不能渲染小数点像素值问题 + ## 3.0.5 `tag:fixed` canvas 模式在 Retina 下显示模糊 From b162dc4c2a23deac69324dec293d0b9827e660a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8F=B6=E8=A8=80?= Date: Wed, 28 Oct 2015 17:14:03 +0800 Subject: [PATCH 03/10] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=8D=E8=83=BD?= =?UTF-8?q?=E6=B8=B2=E6=9F=93=E5=B0=8F=E6=95=B0=E7=82=B9=E5=83=8F=E7=B4=A0?= =?UTF-8?q?=E5=80=BC=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dist/arale-qrcode/3.0.6/index.js | 2 +- src/index.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/dist/arale-qrcode/3.0.6/index.js b/dist/arale-qrcode/3.0.6/index.js index 153b31b..0695885 100644 --- a/dist/arale-qrcode/3.0.6/index.js +++ b/dist/arale-qrcode/3.0.6/index.js @@ -1 +1 @@ -this.AraleQRCode=function(t){function e(o){if(r[o])return r[o].exports;var i=r[o]={exports:{},id:o,loaded:!1};return t[o].call(i.exports,i,i.exports,e),i.loaded=!0,i.exports}var r={};return e.m=t,e.c=r,e.p="",e(0)}([function(t,e,r){t.exports=r(1)},function(t,e,r){"use strict";t.exports=r(2)},function(t,e,r){"use strict";var o=r(4),i=[],n=r(3),s=function(t){var e=t.options;return e.pdground&&(t.row>1&&t.row<5&&t.col>1&&t.col<5||t.row>t.count-6&&t.row1&&t.col<5||t.row>1&&t.row<5&&t.col>t.count-6&&t.colr;r++)if(i[r].text==this.options.text&&i[r].text.correctLevel==this.options.correctLevel){e=i[r].obj;break}if(r==s&&(e=new n(this.options.text,this.options.correctLevel),i.push({text:this.options.text,correctLevel:this.options.correctLevel,obj:e})),this.options.render)switch(this.options.render){case"canvas":return this.createCanvas(e);case"table":return this.createTable(e);case"svg":return this.createSVG(e);default:return this.createDefault(e)}return this.createDefault(e)};o(a.prototype,{createDefault:function(t){var e=document.createElement("canvas");if(e.getContext)return this.createCanvas(t);var r="http://www.w3.org/2000/svg";return document.createElementNS&&document.createElementNS(r,"svg").createSVGRect?this.createSVG(t):this.createTable(t)},createCanvas:function(t){var e=this.options,r=document.createElement("canvas"),o=r.getContext("2d"),i=t.getModuleCount(),n=u(o),a=e.size,l=a*n,h=e.imageSize*n,g=function(t,e){var r=new Image;r.src=t,r.onload=function(){e(this),r.onload=null}},f=Math.floor(l/i),c=Math.floor(l/i);0>=f&&(f=80>i?2:1),0>=c&&(c=80>i?2:1),r.width=f*i,r.height=c*i;for(var d=0;i>d;d++)for(var m=0;i>m;m++){var p=Math.ceil((m+1)*f)-Math.floor(m*f),v=Math.ceil((d+1)*f)-Math.floor(d*f),b=s({row:d,col:m,count:i,options:e});o.fillStyle=t.modules[d][m]?b:e.background,o.fillRect(Math.round(m*f),Math.round(d*c),p,v)}return e.image&&g(e.image,function(t){var e=((l-h)/2).toFixed(2),r=((l-h)/2).toFixed(2);o.drawImage(t,e,r,h,h)}),r.style.width=a+"px",r.style.height=a+"px",r},createTable:function(t){var e=this.options,r=t.getModuleCount(),o=Math.floor(e.size/r),i=Math.floor(e.size/r);0>=o&&(o=80>r?2:1),0>=i&&(i=80>r?2:1);var n=[];n.push('');for(var u=0;r>u;u++){n.push('');for(var a=0;r>a;a++){var l=s({row:u,col:a,count:r,options:e});t.modules[u][a]?n.push(''):n.push('')}n.push("")}if(n.push("
"),e.image){var h=o*r,g=i*r,f=((h-e.imageSize)/2).toFixed(2),c=((g-e.imageSize)/2).toFixed(2);n.unshift("
"),n.push(""),n.push("
")}var d=document.createElement("span");return d.innerHTML=n.join(""),d.firstChild},createSVG:function(t){var e=this.options,r=t.getModuleCount(),o=r/e.size,i=document.createElementNS("http://www.w3.org/2000/svg","svg");i.setAttribute("width",e.size),i.setAttribute("height",e.size),i.setAttribute("viewBox","0 0 "+r+" "+r);for(var n=0;r>n;n++)for(var u=0;r>u;u++){var a=document.createElementNS("http://www.w3.org/2000/svg","rect"),l=s({row:n,col:u,count:r,options:e});a.setAttribute("x",u),a.setAttribute("y",n),a.setAttribute("width",1),a.setAttribute("height",1),a.setAttribute("stroke-width",0),t.modules[n][u]?a.setAttribute("fill",l):a.setAttribute("fill",e.background),i.appendChild(a)}if(e.image){var h=document.createElementNS("http://www.w3.org/2000/svg","image");h.setAttributeNS("http://www.w3.org/1999/xlink","href",e.image),h.setAttribute("x",((r-e.imageSize*o)/2).toFixed(2)),h.setAttribute("y",((r-e.imageSize*o)/2).toFixed(2)),h.setAttribute("width",e.imageSize*o),h.setAttribute("height",e.imageSize*o),i.appendChild(h)}return i}}),t.exports=a},function(t,e){"use strict";function r(t){var e,r,o;return 128>t?[t]:2048>t?(e=192+(t>>6),r=128+(63&t),[e,r]):(e=224+(t>>12),r=128+(t>>6&63),o=128+(63&t),[e,r,o])}function o(t){for(var e=[],o=0;o=7&&this.setupTypeNumber(!0),this.mapData(this.dataCache,t)},setupPositionProbePattern:function(t,e){for(var r=-1;7>=r;r++)if(!(-1>=t+r||this.moduleCount<=t+r))for(var o=-1;7>=o;o++)-1>=e+o||this.moduleCount<=e+o||(r>=0&&6>=r&&(0==o||6==o)||o>=0&&6>=o&&(0==r||6==r)||r>=2&&4>=r&&o>=2&&4>=o?this.modules[t+r][e+o]=!0:this.modules[t+r][e+o]=!1)},createQrcode:function(){for(var t=0,e=0,r=null,o=0;8>o;o++){this.makeImpl(o);var i=l.getLostPoint(this);(0==o||t>i)&&(t=i,e=o,r=this.modules)}this.modules=r,this.setupTypeInfo(!1,e),this.typeNumber>=7&&this.setupTypeNumber(!1)},setupTimingPattern:function(){for(var t=8;t=n;n++)for(var s=-2;2>=s;s++)-2==n||2==n||-2==s||2==s||0==n&&0==s?this.modules[o+n][i+s]=!0:this.modules[o+n][i+s]=!1}},setupTypeNumber:function(t){for(var e=l.getBCHTypeNumber(this.typeNumber),r=0;18>r;r++){var o=!t&&1==(e>>r&1);this.modules[Math.floor(r/3)][r%3+this.moduleCount-8-3]=o,this.modules[r%3+this.moduleCount-8-3][Math.floor(r/3)]=o}},setupTypeInfo:function(t,e){for(var r=u[this.errorCorrectLevel]<<3|e,o=l.getBCHTypeInfo(r),i=0;15>i;i++){var n=!t&&1==(o>>i&1);6>i?this.modules[i][8]=n:8>i?this.modules[i+1][8]=n:this.modules[this.moduleCount-15+i][8]=n;var n=!t&&1==(o>>i&1);8>i?this.modules[8][this.moduleCount-i-1]=n:9>i?this.modules[8][15-i-1+1]=n:this.modules[8][15-i-1]=n}this.modules[this.moduleCount-8][8]=!t},createData:function(){var t=new s,e=this.typeNumber>9?16:8;t.put(4,4),t.put(this.utf8bytes.length,e);for(var r=0,o=this.utf8bytes.length;o>r;r++)t.put(this.utf8bytes[r],8);for(t.length+4<=8*this.totalDataCount&&t.put(0,4);t.length%8!=0;)t.putBit(!1);for(;;){if(t.length>=8*this.totalDataCount)break;if(t.put(i.PAD0,8),t.length>=8*this.totalDataCount)break;t.put(i.PAD1,8)}return this.createBytes(t)},createBytes:function(t){for(var e=0,r=0,o=0,i=this.rsBlock.length/3,s=new Array,u=0;i>u;u++)for(var a=this.rsBlock[3*u+0],h=this.rsBlock[3*u+1],g=this.rsBlock[3*u+2],f=0;a>f;f++)s.push([g,h]);for(var c=new Array(s.length),d=new Array(s.length),m=0;m=0?A.get(T):0}}for(var P=new Array(this.totalDataCount),y=0,u=0;r>u;u++)for(var m=0;mu;u++)for(var m=0;m0;s-=2)for(6==s&&s--;;){for(var u=0;2>u;u++)if(null==this.modules[o][s-u]){var a=!1;n>>i&1));var h=l.getMask(e,o,s-u);h&&(a=!a),this.modules[o][s-u]=a,i--,-1==i&&(n++,i=7)}if(o+=r,0>o||this.moduleCount<=o){o-=r,r=-r;break}}}},i.PAD0=236,i.PAD1=17;for(var u=[1,0,3,2],a={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7},l={PATTERN_POSITION_TABLE:[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58],[6,34,62],[6,26,46,66],[6,26,48,70],[6,26,50,74],[6,30,54,78],[6,30,56,82],[6,30,58,86],[6,34,62,90],[6,28,50,72,94],[6,26,50,74,98],[6,30,54,78,102],[6,28,54,80,106],[6,32,58,84,110],[6,30,58,86,114],[6,34,62,90,118],[6,26,50,74,98,122],[6,30,54,78,102,126],[6,26,52,78,104,130],[6,30,56,82,108,134],[6,34,60,86,112,138],[6,30,58,86,114,142],[6,34,62,90,118,146],[6,30,54,78,102,126,150],[6,24,50,76,102,128,154],[6,28,54,80,106,132,158],[6,32,58,84,110,136,162],[6,26,54,82,110,138,166],[6,30,58,86,114,142,170]],G15:1335,G18:7973,G15_MASK:21522,getBCHTypeInfo:function(t){for(var e=t<<10;l.getBCHDigit(e)-l.getBCHDigit(l.G15)>=0;)e^=l.G15<=0;)e^=l.G18<>>=1;return e},getPatternPosition:function(t){return l.PATTERN_POSITION_TABLE[t-1]},getMask:function(t,e,r){switch(t){case a.PATTERN000:return(e+r)%2==0;case a.PATTERN001:return e%2==0;case a.PATTERN010:return r%3==0;case a.PATTERN011:return(e+r)%3==0;case a.PATTERN100:return(Math.floor(e/2)+Math.floor(r/3))%2==0;case a.PATTERN101:return e*r%2+e*r%3==0;case a.PATTERN110:return(e*r%2+e*r%3)%2==0;case a.PATTERN111:return(e*r%3+(e+r)%2)%2==0;default:throw new Error("bad maskPattern:"+t)}},getErrorCorrectPolynomial:function(t){for(var e=new n([1],0),r=0;t>r;r++)e=e.multiply(new n([1,h.gexp(r)],0));return e},getLostPoint:function(t){for(var e=t.getModuleCount(),r=0,o=0,i=0;e>i;i++)for(var n=0,s=t.modules[i][0],u=0;e>u;u++){var a=t.modules[i][u];if(e-6>u&&a&&!t.modules[i][u+1]&&t.modules[i][u+2]&&t.modules[i][u+3]&&t.modules[i][u+4]&&!t.modules[i][u+5]&&t.modules[i][u+6]&&(e-10>u?t.modules[i][u+7]&&t.modules[i][u+8]&&t.modules[i][u+9]&&t.modules[i][u+10]&&(r+=40):u>3&&t.modules[i][u-1]&&t.modules[i][u-2]&&t.modules[i][u-3]&&t.modules[i][u-4]&&(r+=40)),e-1>i&&e-1>u){var l=0;a&&l++,t.modules[i+1][u]&&l++,t.modules[i][u+1]&&l++,t.modules[i+1][u+1]&&l++,(0==l||4==l)&&(r+=3)}s^a?n++:(s=a,n>=5&&(r+=3+n-5),n=1),a&&o++}for(var u=0;e>u;u++)for(var n=0,s=t.modules[0][u],i=0;e>i;i++){var a=t.modules[i][u];e-6>i&&a&&!t.modules[i+1][u]&&t.modules[i+2][u]&&t.modules[i+3][u]&&t.modules[i+4][u]&&!t.modules[i+5][u]&&t.modules[i+6][u]&&(e-10>i?t.modules[i+7][u]&&t.modules[i+8][u]&&t.modules[i+9][u]&&t.modules[i+10][u]&&(r+=40):i>3&&t.modules[i-1][u]&&t.modules[i-2][u]&&t.modules[i-3][u]&&t.modules[i-4][u]&&(r+=40)),s^a?n++:(s=a,n>=5&&(r+=3+n-5),n=1)}var h=Math.abs(100*o/e/e-50)/5;return r+=10*h}},h={glog:function(t){if(1>t)throw new Error("glog("+t+")");return h.LOG_TABLE[t]},gexp:function(t){for(;0>t;)t+=255;for(;t>=256;)t-=255;return h.EXP_TABLE[t]},EXP_TABLE:new Array(256),LOG_TABLE:new Array(256)},g=0;8>g;g++)h.EXP_TABLE[g]=1<g;g++)h.EXP_TABLE[g]=h.EXP_TABLE[g-4]^h.EXP_TABLE[g-5]^h.EXP_TABLE[g-6]^h.EXP_TABLE[g-8];for(var g=0;255>g;g++)h.LOG_TABLE[h.EXP_TABLE[g]]=g;n.prototype={get:function(t){return this.num[t]},getLength:function(){return this.num.length},multiply:function(t){for(var e=new Array(this.getLength()+t.getLength()-1),r=0;re-r)return this;for(var o=new Array(e),i=0;e>i;i++)o[i]=this.get(i);for(;o.length>=r;){for(var s=h.glog(o[0])-h.glog(t.get(0)),i=0;it;t++){var e=f[4*(t-1)+this.errorCorrectLevel];if(void 0==e)throw new Error("bad rs block @ typeNumber:"+t+"/errorCorrectLevel:"+this.errorCorrectLevel);for(var r=e.length/3,o=0,i=0;r>i;i++){var n=e[3*i+0],s=e[3*i+2];o+=s*n}var u=t>9?2:1;if(this.utf8bytes.length+u>>7-t%8&1},put:function(t,e){for(var r=0;e>r;r++)this.putBit(t>>>e-r-1&1)},putBit:function(t){var e=Math.floor(this.length/8);this.buffer.length<=e&&this.buffer.push(0),t&&(this.buffer[e]|=128>>>this.length%8),this.length++}},t.exports=i},function(t,e){t.exports=function(t){for(var e,r=Array.prototype.slice.call(arguments,1),o=0;e=r[o];o++)if(e)for(var i in e)t[i]=e[i];return t}}]); \ No newline at end of file +this.AraleQRCode=function(t){function e(o){if(r[o])return r[o].exports;var i=r[o]={exports:{},id:o,loaded:!1};return t[o].call(i.exports,i,i.exports,e),i.loaded=!0,i.exports}var r={};return e.m=t,e.c=r,e.p="",e(0)}([function(t,e,r){t.exports=r(1)},function(t,e,r){"use strict";t.exports=r(2)},function(t,e,r){"use strict";var o=r(4),i=[],n=r(3),s=function(t){var e=t.options;return e.pdground&&(t.row>1&&t.row<5&&t.col>1&&t.col<5||t.row>t.count-6&&t.row1&&t.col<5||t.row>1&&t.row<5&&t.col>t.count-6&&t.colr;r++)if(i[r].text==this.options.text&&i[r].text.correctLevel==this.options.correctLevel){e=i[r].obj;break}if(r==s&&(e=new n(this.options.text,this.options.correctLevel),i.push({text:this.options.text,correctLevel:this.options.correctLevel,obj:e})),this.options.render)switch(this.options.render){case"canvas":return this.createCanvas(e);case"table":return this.createTable(e);case"svg":return this.createSVG(e);default:return this.createDefault(e)}return this.createDefault(e)};o(a.prototype,{createDefault:function(t){var e=document.createElement("canvas");if(e.getContext)return this.createCanvas(t);var r="http://www.w3.org/2000/svg";return document.createElementNS&&document.createElementNS(r,"svg").createSVGRect?this.createSVG(t):this.createTable(t)},createCanvas:function(t){var e=this.options,r=document.createElement("canvas"),o=r.getContext("2d"),i=t.getModuleCount(),n=u(o),a=e.size,l=a*n,h=e.imageSize*n,g=function(t,e){var r=new Image;r.src=t,r.onload=function(){e(this),r.onload=null}},f=Math.floor(l/i),d=Math.floor(l/i);0>=f&&(f=80>i?2:1),0>=d&&(d=80>i?2:1),r.width=f*i,r.height=d*i;for(var c=h*(r.width/l),m=0;i>m;m++)for(var p=0;i>p;p++){var v=Math.ceil((p+1)*f)-Math.floor(p*f),w=Math.ceil((m+1)*f)-Math.floor(m*f),b=s({row:m,col:p,count:i,options:e});o.fillStyle=t.modules[m][p]?b:e.background,o.fillRect(Math.round(p*f),Math.round(m*d),v,w)}return e.image&&g(e.image,function(t){var e=((r.width-c)/2).toFixed(2),i=((r.height-c)/2).toFixed(2);o.drawImage(t,e,i,c,c)}),r.style.width=(r.width/n).toFixed(2)+"px",r.style.height=(r.height/n).toFixed(2)+"px",r},createTable:function(t){var e=this.options,r=t.getModuleCount(),o=Math.floor(e.size/r),i=Math.floor(e.size/r);0>=o&&(o=80>r?2:1),0>=i&&(i=80>r?2:1);var n=[];n.push('');for(var u=0;r>u;u++){n.push('');for(var a=0;r>a;a++){var l=s({row:u,col:a,count:r,options:e});t.modules[u][a]?n.push(''):n.push('')}n.push("")}if(n.push("
"),e.image){var h=o*r,g=i*r,f=((h-e.imageSize)/2).toFixed(2),d=((g-e.imageSize)/2).toFixed(2);n.unshift("
"),n.push(""),n.push("
")}var c=document.createElement("span");return c.innerHTML=n.join(""),c.firstChild},createSVG:function(t){var e=this.options,r=t.getModuleCount(),o=r/e.size,i=document.createElementNS("http://www.w3.org/2000/svg","svg");i.setAttribute("width",e.size),i.setAttribute("height",e.size),i.setAttribute("viewBox","0 0 "+r+" "+r);for(var n=0;r>n;n++)for(var u=0;r>u;u++){var a=document.createElementNS("http://www.w3.org/2000/svg","rect"),l=s({row:n,col:u,count:r,options:e});a.setAttribute("x",u),a.setAttribute("y",n),a.setAttribute("width",1),a.setAttribute("height",1),a.setAttribute("stroke-width",0),t.modules[n][u]?a.setAttribute("fill",l):a.setAttribute("fill",e.background),i.appendChild(a)}if(e.image){var h=document.createElementNS("http://www.w3.org/2000/svg","image");h.setAttributeNS("http://www.w3.org/1999/xlink","href",e.image),h.setAttribute("x",((r-e.imageSize*o)/2).toFixed(2)),h.setAttribute("y",((r-e.imageSize*o)/2).toFixed(2)),h.setAttribute("width",e.imageSize*o),h.setAttribute("height",e.imageSize*o),i.appendChild(h)}return i}}),t.exports=a},function(t,e){"use strict";function r(t){var e,r,o;return 128>t?[t]:2048>t?(e=192+(t>>6),r=128+(63&t),[e,r]):(e=224+(t>>12),r=128+(t>>6&63),o=128+(63&t),[e,r,o])}function o(t){for(var e=[],o=0;o=7&&this.setupTypeNumber(!0),this.mapData(this.dataCache,t)},setupPositionProbePattern:function(t,e){for(var r=-1;7>=r;r++)if(!(-1>=t+r||this.moduleCount<=t+r))for(var o=-1;7>=o;o++)-1>=e+o||this.moduleCount<=e+o||(r>=0&&6>=r&&(0==o||6==o)||o>=0&&6>=o&&(0==r||6==r)||r>=2&&4>=r&&o>=2&&4>=o?this.modules[t+r][e+o]=!0:this.modules[t+r][e+o]=!1)},createQrcode:function(){for(var t=0,e=0,r=null,o=0;8>o;o++){this.makeImpl(o);var i=l.getLostPoint(this);(0==o||t>i)&&(t=i,e=o,r=this.modules)}this.modules=r,this.setupTypeInfo(!1,e),this.typeNumber>=7&&this.setupTypeNumber(!1)},setupTimingPattern:function(){for(var t=8;t=n;n++)for(var s=-2;2>=s;s++)-2==n||2==n||-2==s||2==s||0==n&&0==s?this.modules[o+n][i+s]=!0:this.modules[o+n][i+s]=!1}},setupTypeNumber:function(t){for(var e=l.getBCHTypeNumber(this.typeNumber),r=0;18>r;r++){var o=!t&&1==(e>>r&1);this.modules[Math.floor(r/3)][r%3+this.moduleCount-8-3]=o,this.modules[r%3+this.moduleCount-8-3][Math.floor(r/3)]=o}},setupTypeInfo:function(t,e){for(var r=u[this.errorCorrectLevel]<<3|e,o=l.getBCHTypeInfo(r),i=0;15>i;i++){var n=!t&&1==(o>>i&1);6>i?this.modules[i][8]=n:8>i?this.modules[i+1][8]=n:this.modules[this.moduleCount-15+i][8]=n;var n=!t&&1==(o>>i&1);8>i?this.modules[8][this.moduleCount-i-1]=n:9>i?this.modules[8][15-i-1+1]=n:this.modules[8][15-i-1]=n}this.modules[this.moduleCount-8][8]=!t},createData:function(){var t=new s,e=this.typeNumber>9?16:8;t.put(4,4),t.put(this.utf8bytes.length,e);for(var r=0,o=this.utf8bytes.length;o>r;r++)t.put(this.utf8bytes[r],8);for(t.length+4<=8*this.totalDataCount&&t.put(0,4);t.length%8!=0;)t.putBit(!1);for(;;){if(t.length>=8*this.totalDataCount)break;if(t.put(i.PAD0,8),t.length>=8*this.totalDataCount)break;t.put(i.PAD1,8)}return this.createBytes(t)},createBytes:function(t){for(var e=0,r=0,o=0,i=this.rsBlock.length/3,s=new Array,u=0;i>u;u++)for(var a=this.rsBlock[3*u+0],h=this.rsBlock[3*u+1],g=this.rsBlock[3*u+2],f=0;a>f;f++)s.push([g,h]);for(var d=new Array(s.length),c=new Array(s.length),m=0;m=0?A.get(T):0}}for(var P=new Array(this.totalDataCount),x=0,u=0;r>u;u++)for(var m=0;mu;u++)for(var m=0;m0;s-=2)for(6==s&&s--;;){for(var u=0;2>u;u++)if(null==this.modules[o][s-u]){var a=!1;n>>i&1));var h=l.getMask(e,o,s-u);h&&(a=!a),this.modules[o][s-u]=a,i--,-1==i&&(n++,i=7)}if(o+=r,0>o||this.moduleCount<=o){o-=r,r=-r;break}}}},i.PAD0=236,i.PAD1=17;for(var u=[1,0,3,2],a={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7},l={PATTERN_POSITION_TABLE:[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58],[6,34,62],[6,26,46,66],[6,26,48,70],[6,26,50,74],[6,30,54,78],[6,30,56,82],[6,30,58,86],[6,34,62,90],[6,28,50,72,94],[6,26,50,74,98],[6,30,54,78,102],[6,28,54,80,106],[6,32,58,84,110],[6,30,58,86,114],[6,34,62,90,118],[6,26,50,74,98,122],[6,30,54,78,102,126],[6,26,52,78,104,130],[6,30,56,82,108,134],[6,34,60,86,112,138],[6,30,58,86,114,142],[6,34,62,90,118,146],[6,30,54,78,102,126,150],[6,24,50,76,102,128,154],[6,28,54,80,106,132,158],[6,32,58,84,110,136,162],[6,26,54,82,110,138,166],[6,30,58,86,114,142,170]],G15:1335,G18:7973,G15_MASK:21522,getBCHTypeInfo:function(t){for(var e=t<<10;l.getBCHDigit(e)-l.getBCHDigit(l.G15)>=0;)e^=l.G15<=0;)e^=l.G18<>>=1;return e},getPatternPosition:function(t){return l.PATTERN_POSITION_TABLE[t-1]},getMask:function(t,e,r){switch(t){case a.PATTERN000:return(e+r)%2==0;case a.PATTERN001:return e%2==0;case a.PATTERN010:return r%3==0;case a.PATTERN011:return(e+r)%3==0;case a.PATTERN100:return(Math.floor(e/2)+Math.floor(r/3))%2==0;case a.PATTERN101:return e*r%2+e*r%3==0;case a.PATTERN110:return(e*r%2+e*r%3)%2==0;case a.PATTERN111:return(e*r%3+(e+r)%2)%2==0;default:throw new Error("bad maskPattern:"+t)}},getErrorCorrectPolynomial:function(t){for(var e=new n([1],0),r=0;t>r;r++)e=e.multiply(new n([1,h.gexp(r)],0));return e},getLostPoint:function(t){for(var e=t.getModuleCount(),r=0,o=0,i=0;e>i;i++)for(var n=0,s=t.modules[i][0],u=0;e>u;u++){var a=t.modules[i][u];if(e-6>u&&a&&!t.modules[i][u+1]&&t.modules[i][u+2]&&t.modules[i][u+3]&&t.modules[i][u+4]&&!t.modules[i][u+5]&&t.modules[i][u+6]&&(e-10>u?t.modules[i][u+7]&&t.modules[i][u+8]&&t.modules[i][u+9]&&t.modules[i][u+10]&&(r+=40):u>3&&t.modules[i][u-1]&&t.modules[i][u-2]&&t.modules[i][u-3]&&t.modules[i][u-4]&&(r+=40)),e-1>i&&e-1>u){var l=0;a&&l++,t.modules[i+1][u]&&l++,t.modules[i][u+1]&&l++,t.modules[i+1][u+1]&&l++,(0==l||4==l)&&(r+=3)}s^a?n++:(s=a,n>=5&&(r+=3+n-5),n=1),a&&o++}for(var u=0;e>u;u++)for(var n=0,s=t.modules[0][u],i=0;e>i;i++){var a=t.modules[i][u];e-6>i&&a&&!t.modules[i+1][u]&&t.modules[i+2][u]&&t.modules[i+3][u]&&t.modules[i+4][u]&&!t.modules[i+5][u]&&t.modules[i+6][u]&&(e-10>i?t.modules[i+7][u]&&t.modules[i+8][u]&&t.modules[i+9][u]&&t.modules[i+10][u]&&(r+=40):i>3&&t.modules[i-1][u]&&t.modules[i-2][u]&&t.modules[i-3][u]&&t.modules[i-4][u]&&(r+=40)),s^a?n++:(s=a,n>=5&&(r+=3+n-5),n=1)}var h=Math.abs(100*o/e/e-50)/5;return r+=10*h}},h={glog:function(t){if(1>t)throw new Error("glog("+t+")");return h.LOG_TABLE[t]},gexp:function(t){for(;0>t;)t+=255;for(;t>=256;)t-=255;return h.EXP_TABLE[t]},EXP_TABLE:new Array(256),LOG_TABLE:new Array(256)},g=0;8>g;g++)h.EXP_TABLE[g]=1<g;g++)h.EXP_TABLE[g]=h.EXP_TABLE[g-4]^h.EXP_TABLE[g-5]^h.EXP_TABLE[g-6]^h.EXP_TABLE[g-8];for(var g=0;255>g;g++)h.LOG_TABLE[h.EXP_TABLE[g]]=g;n.prototype={get:function(t){return this.num[t]},getLength:function(){return this.num.length},multiply:function(t){for(var e=new Array(this.getLength()+t.getLength()-1),r=0;re-r)return this;for(var o=new Array(e),i=0;e>i;i++)o[i]=this.get(i);for(;o.length>=r;){for(var s=h.glog(o[0])-h.glog(t.get(0)),i=0;it;t++){var e=f[4*(t-1)+this.errorCorrectLevel];if(void 0==e)throw new Error("bad rs block @ typeNumber:"+t+"/errorCorrectLevel:"+this.errorCorrectLevel);for(var r=e.length/3,o=0,i=0;r>i;i++){var n=e[3*i+0],s=e[3*i+2];o+=s*n}var u=t>9?2:1;if(this.utf8bytes.length+u>>7-t%8&1},put:function(t,e){for(var r=0;e>r;r++)this.putBit(t>>>e-r-1&1)},putBit:function(t){var e=Math.floor(this.length/8);this.buffer.length<=e&&this.buffer.push(0),t&&(this.buffer[e]|=128>>>this.length%8),this.length++}},t.exports=i},function(t,e){t.exports=function(t){for(var e,r=Array.prototype.slice.call(arguments,1),o=0;e=r[o];o++)if(e)for(var i in e)t[i]=e[i];return t}}]); \ No newline at end of file diff --git a/src/index.js b/src/index.js index 4763c3d..c9a7f1b 100644 --- a/src/index.js +++ b/src/index.js @@ -177,8 +177,8 @@ extend(qrcode.prototype,{ ctx.drawImage(img, x, y, currImageSize, currImageSize); }); } - canvas.style.width = size + 'px'; - canvas.style.height = size + 'px'; + canvas.style.width = (canvas.width/ratio).toFixed(2) + 'px'; + canvas.style.height = (canvas.height/ratio).toFixed(2) + 'px'; return canvas; }, // table create From 122fe9cc2f94d4c2e20ddc0e488a27a802dff4b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8F=B6=E8=A8=80?= Date: Wed, 28 Oct 2015 17:44:47 +0800 Subject: [PATCH 04/10] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=8D=E8=83=BD?= =?UTF-8?q?=E6=B8=B2=E6=9F=93=E5=B0=8F=E6=95=B0=E7=82=B9=E5=83=8F=E7=B4=A0?= =?UTF-8?q?=E5=80=BC=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dist/arale-qrcode/3.0.6/index.js | 2 +- src/index.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/dist/arale-qrcode/3.0.6/index.js b/dist/arale-qrcode/3.0.6/index.js index 0695885..b6cc851 100644 --- a/dist/arale-qrcode/3.0.6/index.js +++ b/dist/arale-qrcode/3.0.6/index.js @@ -1 +1 @@ -this.AraleQRCode=function(t){function e(o){if(r[o])return r[o].exports;var i=r[o]={exports:{},id:o,loaded:!1};return t[o].call(i.exports,i,i.exports,e),i.loaded=!0,i.exports}var r={};return e.m=t,e.c=r,e.p="",e(0)}([function(t,e,r){t.exports=r(1)},function(t,e,r){"use strict";t.exports=r(2)},function(t,e,r){"use strict";var o=r(4),i=[],n=r(3),s=function(t){var e=t.options;return e.pdground&&(t.row>1&&t.row<5&&t.col>1&&t.col<5||t.row>t.count-6&&t.row1&&t.col<5||t.row>1&&t.row<5&&t.col>t.count-6&&t.colr;r++)if(i[r].text==this.options.text&&i[r].text.correctLevel==this.options.correctLevel){e=i[r].obj;break}if(r==s&&(e=new n(this.options.text,this.options.correctLevel),i.push({text:this.options.text,correctLevel:this.options.correctLevel,obj:e})),this.options.render)switch(this.options.render){case"canvas":return this.createCanvas(e);case"table":return this.createTable(e);case"svg":return this.createSVG(e);default:return this.createDefault(e)}return this.createDefault(e)};o(a.prototype,{createDefault:function(t){var e=document.createElement("canvas");if(e.getContext)return this.createCanvas(t);var r="http://www.w3.org/2000/svg";return document.createElementNS&&document.createElementNS(r,"svg").createSVGRect?this.createSVG(t):this.createTable(t)},createCanvas:function(t){var e=this.options,r=document.createElement("canvas"),o=r.getContext("2d"),i=t.getModuleCount(),n=u(o),a=e.size,l=a*n,h=e.imageSize*n,g=function(t,e){var r=new Image;r.src=t,r.onload=function(){e(this),r.onload=null}},f=Math.floor(l/i),d=Math.floor(l/i);0>=f&&(f=80>i?2:1),0>=d&&(d=80>i?2:1),r.width=f*i,r.height=d*i;for(var c=h*(r.width/l),m=0;i>m;m++)for(var p=0;i>p;p++){var v=Math.ceil((p+1)*f)-Math.floor(p*f),w=Math.ceil((m+1)*f)-Math.floor(m*f),b=s({row:m,col:p,count:i,options:e});o.fillStyle=t.modules[m][p]?b:e.background,o.fillRect(Math.round(p*f),Math.round(m*d),v,w)}return e.image&&g(e.image,function(t){var e=((r.width-c)/2).toFixed(2),i=((r.height-c)/2).toFixed(2);o.drawImage(t,e,i,c,c)}),r.style.width=(r.width/n).toFixed(2)+"px",r.style.height=(r.height/n).toFixed(2)+"px",r},createTable:function(t){var e=this.options,r=t.getModuleCount(),o=Math.floor(e.size/r),i=Math.floor(e.size/r);0>=o&&(o=80>r?2:1),0>=i&&(i=80>r?2:1);var n=[];n.push('');for(var u=0;r>u;u++){n.push('');for(var a=0;r>a;a++){var l=s({row:u,col:a,count:r,options:e});t.modules[u][a]?n.push(''):n.push('')}n.push("")}if(n.push("
"),e.image){var h=o*r,g=i*r,f=((h-e.imageSize)/2).toFixed(2),d=((g-e.imageSize)/2).toFixed(2);n.unshift("
"),n.push(""),n.push("
")}var c=document.createElement("span");return c.innerHTML=n.join(""),c.firstChild},createSVG:function(t){var e=this.options,r=t.getModuleCount(),o=r/e.size,i=document.createElementNS("http://www.w3.org/2000/svg","svg");i.setAttribute("width",e.size),i.setAttribute("height",e.size),i.setAttribute("viewBox","0 0 "+r+" "+r);for(var n=0;r>n;n++)for(var u=0;r>u;u++){var a=document.createElementNS("http://www.w3.org/2000/svg","rect"),l=s({row:n,col:u,count:r,options:e});a.setAttribute("x",u),a.setAttribute("y",n),a.setAttribute("width",1),a.setAttribute("height",1),a.setAttribute("stroke-width",0),t.modules[n][u]?a.setAttribute("fill",l):a.setAttribute("fill",e.background),i.appendChild(a)}if(e.image){var h=document.createElementNS("http://www.w3.org/2000/svg","image");h.setAttributeNS("http://www.w3.org/1999/xlink","href",e.image),h.setAttribute("x",((r-e.imageSize*o)/2).toFixed(2)),h.setAttribute("y",((r-e.imageSize*o)/2).toFixed(2)),h.setAttribute("width",e.imageSize*o),h.setAttribute("height",e.imageSize*o),i.appendChild(h)}return i}}),t.exports=a},function(t,e){"use strict";function r(t){var e,r,o;return 128>t?[t]:2048>t?(e=192+(t>>6),r=128+(63&t),[e,r]):(e=224+(t>>12),r=128+(t>>6&63),o=128+(63&t),[e,r,o])}function o(t){for(var e=[],o=0;o=7&&this.setupTypeNumber(!0),this.mapData(this.dataCache,t)},setupPositionProbePattern:function(t,e){for(var r=-1;7>=r;r++)if(!(-1>=t+r||this.moduleCount<=t+r))for(var o=-1;7>=o;o++)-1>=e+o||this.moduleCount<=e+o||(r>=0&&6>=r&&(0==o||6==o)||o>=0&&6>=o&&(0==r||6==r)||r>=2&&4>=r&&o>=2&&4>=o?this.modules[t+r][e+o]=!0:this.modules[t+r][e+o]=!1)},createQrcode:function(){for(var t=0,e=0,r=null,o=0;8>o;o++){this.makeImpl(o);var i=l.getLostPoint(this);(0==o||t>i)&&(t=i,e=o,r=this.modules)}this.modules=r,this.setupTypeInfo(!1,e),this.typeNumber>=7&&this.setupTypeNumber(!1)},setupTimingPattern:function(){for(var t=8;t=n;n++)for(var s=-2;2>=s;s++)-2==n||2==n||-2==s||2==s||0==n&&0==s?this.modules[o+n][i+s]=!0:this.modules[o+n][i+s]=!1}},setupTypeNumber:function(t){for(var e=l.getBCHTypeNumber(this.typeNumber),r=0;18>r;r++){var o=!t&&1==(e>>r&1);this.modules[Math.floor(r/3)][r%3+this.moduleCount-8-3]=o,this.modules[r%3+this.moduleCount-8-3][Math.floor(r/3)]=o}},setupTypeInfo:function(t,e){for(var r=u[this.errorCorrectLevel]<<3|e,o=l.getBCHTypeInfo(r),i=0;15>i;i++){var n=!t&&1==(o>>i&1);6>i?this.modules[i][8]=n:8>i?this.modules[i+1][8]=n:this.modules[this.moduleCount-15+i][8]=n;var n=!t&&1==(o>>i&1);8>i?this.modules[8][this.moduleCount-i-1]=n:9>i?this.modules[8][15-i-1+1]=n:this.modules[8][15-i-1]=n}this.modules[this.moduleCount-8][8]=!t},createData:function(){var t=new s,e=this.typeNumber>9?16:8;t.put(4,4),t.put(this.utf8bytes.length,e);for(var r=0,o=this.utf8bytes.length;o>r;r++)t.put(this.utf8bytes[r],8);for(t.length+4<=8*this.totalDataCount&&t.put(0,4);t.length%8!=0;)t.putBit(!1);for(;;){if(t.length>=8*this.totalDataCount)break;if(t.put(i.PAD0,8),t.length>=8*this.totalDataCount)break;t.put(i.PAD1,8)}return this.createBytes(t)},createBytes:function(t){for(var e=0,r=0,o=0,i=this.rsBlock.length/3,s=new Array,u=0;i>u;u++)for(var a=this.rsBlock[3*u+0],h=this.rsBlock[3*u+1],g=this.rsBlock[3*u+2],f=0;a>f;f++)s.push([g,h]);for(var d=new Array(s.length),c=new Array(s.length),m=0;m=0?A.get(T):0}}for(var P=new Array(this.totalDataCount),x=0,u=0;r>u;u++)for(var m=0;mu;u++)for(var m=0;m0;s-=2)for(6==s&&s--;;){for(var u=0;2>u;u++)if(null==this.modules[o][s-u]){var a=!1;n>>i&1));var h=l.getMask(e,o,s-u);h&&(a=!a),this.modules[o][s-u]=a,i--,-1==i&&(n++,i=7)}if(o+=r,0>o||this.moduleCount<=o){o-=r,r=-r;break}}}},i.PAD0=236,i.PAD1=17;for(var u=[1,0,3,2],a={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7},l={PATTERN_POSITION_TABLE:[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58],[6,34,62],[6,26,46,66],[6,26,48,70],[6,26,50,74],[6,30,54,78],[6,30,56,82],[6,30,58,86],[6,34,62,90],[6,28,50,72,94],[6,26,50,74,98],[6,30,54,78,102],[6,28,54,80,106],[6,32,58,84,110],[6,30,58,86,114],[6,34,62,90,118],[6,26,50,74,98,122],[6,30,54,78,102,126],[6,26,52,78,104,130],[6,30,56,82,108,134],[6,34,60,86,112,138],[6,30,58,86,114,142],[6,34,62,90,118,146],[6,30,54,78,102,126,150],[6,24,50,76,102,128,154],[6,28,54,80,106,132,158],[6,32,58,84,110,136,162],[6,26,54,82,110,138,166],[6,30,58,86,114,142,170]],G15:1335,G18:7973,G15_MASK:21522,getBCHTypeInfo:function(t){for(var e=t<<10;l.getBCHDigit(e)-l.getBCHDigit(l.G15)>=0;)e^=l.G15<=0;)e^=l.G18<>>=1;return e},getPatternPosition:function(t){return l.PATTERN_POSITION_TABLE[t-1]},getMask:function(t,e,r){switch(t){case a.PATTERN000:return(e+r)%2==0;case a.PATTERN001:return e%2==0;case a.PATTERN010:return r%3==0;case a.PATTERN011:return(e+r)%3==0;case a.PATTERN100:return(Math.floor(e/2)+Math.floor(r/3))%2==0;case a.PATTERN101:return e*r%2+e*r%3==0;case a.PATTERN110:return(e*r%2+e*r%3)%2==0;case a.PATTERN111:return(e*r%3+(e+r)%2)%2==0;default:throw new Error("bad maskPattern:"+t)}},getErrorCorrectPolynomial:function(t){for(var e=new n([1],0),r=0;t>r;r++)e=e.multiply(new n([1,h.gexp(r)],0));return e},getLostPoint:function(t){for(var e=t.getModuleCount(),r=0,o=0,i=0;e>i;i++)for(var n=0,s=t.modules[i][0],u=0;e>u;u++){var a=t.modules[i][u];if(e-6>u&&a&&!t.modules[i][u+1]&&t.modules[i][u+2]&&t.modules[i][u+3]&&t.modules[i][u+4]&&!t.modules[i][u+5]&&t.modules[i][u+6]&&(e-10>u?t.modules[i][u+7]&&t.modules[i][u+8]&&t.modules[i][u+9]&&t.modules[i][u+10]&&(r+=40):u>3&&t.modules[i][u-1]&&t.modules[i][u-2]&&t.modules[i][u-3]&&t.modules[i][u-4]&&(r+=40)),e-1>i&&e-1>u){var l=0;a&&l++,t.modules[i+1][u]&&l++,t.modules[i][u+1]&&l++,t.modules[i+1][u+1]&&l++,(0==l||4==l)&&(r+=3)}s^a?n++:(s=a,n>=5&&(r+=3+n-5),n=1),a&&o++}for(var u=0;e>u;u++)for(var n=0,s=t.modules[0][u],i=0;e>i;i++){var a=t.modules[i][u];e-6>i&&a&&!t.modules[i+1][u]&&t.modules[i+2][u]&&t.modules[i+3][u]&&t.modules[i+4][u]&&!t.modules[i+5][u]&&t.modules[i+6][u]&&(e-10>i?t.modules[i+7][u]&&t.modules[i+8][u]&&t.modules[i+9][u]&&t.modules[i+10][u]&&(r+=40):i>3&&t.modules[i-1][u]&&t.modules[i-2][u]&&t.modules[i-3][u]&&t.modules[i-4][u]&&(r+=40)),s^a?n++:(s=a,n>=5&&(r+=3+n-5),n=1)}var h=Math.abs(100*o/e/e-50)/5;return r+=10*h}},h={glog:function(t){if(1>t)throw new Error("glog("+t+")");return h.LOG_TABLE[t]},gexp:function(t){for(;0>t;)t+=255;for(;t>=256;)t-=255;return h.EXP_TABLE[t]},EXP_TABLE:new Array(256),LOG_TABLE:new Array(256)},g=0;8>g;g++)h.EXP_TABLE[g]=1<g;g++)h.EXP_TABLE[g]=h.EXP_TABLE[g-4]^h.EXP_TABLE[g-5]^h.EXP_TABLE[g-6]^h.EXP_TABLE[g-8];for(var g=0;255>g;g++)h.LOG_TABLE[h.EXP_TABLE[g]]=g;n.prototype={get:function(t){return this.num[t]},getLength:function(){return this.num.length},multiply:function(t){for(var e=new Array(this.getLength()+t.getLength()-1),r=0;re-r)return this;for(var o=new Array(e),i=0;e>i;i++)o[i]=this.get(i);for(;o.length>=r;){for(var s=h.glog(o[0])-h.glog(t.get(0)),i=0;it;t++){var e=f[4*(t-1)+this.errorCorrectLevel];if(void 0==e)throw new Error("bad rs block @ typeNumber:"+t+"/errorCorrectLevel:"+this.errorCorrectLevel);for(var r=e.length/3,o=0,i=0;r>i;i++){var n=e[3*i+0],s=e[3*i+2];o+=s*n}var u=t>9?2:1;if(this.utf8bytes.length+u>>7-t%8&1},put:function(t,e){for(var r=0;e>r;r++)this.putBit(t>>>e-r-1&1)},putBit:function(t){var e=Math.floor(this.length/8);this.buffer.length<=e&&this.buffer.push(0),t&&(this.buffer[e]|=128>>>this.length%8),this.length++}},t.exports=i},function(t,e){t.exports=function(t){for(var e,r=Array.prototype.slice.call(arguments,1),o=0;e=r[o];o++)if(e)for(var i in e)t[i]=e[i];return t}}]); \ No newline at end of file +this.AraleQRCode=function(t){function e(o){if(r[o])return r[o].exports;var i=r[o]={exports:{},id:o,loaded:!1};return t[o].call(i.exports,i,i.exports,e),i.loaded=!0,i.exports}var r={};return e.m=t,e.c=r,e.p="",e(0)}([function(t,e,r){t.exports=r(1)},function(t,e,r){"use strict";t.exports=r(2)},function(t,e,r){"use strict";var o=r(4),i=[],n=r(3),s=function(t){var e=t.options;return e.pdground&&(t.row>1&&t.row<5&&t.col>1&&t.col<5||t.row>t.count-6&&t.row1&&t.col<5||t.row>1&&t.row<5&&t.col>t.count-6&&t.colr;r++)if(i[r].text==this.options.text&&i[r].text.correctLevel==this.options.correctLevel){e=i[r].obj;break}if(r==s&&(e=new n(this.options.text,this.options.correctLevel),i.push({text:this.options.text,correctLevel:this.options.correctLevel,obj:e})),this.options.render)switch(this.options.render){case"canvas":return this.createCanvas(e);case"table":return this.createTable(e);case"svg":return this.createSVG(e);default:return this.createDefault(e)}return this.createDefault(e)};o(a.prototype,{createDefault:function(t){var e=document.createElement("canvas");if(e.getContext)return this.createCanvas(t);var r="http://www.w3.org/2000/svg";return document.createElementNS&&document.createElementNS(r,"svg").createSVGRect?this.createSVG(t):this.createTable(t)},createCanvas:function(t){var e=this.options,r=document.createElement("canvas"),o=r.getContext("2d"),i=t.getModuleCount(),n=u(o),a=e.size,l=a*n,h=e.imageSize*n,g=function(t,e){var r=new Image;r.src=t,r.onload=function(){e(this),r.onload=null}},f=Math.floor(l/i),c=Math.floor(l/i);0>=f&&(f=80>i?2:1),0>=c&&(c=80>i?2:1),r.width=f*i,r.height=c*i;for(var d=h*(r.width/l),m=0;i>m;m++)for(var p=0;i>p;p++){var v=Math.ceil((p+1)*f)-Math.floor(p*f),w=Math.ceil((m+1)*f)-Math.floor(m*f),b=s({row:m,col:p,count:i,options:e});o.fillStyle=t.modules[m][p]?b:e.background,o.fillRect(Math.round(p*f),Math.round(m*c),v,w)}return e.image&&g(e.image,function(t){var e=((r.width-d)/2).toFixed(2),i=((r.height-d)/2).toFixed(2);o.drawImage(t,e,i,d,d)}),r.style.width=Math.floor(r.width/n)+"px",r.style.height=Math.floor(r.height/n)+"px",r},createTable:function(t){var e=this.options,r=t.getModuleCount(),o=Math.floor(e.size/r),i=Math.floor(e.size/r);0>=o&&(o=80>r?2:1),0>=i&&(i=80>r?2:1);var n=[];n.push('');for(var u=0;r>u;u++){n.push('');for(var a=0;r>a;a++){var l=s({row:u,col:a,count:r,options:e});t.modules[u][a]?n.push(''):n.push('')}n.push("")}if(n.push("
"),e.image){var h=o*r,g=i*r,f=((h-e.imageSize)/2).toFixed(2),c=((g-e.imageSize)/2).toFixed(2);n.unshift("
"),n.push(""),n.push("
")}var d=document.createElement("span");return d.innerHTML=n.join(""),d.firstChild},createSVG:function(t){var e=this.options,r=t.getModuleCount(),o=r/e.size,i=document.createElementNS("http://www.w3.org/2000/svg","svg");i.setAttribute("width",e.size),i.setAttribute("height",e.size),i.setAttribute("viewBox","0 0 "+r+" "+r);for(var n=0;r>n;n++)for(var u=0;r>u;u++){var a=document.createElementNS("http://www.w3.org/2000/svg","rect"),l=s({row:n,col:u,count:r,options:e});a.setAttribute("x",u),a.setAttribute("y",n),a.setAttribute("width",1),a.setAttribute("height",1),a.setAttribute("stroke-width",0),t.modules[n][u]?a.setAttribute("fill",l):a.setAttribute("fill",e.background),i.appendChild(a)}if(e.image){var h=document.createElementNS("http://www.w3.org/2000/svg","image");h.setAttributeNS("http://www.w3.org/1999/xlink","href",e.image),h.setAttribute("x",((r-e.imageSize*o)/2).toFixed(2)),h.setAttribute("y",((r-e.imageSize*o)/2).toFixed(2)),h.setAttribute("width",e.imageSize*o),h.setAttribute("height",e.imageSize*o),i.appendChild(h)}return i}}),t.exports=a},function(t,e){"use strict";function r(t){var e,r,o;return 128>t?[t]:2048>t?(e=192+(t>>6),r=128+(63&t),[e,r]):(e=224+(t>>12),r=128+(t>>6&63),o=128+(63&t),[e,r,o])}function o(t){for(var e=[],o=0;o=7&&this.setupTypeNumber(!0),this.mapData(this.dataCache,t)},setupPositionProbePattern:function(t,e){for(var r=-1;7>=r;r++)if(!(-1>=t+r||this.moduleCount<=t+r))for(var o=-1;7>=o;o++)-1>=e+o||this.moduleCount<=e+o||(r>=0&&6>=r&&(0==o||6==o)||o>=0&&6>=o&&(0==r||6==r)||r>=2&&4>=r&&o>=2&&4>=o?this.modules[t+r][e+o]=!0:this.modules[t+r][e+o]=!1)},createQrcode:function(){for(var t=0,e=0,r=null,o=0;8>o;o++){this.makeImpl(o);var i=l.getLostPoint(this);(0==o||t>i)&&(t=i,e=o,r=this.modules)}this.modules=r,this.setupTypeInfo(!1,e),this.typeNumber>=7&&this.setupTypeNumber(!1)},setupTimingPattern:function(){for(var t=8;t=n;n++)for(var s=-2;2>=s;s++)-2==n||2==n||-2==s||2==s||0==n&&0==s?this.modules[o+n][i+s]=!0:this.modules[o+n][i+s]=!1}},setupTypeNumber:function(t){for(var e=l.getBCHTypeNumber(this.typeNumber),r=0;18>r;r++){var o=!t&&1==(e>>r&1);this.modules[Math.floor(r/3)][r%3+this.moduleCount-8-3]=o,this.modules[r%3+this.moduleCount-8-3][Math.floor(r/3)]=o}},setupTypeInfo:function(t,e){for(var r=u[this.errorCorrectLevel]<<3|e,o=l.getBCHTypeInfo(r),i=0;15>i;i++){var n=!t&&1==(o>>i&1);6>i?this.modules[i][8]=n:8>i?this.modules[i+1][8]=n:this.modules[this.moduleCount-15+i][8]=n;var n=!t&&1==(o>>i&1);8>i?this.modules[8][this.moduleCount-i-1]=n:9>i?this.modules[8][15-i-1+1]=n:this.modules[8][15-i-1]=n}this.modules[this.moduleCount-8][8]=!t},createData:function(){var t=new s,e=this.typeNumber>9?16:8;t.put(4,4),t.put(this.utf8bytes.length,e);for(var r=0,o=this.utf8bytes.length;o>r;r++)t.put(this.utf8bytes[r],8);for(t.length+4<=8*this.totalDataCount&&t.put(0,4);t.length%8!=0;)t.putBit(!1);for(;;){if(t.length>=8*this.totalDataCount)break;if(t.put(i.PAD0,8),t.length>=8*this.totalDataCount)break;t.put(i.PAD1,8)}return this.createBytes(t)},createBytes:function(t){for(var e=0,r=0,o=0,i=this.rsBlock.length/3,s=new Array,u=0;i>u;u++)for(var a=this.rsBlock[3*u+0],h=this.rsBlock[3*u+1],g=this.rsBlock[3*u+2],f=0;a>f;f++)s.push([g,h]);for(var c=new Array(s.length),d=new Array(s.length),m=0;m=0?A.get(T):0}}for(var P=new Array(this.totalDataCount),y=0,u=0;r>u;u++)for(var m=0;mu;u++)for(var m=0;m0;s-=2)for(6==s&&s--;;){for(var u=0;2>u;u++)if(null==this.modules[o][s-u]){var a=!1;n>>i&1));var h=l.getMask(e,o,s-u);h&&(a=!a),this.modules[o][s-u]=a,i--,-1==i&&(n++,i=7)}if(o+=r,0>o||this.moduleCount<=o){o-=r,r=-r;break}}}},i.PAD0=236,i.PAD1=17;for(var u=[1,0,3,2],a={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7},l={PATTERN_POSITION_TABLE:[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58],[6,34,62],[6,26,46,66],[6,26,48,70],[6,26,50,74],[6,30,54,78],[6,30,56,82],[6,30,58,86],[6,34,62,90],[6,28,50,72,94],[6,26,50,74,98],[6,30,54,78,102],[6,28,54,80,106],[6,32,58,84,110],[6,30,58,86,114],[6,34,62,90,118],[6,26,50,74,98,122],[6,30,54,78,102,126],[6,26,52,78,104,130],[6,30,56,82,108,134],[6,34,60,86,112,138],[6,30,58,86,114,142],[6,34,62,90,118,146],[6,30,54,78,102,126,150],[6,24,50,76,102,128,154],[6,28,54,80,106,132,158],[6,32,58,84,110,136,162],[6,26,54,82,110,138,166],[6,30,58,86,114,142,170]],G15:1335,G18:7973,G15_MASK:21522,getBCHTypeInfo:function(t){for(var e=t<<10;l.getBCHDigit(e)-l.getBCHDigit(l.G15)>=0;)e^=l.G15<=0;)e^=l.G18<>>=1;return e},getPatternPosition:function(t){return l.PATTERN_POSITION_TABLE[t-1]},getMask:function(t,e,r){switch(t){case a.PATTERN000:return(e+r)%2==0;case a.PATTERN001:return e%2==0;case a.PATTERN010:return r%3==0;case a.PATTERN011:return(e+r)%3==0;case a.PATTERN100:return(Math.floor(e/2)+Math.floor(r/3))%2==0;case a.PATTERN101:return e*r%2+e*r%3==0;case a.PATTERN110:return(e*r%2+e*r%3)%2==0;case a.PATTERN111:return(e*r%3+(e+r)%2)%2==0;default:throw new Error("bad maskPattern:"+t)}},getErrorCorrectPolynomial:function(t){for(var e=new n([1],0),r=0;t>r;r++)e=e.multiply(new n([1,h.gexp(r)],0));return e},getLostPoint:function(t){for(var e=t.getModuleCount(),r=0,o=0,i=0;e>i;i++)for(var n=0,s=t.modules[i][0],u=0;e>u;u++){var a=t.modules[i][u];if(e-6>u&&a&&!t.modules[i][u+1]&&t.modules[i][u+2]&&t.modules[i][u+3]&&t.modules[i][u+4]&&!t.modules[i][u+5]&&t.modules[i][u+6]&&(e-10>u?t.modules[i][u+7]&&t.modules[i][u+8]&&t.modules[i][u+9]&&t.modules[i][u+10]&&(r+=40):u>3&&t.modules[i][u-1]&&t.modules[i][u-2]&&t.modules[i][u-3]&&t.modules[i][u-4]&&(r+=40)),e-1>i&&e-1>u){var l=0;a&&l++,t.modules[i+1][u]&&l++,t.modules[i][u+1]&&l++,t.modules[i+1][u+1]&&l++,(0==l||4==l)&&(r+=3)}s^a?n++:(s=a,n>=5&&(r+=3+n-5),n=1),a&&o++}for(var u=0;e>u;u++)for(var n=0,s=t.modules[0][u],i=0;e>i;i++){var a=t.modules[i][u];e-6>i&&a&&!t.modules[i+1][u]&&t.modules[i+2][u]&&t.modules[i+3][u]&&t.modules[i+4][u]&&!t.modules[i+5][u]&&t.modules[i+6][u]&&(e-10>i?t.modules[i+7][u]&&t.modules[i+8][u]&&t.modules[i+9][u]&&t.modules[i+10][u]&&(r+=40):i>3&&t.modules[i-1][u]&&t.modules[i-2][u]&&t.modules[i-3][u]&&t.modules[i-4][u]&&(r+=40)),s^a?n++:(s=a,n>=5&&(r+=3+n-5),n=1)}var h=Math.abs(100*o/e/e-50)/5;return r+=10*h}},h={glog:function(t){if(1>t)throw new Error("glog("+t+")");return h.LOG_TABLE[t]},gexp:function(t){for(;0>t;)t+=255;for(;t>=256;)t-=255;return h.EXP_TABLE[t]},EXP_TABLE:new Array(256),LOG_TABLE:new Array(256)},g=0;8>g;g++)h.EXP_TABLE[g]=1<g;g++)h.EXP_TABLE[g]=h.EXP_TABLE[g-4]^h.EXP_TABLE[g-5]^h.EXP_TABLE[g-6]^h.EXP_TABLE[g-8];for(var g=0;255>g;g++)h.LOG_TABLE[h.EXP_TABLE[g]]=g;n.prototype={get:function(t){return this.num[t]},getLength:function(){return this.num.length},multiply:function(t){for(var e=new Array(this.getLength()+t.getLength()-1),r=0;re-r)return this;for(var o=new Array(e),i=0;e>i;i++)o[i]=this.get(i);for(;o.length>=r;){for(var s=h.glog(o[0])-h.glog(t.get(0)),i=0;it;t++){var e=f[4*(t-1)+this.errorCorrectLevel];if(void 0==e)throw new Error("bad rs block @ typeNumber:"+t+"/errorCorrectLevel:"+this.errorCorrectLevel);for(var r=e.length/3,o=0,i=0;r>i;i++){var n=e[3*i+0],s=e[3*i+2];o+=s*n}var u=t>9?2:1;if(this.utf8bytes.length+u>>7-t%8&1},put:function(t,e){for(var r=0;e>r;r++)this.putBit(t>>>e-r-1&1)},putBit:function(t){var e=Math.floor(this.length/8);this.buffer.length<=e&&this.buffer.push(0),t&&(this.buffer[e]|=128>>>this.length%8),this.length++}},t.exports=i},function(t,e){t.exports=function(t){for(var e,r=Array.prototype.slice.call(arguments,1),o=0;e=r[o];o++)if(e)for(var i in e)t[i]=e[i];return t}}]); \ No newline at end of file diff --git a/src/index.js b/src/index.js index c9a7f1b..e0b5562 100644 --- a/src/index.js +++ b/src/index.js @@ -177,8 +177,8 @@ extend(qrcode.prototype,{ ctx.drawImage(img, x, y, currImageSize, currImageSize); }); } - canvas.style.width = (canvas.width/ratio).toFixed(2) + 'px'; - canvas.style.height = (canvas.height/ratio).toFixed(2) + 'px'; + canvas.style.width = Math.floor(canvas.width/ratio) + 'px'; + canvas.style.height = Math.floor(canvas.height/ratio) + 'px'; return canvas; }, // table create From 1ae87fcde9a57a4ddc4543b5127d8c62bf03f1a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8F=B6=E8=A8=80?= Date: Wed, 28 Oct 2015 19:28:05 +0800 Subject: [PATCH 05/10] =?UTF-8?q?fix(src/index.js):=20delete=20redundancy?= =?UTF-8?q?=20function=20`inPositionDetection`=20test(test/qrcode-spec.js)?= =?UTF-8?q?:=20=E6=B7=BB=E5=8A=A0=E6=B5=8B=E8=AF=95=E7=94=A8=E4=BE=8B=20`?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E4=BA=8C=E7=BB=B4=E7=A0=81=E5=AE=B9=E9=94=99?= =?UTF-8?q?=E6=B0=B4=E5=B9=B3`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/index.js | 3 ++- tests/qrcode-spec.js | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index e0b5562..25835b3 100644 --- a/src/index.js +++ b/src/index.js @@ -28,7 +28,7 @@ var getForeGround = function(config){ * @param {col} 矩阵列 * @param {count} 矩阵大小 * @return {Boolean} -*/ + var inPositionDetection = function(row, col, count){ if( (row<7 && col<7) @@ -39,6 +39,7 @@ var inPositionDetection = function(row, col, count){ } return false; } +*/ /** * 获取当前屏幕的设备像素比 devicePixelRatio/backingStore * @param {context} 当前 canvas 上下文,可以为 window diff --git a/tests/qrcode-spec.js b/tests/qrcode-spec.js index c1677eb..6caf315 100644 --- a/tests/qrcode-spec.js +++ b/tests/qrcode-spec.js @@ -39,6 +39,11 @@ describe('qrcode', function() { foreground:'#011' }); }); + it('设置二维码容错水平', function() { + var qrnode = new qrcode({ + correctLevel: 2 + }); + }); it('以table来显示', function() { var qrnode = new qrcode({ render:'table' From be1f55d3285edbf567a56f322a6d6b0d32d0f032 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8F=B6=E8=A8=80?= Date: Thu, 29 Oct 2015 10:21:31 +0800 Subject: [PATCH 06/10] =?UTF-8?q?=E6=94=B9=E5=8F=98=20canvas=20=E6=B8=B2?= =?UTF-8?q?=E6=9F=93=E7=AE=97=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dist/arale-qrcode/3.0.6/index.js | 2 +- examples/index.md | 2 +- src/index.js | 22 ++++++++++++---------- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/dist/arale-qrcode/3.0.6/index.js b/dist/arale-qrcode/3.0.6/index.js index b6cc851..9f7b2d2 100644 --- a/dist/arale-qrcode/3.0.6/index.js +++ b/dist/arale-qrcode/3.0.6/index.js @@ -1 +1 @@ -this.AraleQRCode=function(t){function e(o){if(r[o])return r[o].exports;var i=r[o]={exports:{},id:o,loaded:!1};return t[o].call(i.exports,i,i.exports,e),i.loaded=!0,i.exports}var r={};return e.m=t,e.c=r,e.p="",e(0)}([function(t,e,r){t.exports=r(1)},function(t,e,r){"use strict";t.exports=r(2)},function(t,e,r){"use strict";var o=r(4),i=[],n=r(3),s=function(t){var e=t.options;return e.pdground&&(t.row>1&&t.row<5&&t.col>1&&t.col<5||t.row>t.count-6&&t.row1&&t.col<5||t.row>1&&t.row<5&&t.col>t.count-6&&t.colr;r++)if(i[r].text==this.options.text&&i[r].text.correctLevel==this.options.correctLevel){e=i[r].obj;break}if(r==s&&(e=new n(this.options.text,this.options.correctLevel),i.push({text:this.options.text,correctLevel:this.options.correctLevel,obj:e})),this.options.render)switch(this.options.render){case"canvas":return this.createCanvas(e);case"table":return this.createTable(e);case"svg":return this.createSVG(e);default:return this.createDefault(e)}return this.createDefault(e)};o(a.prototype,{createDefault:function(t){var e=document.createElement("canvas");if(e.getContext)return this.createCanvas(t);var r="http://www.w3.org/2000/svg";return document.createElementNS&&document.createElementNS(r,"svg").createSVGRect?this.createSVG(t):this.createTable(t)},createCanvas:function(t){var e=this.options,r=document.createElement("canvas"),o=r.getContext("2d"),i=t.getModuleCount(),n=u(o),a=e.size,l=a*n,h=e.imageSize*n,g=function(t,e){var r=new Image;r.src=t,r.onload=function(){e(this),r.onload=null}},f=Math.floor(l/i),c=Math.floor(l/i);0>=f&&(f=80>i?2:1),0>=c&&(c=80>i?2:1),r.width=f*i,r.height=c*i;for(var d=h*(r.width/l),m=0;i>m;m++)for(var p=0;i>p;p++){var v=Math.ceil((p+1)*f)-Math.floor(p*f),w=Math.ceil((m+1)*f)-Math.floor(m*f),b=s({row:m,col:p,count:i,options:e});o.fillStyle=t.modules[m][p]?b:e.background,o.fillRect(Math.round(p*f),Math.round(m*c),v,w)}return e.image&&g(e.image,function(t){var e=((r.width-d)/2).toFixed(2),i=((r.height-d)/2).toFixed(2);o.drawImage(t,e,i,d,d)}),r.style.width=Math.floor(r.width/n)+"px",r.style.height=Math.floor(r.height/n)+"px",r},createTable:function(t){var e=this.options,r=t.getModuleCount(),o=Math.floor(e.size/r),i=Math.floor(e.size/r);0>=o&&(o=80>r?2:1),0>=i&&(i=80>r?2:1);var n=[];n.push('');for(var u=0;r>u;u++){n.push('');for(var a=0;r>a;a++){var l=s({row:u,col:a,count:r,options:e});t.modules[u][a]?n.push(''):n.push('')}n.push("")}if(n.push("
"),e.image){var h=o*r,g=i*r,f=((h-e.imageSize)/2).toFixed(2),c=((g-e.imageSize)/2).toFixed(2);n.unshift("
"),n.push(""),n.push("
")}var d=document.createElement("span");return d.innerHTML=n.join(""),d.firstChild},createSVG:function(t){var e=this.options,r=t.getModuleCount(),o=r/e.size,i=document.createElementNS("http://www.w3.org/2000/svg","svg");i.setAttribute("width",e.size),i.setAttribute("height",e.size),i.setAttribute("viewBox","0 0 "+r+" "+r);for(var n=0;r>n;n++)for(var u=0;r>u;u++){var a=document.createElementNS("http://www.w3.org/2000/svg","rect"),l=s({row:n,col:u,count:r,options:e});a.setAttribute("x",u),a.setAttribute("y",n),a.setAttribute("width",1),a.setAttribute("height",1),a.setAttribute("stroke-width",0),t.modules[n][u]?a.setAttribute("fill",l):a.setAttribute("fill",e.background),i.appendChild(a)}if(e.image){var h=document.createElementNS("http://www.w3.org/2000/svg","image");h.setAttributeNS("http://www.w3.org/1999/xlink","href",e.image),h.setAttribute("x",((r-e.imageSize*o)/2).toFixed(2)),h.setAttribute("y",((r-e.imageSize*o)/2).toFixed(2)),h.setAttribute("width",e.imageSize*o),h.setAttribute("height",e.imageSize*o),i.appendChild(h)}return i}}),t.exports=a},function(t,e){"use strict";function r(t){var e,r,o;return 128>t?[t]:2048>t?(e=192+(t>>6),r=128+(63&t),[e,r]):(e=224+(t>>12),r=128+(t>>6&63),o=128+(63&t),[e,r,o])}function o(t){for(var e=[],o=0;o=7&&this.setupTypeNumber(!0),this.mapData(this.dataCache,t)},setupPositionProbePattern:function(t,e){for(var r=-1;7>=r;r++)if(!(-1>=t+r||this.moduleCount<=t+r))for(var o=-1;7>=o;o++)-1>=e+o||this.moduleCount<=e+o||(r>=0&&6>=r&&(0==o||6==o)||o>=0&&6>=o&&(0==r||6==r)||r>=2&&4>=r&&o>=2&&4>=o?this.modules[t+r][e+o]=!0:this.modules[t+r][e+o]=!1)},createQrcode:function(){for(var t=0,e=0,r=null,o=0;8>o;o++){this.makeImpl(o);var i=l.getLostPoint(this);(0==o||t>i)&&(t=i,e=o,r=this.modules)}this.modules=r,this.setupTypeInfo(!1,e),this.typeNumber>=7&&this.setupTypeNumber(!1)},setupTimingPattern:function(){for(var t=8;t=n;n++)for(var s=-2;2>=s;s++)-2==n||2==n||-2==s||2==s||0==n&&0==s?this.modules[o+n][i+s]=!0:this.modules[o+n][i+s]=!1}},setupTypeNumber:function(t){for(var e=l.getBCHTypeNumber(this.typeNumber),r=0;18>r;r++){var o=!t&&1==(e>>r&1);this.modules[Math.floor(r/3)][r%3+this.moduleCount-8-3]=o,this.modules[r%3+this.moduleCount-8-3][Math.floor(r/3)]=o}},setupTypeInfo:function(t,e){for(var r=u[this.errorCorrectLevel]<<3|e,o=l.getBCHTypeInfo(r),i=0;15>i;i++){var n=!t&&1==(o>>i&1);6>i?this.modules[i][8]=n:8>i?this.modules[i+1][8]=n:this.modules[this.moduleCount-15+i][8]=n;var n=!t&&1==(o>>i&1);8>i?this.modules[8][this.moduleCount-i-1]=n:9>i?this.modules[8][15-i-1+1]=n:this.modules[8][15-i-1]=n}this.modules[this.moduleCount-8][8]=!t},createData:function(){var t=new s,e=this.typeNumber>9?16:8;t.put(4,4),t.put(this.utf8bytes.length,e);for(var r=0,o=this.utf8bytes.length;o>r;r++)t.put(this.utf8bytes[r],8);for(t.length+4<=8*this.totalDataCount&&t.put(0,4);t.length%8!=0;)t.putBit(!1);for(;;){if(t.length>=8*this.totalDataCount)break;if(t.put(i.PAD0,8),t.length>=8*this.totalDataCount)break;t.put(i.PAD1,8)}return this.createBytes(t)},createBytes:function(t){for(var e=0,r=0,o=0,i=this.rsBlock.length/3,s=new Array,u=0;i>u;u++)for(var a=this.rsBlock[3*u+0],h=this.rsBlock[3*u+1],g=this.rsBlock[3*u+2],f=0;a>f;f++)s.push([g,h]);for(var c=new Array(s.length),d=new Array(s.length),m=0;m=0?A.get(T):0}}for(var P=new Array(this.totalDataCount),y=0,u=0;r>u;u++)for(var m=0;mu;u++)for(var m=0;m0;s-=2)for(6==s&&s--;;){for(var u=0;2>u;u++)if(null==this.modules[o][s-u]){var a=!1;n>>i&1));var h=l.getMask(e,o,s-u);h&&(a=!a),this.modules[o][s-u]=a,i--,-1==i&&(n++,i=7)}if(o+=r,0>o||this.moduleCount<=o){o-=r,r=-r;break}}}},i.PAD0=236,i.PAD1=17;for(var u=[1,0,3,2],a={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7},l={PATTERN_POSITION_TABLE:[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58],[6,34,62],[6,26,46,66],[6,26,48,70],[6,26,50,74],[6,30,54,78],[6,30,56,82],[6,30,58,86],[6,34,62,90],[6,28,50,72,94],[6,26,50,74,98],[6,30,54,78,102],[6,28,54,80,106],[6,32,58,84,110],[6,30,58,86,114],[6,34,62,90,118],[6,26,50,74,98,122],[6,30,54,78,102,126],[6,26,52,78,104,130],[6,30,56,82,108,134],[6,34,60,86,112,138],[6,30,58,86,114,142],[6,34,62,90,118,146],[6,30,54,78,102,126,150],[6,24,50,76,102,128,154],[6,28,54,80,106,132,158],[6,32,58,84,110,136,162],[6,26,54,82,110,138,166],[6,30,58,86,114,142,170]],G15:1335,G18:7973,G15_MASK:21522,getBCHTypeInfo:function(t){for(var e=t<<10;l.getBCHDigit(e)-l.getBCHDigit(l.G15)>=0;)e^=l.G15<=0;)e^=l.G18<>>=1;return e},getPatternPosition:function(t){return l.PATTERN_POSITION_TABLE[t-1]},getMask:function(t,e,r){switch(t){case a.PATTERN000:return(e+r)%2==0;case a.PATTERN001:return e%2==0;case a.PATTERN010:return r%3==0;case a.PATTERN011:return(e+r)%3==0;case a.PATTERN100:return(Math.floor(e/2)+Math.floor(r/3))%2==0;case a.PATTERN101:return e*r%2+e*r%3==0;case a.PATTERN110:return(e*r%2+e*r%3)%2==0;case a.PATTERN111:return(e*r%3+(e+r)%2)%2==0;default:throw new Error("bad maskPattern:"+t)}},getErrorCorrectPolynomial:function(t){for(var e=new n([1],0),r=0;t>r;r++)e=e.multiply(new n([1,h.gexp(r)],0));return e},getLostPoint:function(t){for(var e=t.getModuleCount(),r=0,o=0,i=0;e>i;i++)for(var n=0,s=t.modules[i][0],u=0;e>u;u++){var a=t.modules[i][u];if(e-6>u&&a&&!t.modules[i][u+1]&&t.modules[i][u+2]&&t.modules[i][u+3]&&t.modules[i][u+4]&&!t.modules[i][u+5]&&t.modules[i][u+6]&&(e-10>u?t.modules[i][u+7]&&t.modules[i][u+8]&&t.modules[i][u+9]&&t.modules[i][u+10]&&(r+=40):u>3&&t.modules[i][u-1]&&t.modules[i][u-2]&&t.modules[i][u-3]&&t.modules[i][u-4]&&(r+=40)),e-1>i&&e-1>u){var l=0;a&&l++,t.modules[i+1][u]&&l++,t.modules[i][u+1]&&l++,t.modules[i+1][u+1]&&l++,(0==l||4==l)&&(r+=3)}s^a?n++:(s=a,n>=5&&(r+=3+n-5),n=1),a&&o++}for(var u=0;e>u;u++)for(var n=0,s=t.modules[0][u],i=0;e>i;i++){var a=t.modules[i][u];e-6>i&&a&&!t.modules[i+1][u]&&t.modules[i+2][u]&&t.modules[i+3][u]&&t.modules[i+4][u]&&!t.modules[i+5][u]&&t.modules[i+6][u]&&(e-10>i?t.modules[i+7][u]&&t.modules[i+8][u]&&t.modules[i+9][u]&&t.modules[i+10][u]&&(r+=40):i>3&&t.modules[i-1][u]&&t.modules[i-2][u]&&t.modules[i-3][u]&&t.modules[i-4][u]&&(r+=40)),s^a?n++:(s=a,n>=5&&(r+=3+n-5),n=1)}var h=Math.abs(100*o/e/e-50)/5;return r+=10*h}},h={glog:function(t){if(1>t)throw new Error("glog("+t+")");return h.LOG_TABLE[t]},gexp:function(t){for(;0>t;)t+=255;for(;t>=256;)t-=255;return h.EXP_TABLE[t]},EXP_TABLE:new Array(256),LOG_TABLE:new Array(256)},g=0;8>g;g++)h.EXP_TABLE[g]=1<g;g++)h.EXP_TABLE[g]=h.EXP_TABLE[g-4]^h.EXP_TABLE[g-5]^h.EXP_TABLE[g-6]^h.EXP_TABLE[g-8];for(var g=0;255>g;g++)h.LOG_TABLE[h.EXP_TABLE[g]]=g;n.prototype={get:function(t){return this.num[t]},getLength:function(){return this.num.length},multiply:function(t){for(var e=new Array(this.getLength()+t.getLength()-1),r=0;re-r)return this;for(var o=new Array(e),i=0;e>i;i++)o[i]=this.get(i);for(;o.length>=r;){for(var s=h.glog(o[0])-h.glog(t.get(0)),i=0;it;t++){var e=f[4*(t-1)+this.errorCorrectLevel];if(void 0==e)throw new Error("bad rs block @ typeNumber:"+t+"/errorCorrectLevel:"+this.errorCorrectLevel);for(var r=e.length/3,o=0,i=0;r>i;i++){var n=e[3*i+0],s=e[3*i+2];o+=s*n}var u=t>9?2:1;if(this.utf8bytes.length+u>>7-t%8&1},put:function(t,e){for(var r=0;e>r;r++)this.putBit(t>>>e-r-1&1)},putBit:function(t){var e=Math.floor(this.length/8);this.buffer.length<=e&&this.buffer.push(0),t&&(this.buffer[e]|=128>>>this.length%8),this.length++}},t.exports=i},function(t,e){t.exports=function(t){for(var e,r=Array.prototype.slice.call(arguments,1),o=0;e=r[o];o++)if(e)for(var i in e)t[i]=e[i];return t}}]); \ No newline at end of file +this.AraleQRCode=function(t){function e(o){if(r[o])return r[o].exports;var i=r[o]={exports:{},id:o,loaded:!1};return t[o].call(i.exports,i,i.exports,e),i.loaded=!0,i.exports}var r={};return e.m=t,e.c=r,e.p="",e(0)}([function(t,e,r){t.exports=r(1)},function(t,e,r){"use strict";t.exports=r(2)},function(t,e,r){"use strict";var o=r(4),i=[],n=r(3),s=function(t){var e=t.options;return e.pdground&&(t.row>1&&t.row<5&&t.col>1&&t.col<5||t.row>t.count-6&&t.row1&&t.col<5||t.row>1&&t.row<5&&t.col>t.count-6&&t.colr;r++)if(i[r].text==this.options.text&&i[r].text.correctLevel==this.options.correctLevel){e=i[r].obj;break}if(r==s&&(e=new n(this.options.text,this.options.correctLevel),i.push({text:this.options.text,correctLevel:this.options.correctLevel,obj:e})),this.options.render)switch(this.options.render){case"canvas":return this.createCanvas(e);case"table":return this.createTable(e);case"svg":return this.createSVG(e);default:return this.createDefault(e)}return this.createDefault(e)};o(a.prototype,{createDefault:function(t){var e=document.createElement("canvas");if(e.getContext)return this.createCanvas(t);var r="http://www.w3.org/2000/svg";return document.createElementNS&&document.createElementNS(r,"svg").createSVGRect?this.createSVG(t):this.createTable(t)},createCanvas:function(t){var e=this.options,r=document.createElement("canvas"),o=r.getContext("2d"),i=t.getModuleCount(),n=u(o),a=e.size,l=a*n,h=e.imageSize*n,g=function(t,e){var r=new Image;r.src=t,r.onload=function(){e(this),r.onload=null}},f=Math.floor(a/i),c=Math.floor(a/i);0>=f&&(f=80>i?2:1),0>=c&&(c=80>i?2:1);var d=f*n,m=c*n;r.width=d*i,r.height=m*i;for(var p=Math.floor(h*(r.width/l)),v=0;i>v;v++)for(var b=0;i>b;b++){var w=Math.ceil((b+1)*d)-Math.floor(b*d),A=Math.ceil((v+1)*m)-Math.floor(v*m),T=s({row:v,col:b,count:i,options:e});o.fillStyle=t.modules[v][b]?T:e.background,o.fillRect(Math.round(b*d),Math.round(v*m),w,A)}return e.image&&g(e.image,function(t){var e=((r.width-p)/2).toFixed(2),i=((r.height-p)/2).toFixed(2);o.drawImage(t,e,i,p,p)}),r.style.width=f*i+"px",r.style.height=c*i+"px",r},createTable:function(t){var e=this.options,r=t.getModuleCount(),o=Math.floor(e.size/r),i=Math.floor(e.size/r);0>=o&&(o=80>r?2:1),0>=i&&(i=80>r?2:1);var n=[];n.push('');for(var u=0;r>u;u++){n.push('');for(var a=0;r>a;a++){var l=s({row:u,col:a,count:r,options:e});t.modules[u][a]?n.push(''):n.push('')}n.push("")}if(n.push("
"),e.image){var h=o*r,g=i*r,f=((h-e.imageSize)/2).toFixed(2),c=((g-e.imageSize)/2).toFixed(2);n.unshift("
"),n.push(""),n.push("
")}var d=document.createElement("span");return d.innerHTML=n.join(""),d.firstChild},createSVG:function(t){var e=this.options,r=t.getModuleCount(),o=r/e.size,i=document.createElementNS("http://www.w3.org/2000/svg","svg");i.setAttribute("width",e.size),i.setAttribute("height",e.size),i.setAttribute("viewBox","0 0 "+r+" "+r);for(var n=0;r>n;n++)for(var u=0;r>u;u++){var a=document.createElementNS("http://www.w3.org/2000/svg","rect"),l=s({row:n,col:u,count:r,options:e});a.setAttribute("x",u),a.setAttribute("y",n),a.setAttribute("width",1),a.setAttribute("height",1),a.setAttribute("stroke-width",0),t.modules[n][u]?a.setAttribute("fill",l):a.setAttribute("fill",e.background),i.appendChild(a)}if(e.image){var h=document.createElementNS("http://www.w3.org/2000/svg","image");h.setAttributeNS("http://www.w3.org/1999/xlink","href",e.image),h.setAttribute("x",((r-e.imageSize*o)/2).toFixed(2)),h.setAttribute("y",((r-e.imageSize*o)/2).toFixed(2)),h.setAttribute("width",e.imageSize*o),h.setAttribute("height",e.imageSize*o),i.appendChild(h)}return i}}),t.exports=a},function(t,e){"use strict";function r(t){var e,r,o;return 128>t?[t]:2048>t?(e=192+(t>>6),r=128+(63&t),[e,r]):(e=224+(t>>12),r=128+(t>>6&63),o=128+(63&t),[e,r,o])}function o(t){for(var e=[],o=0;o=7&&this.setupTypeNumber(!0),this.mapData(this.dataCache,t)},setupPositionProbePattern:function(t,e){for(var r=-1;7>=r;r++)if(!(-1>=t+r||this.moduleCount<=t+r))for(var o=-1;7>=o;o++)-1>=e+o||this.moduleCount<=e+o||(r>=0&&6>=r&&(0==o||6==o)||o>=0&&6>=o&&(0==r||6==r)||r>=2&&4>=r&&o>=2&&4>=o?this.modules[t+r][e+o]=!0:this.modules[t+r][e+o]=!1)},createQrcode:function(){for(var t=0,e=0,r=null,o=0;8>o;o++){this.makeImpl(o);var i=l.getLostPoint(this);(0==o||t>i)&&(t=i,e=o,r=this.modules)}this.modules=r,this.setupTypeInfo(!1,e),this.typeNumber>=7&&this.setupTypeNumber(!1)},setupTimingPattern:function(){for(var t=8;t=n;n++)for(var s=-2;2>=s;s++)-2==n||2==n||-2==s||2==s||0==n&&0==s?this.modules[o+n][i+s]=!0:this.modules[o+n][i+s]=!1}},setupTypeNumber:function(t){for(var e=l.getBCHTypeNumber(this.typeNumber),r=0;18>r;r++){var o=!t&&1==(e>>r&1);this.modules[Math.floor(r/3)][r%3+this.moduleCount-8-3]=o,this.modules[r%3+this.moduleCount-8-3][Math.floor(r/3)]=o}},setupTypeInfo:function(t,e){for(var r=u[this.errorCorrectLevel]<<3|e,o=l.getBCHTypeInfo(r),i=0;15>i;i++){var n=!t&&1==(o>>i&1);6>i?this.modules[i][8]=n:8>i?this.modules[i+1][8]=n:this.modules[this.moduleCount-15+i][8]=n;var n=!t&&1==(o>>i&1);8>i?this.modules[8][this.moduleCount-i-1]=n:9>i?this.modules[8][15-i-1+1]=n:this.modules[8][15-i-1]=n}this.modules[this.moduleCount-8][8]=!t},createData:function(){var t=new s,e=this.typeNumber>9?16:8;t.put(4,4),t.put(this.utf8bytes.length,e);for(var r=0,o=this.utf8bytes.length;o>r;r++)t.put(this.utf8bytes[r],8);for(t.length+4<=8*this.totalDataCount&&t.put(0,4);t.length%8!=0;)t.putBit(!1);for(;;){if(t.length>=8*this.totalDataCount)break;if(t.put(i.PAD0,8),t.length>=8*this.totalDataCount)break;t.put(i.PAD1,8)}return this.createBytes(t)},createBytes:function(t){for(var e=0,r=0,o=0,i=this.rsBlock.length/3,s=new Array,u=0;i>u;u++)for(var a=this.rsBlock[3*u+0],h=this.rsBlock[3*u+1],g=this.rsBlock[3*u+2],f=0;a>f;f++)s.push([g,h]);for(var c=new Array(s.length),d=new Array(s.length),m=0;m=0?A.get(T):0}}for(var P=new Array(this.totalDataCount),y=0,u=0;r>u;u++)for(var m=0;mu;u++)for(var m=0;m0;s-=2)for(6==s&&s--;;){for(var u=0;2>u;u++)if(null==this.modules[o][s-u]){var a=!1;n>>i&1));var h=l.getMask(e,o,s-u);h&&(a=!a),this.modules[o][s-u]=a,i--,-1==i&&(n++,i=7)}if(o+=r,0>o||this.moduleCount<=o){o-=r,r=-r;break}}}},i.PAD0=236,i.PAD1=17;for(var u=[1,0,3,2],a={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7},l={PATTERN_POSITION_TABLE:[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58],[6,34,62],[6,26,46,66],[6,26,48,70],[6,26,50,74],[6,30,54,78],[6,30,56,82],[6,30,58,86],[6,34,62,90],[6,28,50,72,94],[6,26,50,74,98],[6,30,54,78,102],[6,28,54,80,106],[6,32,58,84,110],[6,30,58,86,114],[6,34,62,90,118],[6,26,50,74,98,122],[6,30,54,78,102,126],[6,26,52,78,104,130],[6,30,56,82,108,134],[6,34,60,86,112,138],[6,30,58,86,114,142],[6,34,62,90,118,146],[6,30,54,78,102,126,150],[6,24,50,76,102,128,154],[6,28,54,80,106,132,158],[6,32,58,84,110,136,162],[6,26,54,82,110,138,166],[6,30,58,86,114,142,170]],G15:1335,G18:7973,G15_MASK:21522,getBCHTypeInfo:function(t){for(var e=t<<10;l.getBCHDigit(e)-l.getBCHDigit(l.G15)>=0;)e^=l.G15<=0;)e^=l.G18<>>=1;return e},getPatternPosition:function(t){return l.PATTERN_POSITION_TABLE[t-1]},getMask:function(t,e,r){switch(t){case a.PATTERN000:return(e+r)%2==0;case a.PATTERN001:return e%2==0;case a.PATTERN010:return r%3==0;case a.PATTERN011:return(e+r)%3==0;case a.PATTERN100:return(Math.floor(e/2)+Math.floor(r/3))%2==0;case a.PATTERN101:return e*r%2+e*r%3==0;case a.PATTERN110:return(e*r%2+e*r%3)%2==0;case a.PATTERN111:return(e*r%3+(e+r)%2)%2==0;default:throw new Error("bad maskPattern:"+t)}},getErrorCorrectPolynomial:function(t){for(var e=new n([1],0),r=0;t>r;r++)e=e.multiply(new n([1,h.gexp(r)],0));return e},getLostPoint:function(t){for(var e=t.getModuleCount(),r=0,o=0,i=0;e>i;i++)for(var n=0,s=t.modules[i][0],u=0;e>u;u++){var a=t.modules[i][u];if(e-6>u&&a&&!t.modules[i][u+1]&&t.modules[i][u+2]&&t.modules[i][u+3]&&t.modules[i][u+4]&&!t.modules[i][u+5]&&t.modules[i][u+6]&&(e-10>u?t.modules[i][u+7]&&t.modules[i][u+8]&&t.modules[i][u+9]&&t.modules[i][u+10]&&(r+=40):u>3&&t.modules[i][u-1]&&t.modules[i][u-2]&&t.modules[i][u-3]&&t.modules[i][u-4]&&(r+=40)),e-1>i&&e-1>u){var l=0;a&&l++,t.modules[i+1][u]&&l++,t.modules[i][u+1]&&l++,t.modules[i+1][u+1]&&l++,(0==l||4==l)&&(r+=3)}s^a?n++:(s=a,n>=5&&(r+=3+n-5),n=1),a&&o++}for(var u=0;e>u;u++)for(var n=0,s=t.modules[0][u],i=0;e>i;i++){var a=t.modules[i][u];e-6>i&&a&&!t.modules[i+1][u]&&t.modules[i+2][u]&&t.modules[i+3][u]&&t.modules[i+4][u]&&!t.modules[i+5][u]&&t.modules[i+6][u]&&(e-10>i?t.modules[i+7][u]&&t.modules[i+8][u]&&t.modules[i+9][u]&&t.modules[i+10][u]&&(r+=40):i>3&&t.modules[i-1][u]&&t.modules[i-2][u]&&t.modules[i-3][u]&&t.modules[i-4][u]&&(r+=40)),s^a?n++:(s=a,n>=5&&(r+=3+n-5),n=1)}var h=Math.abs(100*o/e/e-50)/5;return r+=10*h}},h={glog:function(t){if(1>t)throw new Error("glog("+t+")");return h.LOG_TABLE[t]},gexp:function(t){for(;0>t;)t+=255;for(;t>=256;)t-=255;return h.EXP_TABLE[t]},EXP_TABLE:new Array(256),LOG_TABLE:new Array(256)},g=0;8>g;g++)h.EXP_TABLE[g]=1<g;g++)h.EXP_TABLE[g]=h.EXP_TABLE[g-4]^h.EXP_TABLE[g-5]^h.EXP_TABLE[g-6]^h.EXP_TABLE[g-8];for(var g=0;255>g;g++)h.LOG_TABLE[h.EXP_TABLE[g]]=g;n.prototype={get:function(t){return this.num[t]},getLength:function(){return this.num.length},multiply:function(t){for(var e=new Array(this.getLength()+t.getLength()-1),r=0;re-r)return this;for(var o=new Array(e),i=0;e>i;i++)o[i]=this.get(i);for(;o.length>=r;){for(var s=h.glog(o[0])-h.glog(t.get(0)),i=0;it;t++){var e=f[4*(t-1)+this.errorCorrectLevel];if(void 0==e)throw new Error("bad rs block @ typeNumber:"+t+"/errorCorrectLevel:"+this.errorCorrectLevel);for(var r=e.length/3,o=0,i=0;r>i;i++){var n=e[3*i+0],s=e[3*i+2];o+=s*n}var u=t>9?2:1;if(this.utf8bytes.length+u>>7-t%8&1},put:function(t,e){for(var r=0;e>r;r++)this.putBit(t>>>e-r-1&1)},putBit:function(t){var e=Math.floor(this.length/8);this.buffer.length<=e&&this.buffer.push(0),t&&(this.buffer[e]|=128>>>this.length%8),this.length++}},t.exports=i},function(t,e){t.exports=function(t){for(var e,r=Array.prototype.slice.call(arguments,1),o=0;e=r[o];o++)if(e)for(var i in e)t[i]=e[i];return t}}]); \ No newline at end of file diff --git a/examples/index.md b/examples/index.md index 743ce9d..dc813ed 100644 --- a/examples/index.md +++ b/examples/index.md @@ -2,7 +2,7 @@ --- -## 采用默认方式画二维码" +## 采用默认方式画二维码 ````html diff --git a/src/index.js b/src/index.js index 25835b3..fdadd3f 100644 --- a/src/index.js +++ b/src/index.js @@ -142,8 +142,8 @@ extend(qrcode.prototype,{ } // 计算每个节点的长宽;取整,防止点之间出现分离 - var tileW = Math.floor(ratioSize / count); - var tileH = Math.floor(ratioSize / count); + var tileW = Math.floor(size / count); + var tileH = Math.floor(size / count); if(tileW <= 0){ tileW = count < 80 ? 2 : 1; } @@ -151,16 +151,18 @@ extend(qrcode.prototype,{ tileH = count < 80 ? 2 : 1; } - canvas.width = tileW * count; - canvas.height = tileH * count; + var ratioTileW = tileW * ratio; + var ratioTileH = tileH * ratio; + canvas.width = ratioTileW * count; + canvas.height = ratioTileH * count; - var currImageSize = ratioImgSize * (canvas.width / ratioSize); + var currImageSize = Math.floor(ratioImgSize * (canvas.width / ratioSize)); //绘制 for (var row = 0; row < count; row++) { for (var col = 0; col < count; col++) { - var w = (Math.ceil((col + 1) * tileW) - Math.floor(col * tileW)); - var h = (Math.ceil((row + 1) * tileW) - Math.floor(row * tileW)); + var w = (Math.ceil((col + 1) * ratioTileW) - Math.floor(col * ratioTileW)); + var h = (Math.ceil((row + 1) * ratioTileH) - Math.floor(row * ratioTileH)); var foreground = getForeGround({ row : row, col : col, @@ -168,7 +170,7 @@ extend(qrcode.prototype,{ options : options }); ctx.fillStyle = qrCodeAlg.modules[row][col] ? foreground : options.background; - ctx.fillRect(Math.round(col * tileW), Math.round(row * tileH), w, h); + ctx.fillRect(Math.round(col * ratioTileW), Math.round(row * ratioTileH), w, h); } } if(options.image){ @@ -178,8 +180,8 @@ extend(qrcode.prototype,{ ctx.drawImage(img, x, y, currImageSize, currImageSize); }); } - canvas.style.width = Math.floor(canvas.width/ratio) + 'px'; - canvas.style.height = Math.floor(canvas.height/ratio) + 'px'; + canvas.style.width = tileW * count + 'px'; + canvas.style.height = tileH * count + 'px'; return canvas; }, // table create From bf14926718b0ee189927ac041ce9962b2ee8b9df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8F=B6=E8=A8=80?= Date: Thu, 29 Oct 2015 11:45:59 +0800 Subject: [PATCH 07/10] =?UTF-8?q?fixed(qrcode-spec.js):=20=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E8=B6=85=E6=97=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/qrcode-spec.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/qrcode-spec.js b/tests/qrcode-spec.js index 6caf315..6de247a 100644 --- a/tests/qrcode-spec.js +++ b/tests/qrcode-spec.js @@ -78,8 +78,9 @@ describe('qrcode', function() { }); it('超过最长字符串容错处理,截取前2953个字符', function() { var s = ''; - for(var i = 0; i < 3000; i++){ - s += i%10; + var t = '0123456789'; + for(var i = 0; i < 3000; i+=10){ + s += t; } var qrnode = new qrcode({ width:500, From 801677eff29294f5ea9c416562cc03a9feb427dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8F=B6=E8=A8=80?= Date: Sun, 1 Nov 2015 21:47:45 +0800 Subject: [PATCH 08/10] =?UTF-8?q?fix:=20=E4=BA=8C=E7=BB=B4=E7=A0=81?= =?UTF-8?q?=E5=8F=98=E5=BD=A2=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/index.js | 13 +++++++++++-- tests/qrcode-spec.js | 5 +++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/index.js b/src/index.js index fdadd3f..fe59757 100644 --- a/src/index.js +++ b/src/index.js @@ -76,7 +76,8 @@ var qrcode = function(opt) { background: '#ffffff', foreground: '#000000', image : '', - imageSize: 30 + imageSize: 30, + canvasClass: 'canvas-qrcode' }, opt); //使用QRCodeAlg创建二维码结构 @@ -182,7 +183,15 @@ extend(qrcode.prototype,{ } canvas.style.width = tileW * count + 'px'; canvas.style.height = tileH * count + 'px'; - return canvas; + var s = []; + s.push(``); + s.push(''); + var span = document.createElement('span'); + span.innerHTML = s.join(''); + span.firstChild.appendChild(canvas); + + return span.firstChild; }, // table create createTable (qrCodeAlg) { diff --git a/tests/qrcode-spec.js b/tests/qrcode-spec.js index 6de247a..c1a43c2 100644 --- a/tests/qrcode-spec.js +++ b/tests/qrcode-spec.js @@ -44,6 +44,11 @@ describe('qrcode', function() { correctLevel: 2 }); }); + it('设置二维码className', function() { + var qrnode = new qrcode({ + canvasClass: 'test-class' + }); + }); it('以table来显示', function() { var qrnode = new qrcode({ render:'table' From 27c58c9477997bfbae6c8b6511f2ce51caf4602b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8F=B6=E8=A8=80?= Date: Sun, 1 Nov 2015 21:59:21 +0800 Subject: [PATCH 09/10] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20dist=20=E6=96=87?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dist/arale-qrcode/3.0.6/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dist/arale-qrcode/3.0.6/index.js b/dist/arale-qrcode/3.0.6/index.js index 9f7b2d2..6e54e5a 100644 --- a/dist/arale-qrcode/3.0.6/index.js +++ b/dist/arale-qrcode/3.0.6/index.js @@ -1 +1 @@ -this.AraleQRCode=function(t){function e(o){if(r[o])return r[o].exports;var i=r[o]={exports:{},id:o,loaded:!1};return t[o].call(i.exports,i,i.exports,e),i.loaded=!0,i.exports}var r={};return e.m=t,e.c=r,e.p="",e(0)}([function(t,e,r){t.exports=r(1)},function(t,e,r){"use strict";t.exports=r(2)},function(t,e,r){"use strict";var o=r(4),i=[],n=r(3),s=function(t){var e=t.options;return e.pdground&&(t.row>1&&t.row<5&&t.col>1&&t.col<5||t.row>t.count-6&&t.row1&&t.col<5||t.row>1&&t.row<5&&t.col>t.count-6&&t.colr;r++)if(i[r].text==this.options.text&&i[r].text.correctLevel==this.options.correctLevel){e=i[r].obj;break}if(r==s&&(e=new n(this.options.text,this.options.correctLevel),i.push({text:this.options.text,correctLevel:this.options.correctLevel,obj:e})),this.options.render)switch(this.options.render){case"canvas":return this.createCanvas(e);case"table":return this.createTable(e);case"svg":return this.createSVG(e);default:return this.createDefault(e)}return this.createDefault(e)};o(a.prototype,{createDefault:function(t){var e=document.createElement("canvas");if(e.getContext)return this.createCanvas(t);var r="http://www.w3.org/2000/svg";return document.createElementNS&&document.createElementNS(r,"svg").createSVGRect?this.createSVG(t):this.createTable(t)},createCanvas:function(t){var e=this.options,r=document.createElement("canvas"),o=r.getContext("2d"),i=t.getModuleCount(),n=u(o),a=e.size,l=a*n,h=e.imageSize*n,g=function(t,e){var r=new Image;r.src=t,r.onload=function(){e(this),r.onload=null}},f=Math.floor(a/i),c=Math.floor(a/i);0>=f&&(f=80>i?2:1),0>=c&&(c=80>i?2:1);var d=f*n,m=c*n;r.width=d*i,r.height=m*i;for(var p=Math.floor(h*(r.width/l)),v=0;i>v;v++)for(var b=0;i>b;b++){var w=Math.ceil((b+1)*d)-Math.floor(b*d),A=Math.ceil((v+1)*m)-Math.floor(v*m),T=s({row:v,col:b,count:i,options:e});o.fillStyle=t.modules[v][b]?T:e.background,o.fillRect(Math.round(b*d),Math.round(v*m),w,A)}return e.image&&g(e.image,function(t){var e=((r.width-p)/2).toFixed(2),i=((r.height-p)/2).toFixed(2);o.drawImage(t,e,i,p,p)}),r.style.width=f*i+"px",r.style.height=c*i+"px",r},createTable:function(t){var e=this.options,r=t.getModuleCount(),o=Math.floor(e.size/r),i=Math.floor(e.size/r);0>=o&&(o=80>r?2:1),0>=i&&(i=80>r?2:1);var n=[];n.push('');for(var u=0;r>u;u++){n.push('');for(var a=0;r>a;a++){var l=s({row:u,col:a,count:r,options:e});t.modules[u][a]?n.push(''):n.push('')}n.push("")}if(n.push("
"),e.image){var h=o*r,g=i*r,f=((h-e.imageSize)/2).toFixed(2),c=((g-e.imageSize)/2).toFixed(2);n.unshift("
"),n.push(""),n.push("
")}var d=document.createElement("span");return d.innerHTML=n.join(""),d.firstChild},createSVG:function(t){var e=this.options,r=t.getModuleCount(),o=r/e.size,i=document.createElementNS("http://www.w3.org/2000/svg","svg");i.setAttribute("width",e.size),i.setAttribute("height",e.size),i.setAttribute("viewBox","0 0 "+r+" "+r);for(var n=0;r>n;n++)for(var u=0;r>u;u++){var a=document.createElementNS("http://www.w3.org/2000/svg","rect"),l=s({row:n,col:u,count:r,options:e});a.setAttribute("x",u),a.setAttribute("y",n),a.setAttribute("width",1),a.setAttribute("height",1),a.setAttribute("stroke-width",0),t.modules[n][u]?a.setAttribute("fill",l):a.setAttribute("fill",e.background),i.appendChild(a)}if(e.image){var h=document.createElementNS("http://www.w3.org/2000/svg","image");h.setAttributeNS("http://www.w3.org/1999/xlink","href",e.image),h.setAttribute("x",((r-e.imageSize*o)/2).toFixed(2)),h.setAttribute("y",((r-e.imageSize*o)/2).toFixed(2)),h.setAttribute("width",e.imageSize*o),h.setAttribute("height",e.imageSize*o),i.appendChild(h)}return i}}),t.exports=a},function(t,e){"use strict";function r(t){var e,r,o;return 128>t?[t]:2048>t?(e=192+(t>>6),r=128+(63&t),[e,r]):(e=224+(t>>12),r=128+(t>>6&63),o=128+(63&t),[e,r,o])}function o(t){for(var e=[],o=0;o=7&&this.setupTypeNumber(!0),this.mapData(this.dataCache,t)},setupPositionProbePattern:function(t,e){for(var r=-1;7>=r;r++)if(!(-1>=t+r||this.moduleCount<=t+r))for(var o=-1;7>=o;o++)-1>=e+o||this.moduleCount<=e+o||(r>=0&&6>=r&&(0==o||6==o)||o>=0&&6>=o&&(0==r||6==r)||r>=2&&4>=r&&o>=2&&4>=o?this.modules[t+r][e+o]=!0:this.modules[t+r][e+o]=!1)},createQrcode:function(){for(var t=0,e=0,r=null,o=0;8>o;o++){this.makeImpl(o);var i=l.getLostPoint(this);(0==o||t>i)&&(t=i,e=o,r=this.modules)}this.modules=r,this.setupTypeInfo(!1,e),this.typeNumber>=7&&this.setupTypeNumber(!1)},setupTimingPattern:function(){for(var t=8;t=n;n++)for(var s=-2;2>=s;s++)-2==n||2==n||-2==s||2==s||0==n&&0==s?this.modules[o+n][i+s]=!0:this.modules[o+n][i+s]=!1}},setupTypeNumber:function(t){for(var e=l.getBCHTypeNumber(this.typeNumber),r=0;18>r;r++){var o=!t&&1==(e>>r&1);this.modules[Math.floor(r/3)][r%3+this.moduleCount-8-3]=o,this.modules[r%3+this.moduleCount-8-3][Math.floor(r/3)]=o}},setupTypeInfo:function(t,e){for(var r=u[this.errorCorrectLevel]<<3|e,o=l.getBCHTypeInfo(r),i=0;15>i;i++){var n=!t&&1==(o>>i&1);6>i?this.modules[i][8]=n:8>i?this.modules[i+1][8]=n:this.modules[this.moduleCount-15+i][8]=n;var n=!t&&1==(o>>i&1);8>i?this.modules[8][this.moduleCount-i-1]=n:9>i?this.modules[8][15-i-1+1]=n:this.modules[8][15-i-1]=n}this.modules[this.moduleCount-8][8]=!t},createData:function(){var t=new s,e=this.typeNumber>9?16:8;t.put(4,4),t.put(this.utf8bytes.length,e);for(var r=0,o=this.utf8bytes.length;o>r;r++)t.put(this.utf8bytes[r],8);for(t.length+4<=8*this.totalDataCount&&t.put(0,4);t.length%8!=0;)t.putBit(!1);for(;;){if(t.length>=8*this.totalDataCount)break;if(t.put(i.PAD0,8),t.length>=8*this.totalDataCount)break;t.put(i.PAD1,8)}return this.createBytes(t)},createBytes:function(t){for(var e=0,r=0,o=0,i=this.rsBlock.length/3,s=new Array,u=0;i>u;u++)for(var a=this.rsBlock[3*u+0],h=this.rsBlock[3*u+1],g=this.rsBlock[3*u+2],f=0;a>f;f++)s.push([g,h]);for(var c=new Array(s.length),d=new Array(s.length),m=0;m=0?A.get(T):0}}for(var P=new Array(this.totalDataCount),y=0,u=0;r>u;u++)for(var m=0;mu;u++)for(var m=0;m0;s-=2)for(6==s&&s--;;){for(var u=0;2>u;u++)if(null==this.modules[o][s-u]){var a=!1;n>>i&1));var h=l.getMask(e,o,s-u);h&&(a=!a),this.modules[o][s-u]=a,i--,-1==i&&(n++,i=7)}if(o+=r,0>o||this.moduleCount<=o){o-=r,r=-r;break}}}},i.PAD0=236,i.PAD1=17;for(var u=[1,0,3,2],a={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7},l={PATTERN_POSITION_TABLE:[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58],[6,34,62],[6,26,46,66],[6,26,48,70],[6,26,50,74],[6,30,54,78],[6,30,56,82],[6,30,58,86],[6,34,62,90],[6,28,50,72,94],[6,26,50,74,98],[6,30,54,78,102],[6,28,54,80,106],[6,32,58,84,110],[6,30,58,86,114],[6,34,62,90,118],[6,26,50,74,98,122],[6,30,54,78,102,126],[6,26,52,78,104,130],[6,30,56,82,108,134],[6,34,60,86,112,138],[6,30,58,86,114,142],[6,34,62,90,118,146],[6,30,54,78,102,126,150],[6,24,50,76,102,128,154],[6,28,54,80,106,132,158],[6,32,58,84,110,136,162],[6,26,54,82,110,138,166],[6,30,58,86,114,142,170]],G15:1335,G18:7973,G15_MASK:21522,getBCHTypeInfo:function(t){for(var e=t<<10;l.getBCHDigit(e)-l.getBCHDigit(l.G15)>=0;)e^=l.G15<=0;)e^=l.G18<>>=1;return e},getPatternPosition:function(t){return l.PATTERN_POSITION_TABLE[t-1]},getMask:function(t,e,r){switch(t){case a.PATTERN000:return(e+r)%2==0;case a.PATTERN001:return e%2==0;case a.PATTERN010:return r%3==0;case a.PATTERN011:return(e+r)%3==0;case a.PATTERN100:return(Math.floor(e/2)+Math.floor(r/3))%2==0;case a.PATTERN101:return e*r%2+e*r%3==0;case a.PATTERN110:return(e*r%2+e*r%3)%2==0;case a.PATTERN111:return(e*r%3+(e+r)%2)%2==0;default:throw new Error("bad maskPattern:"+t)}},getErrorCorrectPolynomial:function(t){for(var e=new n([1],0),r=0;t>r;r++)e=e.multiply(new n([1,h.gexp(r)],0));return e},getLostPoint:function(t){for(var e=t.getModuleCount(),r=0,o=0,i=0;e>i;i++)for(var n=0,s=t.modules[i][0],u=0;e>u;u++){var a=t.modules[i][u];if(e-6>u&&a&&!t.modules[i][u+1]&&t.modules[i][u+2]&&t.modules[i][u+3]&&t.modules[i][u+4]&&!t.modules[i][u+5]&&t.modules[i][u+6]&&(e-10>u?t.modules[i][u+7]&&t.modules[i][u+8]&&t.modules[i][u+9]&&t.modules[i][u+10]&&(r+=40):u>3&&t.modules[i][u-1]&&t.modules[i][u-2]&&t.modules[i][u-3]&&t.modules[i][u-4]&&(r+=40)),e-1>i&&e-1>u){var l=0;a&&l++,t.modules[i+1][u]&&l++,t.modules[i][u+1]&&l++,t.modules[i+1][u+1]&&l++,(0==l||4==l)&&(r+=3)}s^a?n++:(s=a,n>=5&&(r+=3+n-5),n=1),a&&o++}for(var u=0;e>u;u++)for(var n=0,s=t.modules[0][u],i=0;e>i;i++){var a=t.modules[i][u];e-6>i&&a&&!t.modules[i+1][u]&&t.modules[i+2][u]&&t.modules[i+3][u]&&t.modules[i+4][u]&&!t.modules[i+5][u]&&t.modules[i+6][u]&&(e-10>i?t.modules[i+7][u]&&t.modules[i+8][u]&&t.modules[i+9][u]&&t.modules[i+10][u]&&(r+=40):i>3&&t.modules[i-1][u]&&t.modules[i-2][u]&&t.modules[i-3][u]&&t.modules[i-4][u]&&(r+=40)),s^a?n++:(s=a,n>=5&&(r+=3+n-5),n=1)}var h=Math.abs(100*o/e/e-50)/5;return r+=10*h}},h={glog:function(t){if(1>t)throw new Error("glog("+t+")");return h.LOG_TABLE[t]},gexp:function(t){for(;0>t;)t+=255;for(;t>=256;)t-=255;return h.EXP_TABLE[t]},EXP_TABLE:new Array(256),LOG_TABLE:new Array(256)},g=0;8>g;g++)h.EXP_TABLE[g]=1<g;g++)h.EXP_TABLE[g]=h.EXP_TABLE[g-4]^h.EXP_TABLE[g-5]^h.EXP_TABLE[g-6]^h.EXP_TABLE[g-8];for(var g=0;255>g;g++)h.LOG_TABLE[h.EXP_TABLE[g]]=g;n.prototype={get:function(t){return this.num[t]},getLength:function(){return this.num.length},multiply:function(t){for(var e=new Array(this.getLength()+t.getLength()-1),r=0;re-r)return this;for(var o=new Array(e),i=0;e>i;i++)o[i]=this.get(i);for(;o.length>=r;){for(var s=h.glog(o[0])-h.glog(t.get(0)),i=0;it;t++){var e=f[4*(t-1)+this.errorCorrectLevel];if(void 0==e)throw new Error("bad rs block @ typeNumber:"+t+"/errorCorrectLevel:"+this.errorCorrectLevel);for(var r=e.length/3,o=0,i=0;r>i;i++){var n=e[3*i+0],s=e[3*i+2];o+=s*n}var u=t>9?2:1;if(this.utf8bytes.length+u>>7-t%8&1},put:function(t,e){for(var r=0;e>r;r++)this.putBit(t>>>e-r-1&1)},putBit:function(t){var e=Math.floor(this.length/8);this.buffer.length<=e&&this.buffer.push(0),t&&(this.buffer[e]|=128>>>this.length%8),this.length++}},t.exports=i},function(t,e){t.exports=function(t){for(var e,r=Array.prototype.slice.call(arguments,1),o=0;e=r[o];o++)if(e)for(var i in e)t[i]=e[i];return t}}]); \ No newline at end of file +this.AraleQRCode=function(t){function e(o){if(r[o])return r[o].exports;var i=r[o]={exports:{},id:o,loaded:!1};return t[o].call(i.exports,i,i.exports,e),i.loaded=!0,i.exports}var r={};return e.m=t,e.c=r,e.p="",e(0)}([function(t,e,r){t.exports=r(1)},function(t,e,r){"use strict";t.exports=r(2)},function(t,e,r){"use strict";var o=r(4),i=[],n=r(3),s=function(t){var e=t.options;return e.pdground&&(t.row>1&&t.row<5&&t.col>1&&t.col<5||t.row>t.count-6&&t.row1&&t.col<5||t.row>1&&t.row<5&&t.col>t.count-6&&t.colr;r++)if(i[r].text==this.options.text&&i[r].text.correctLevel==this.options.correctLevel){e=i[r].obj;break}if(r==s&&(e=new n(this.options.text,this.options.correctLevel),i.push({text:this.options.text,correctLevel:this.options.correctLevel,obj:e})),this.options.render)switch(this.options.render){case"canvas":return this.createCanvas(e);case"table":return this.createTable(e);case"svg":return this.createSVG(e);default:return this.createDefault(e)}return this.createDefault(e)};o(a.prototype,{createDefault:function(t){var e=document.createElement("canvas");if(e.getContext)return this.createCanvas(t);var r="http://www.w3.org/2000/svg";return document.createElementNS&&document.createElementNS(r,"svg").createSVGRect?this.createSVG(t):this.createTable(t)},createCanvas:function(t){var e=this.options,r=document.createElement("canvas"),o=r.getContext("2d"),i=t.getModuleCount(),n=u(o),a=e.size,l=a*n,h=e.imageSize*n,g=function(t,e){var r=new Image;r.src=t,r.onload=function(){e(this),r.onload=null}},c=Math.floor(a/i),d=Math.floor(a/i);0>=c&&(c=80>i?2:1),0>=d&&(d=80>i?2:1);var f=c*n,m=d*n;r.width=f*i,r.height=m*i;for(var p=Math.floor(h*(r.width/l)),v=0;i>v;v++)for(var b=0;i>b;b++){var w=Math.ceil((b+1)*f)-Math.floor(b*f),A=Math.ceil((v+1)*m)-Math.floor(v*m),T=s({row:v,col:b,count:i,options:e});o.fillStyle=t.modules[v][b]?T:e.background,o.fillRect(Math.round(b*f),Math.round(v*m),w,A)}e.image&&g(e.image,function(t){var e=((r.width-p)/2).toFixed(2),i=((r.height-p)/2).toFixed(2);o.drawImage(t,e,i,p,p)}),r.style.width=c*i+"px",r.style.height=d*i+"px";var C=[];C.push(''),C.push("");var x=document.createElement("span");return x.innerHTML=C.join(""),x.firstChild.appendChild(r),x.firstChild},createTable:function(t){var e=this.options,r=t.getModuleCount(),o=Math.floor(e.size/r),i=Math.floor(e.size/r);0>=o&&(o=80>r?2:1),0>=i&&(i=80>r?2:1);var n=[];n.push('');for(var u=0;r>u;u++){n.push('');for(var a=0;r>a;a++){var l=s({row:u,col:a,count:r,options:e});t.modules[u][a]?n.push(''):n.push('')}n.push("")}if(n.push("
"),e.image){var h=o*r,g=i*r,c=((h-e.imageSize)/2).toFixed(2),d=((g-e.imageSize)/2).toFixed(2);n.unshift("
"),n.push(""),n.push("
")}var f=document.createElement("span");return f.innerHTML=n.join(""),f.firstChild},createSVG:function(t){var e=this.options,r=t.getModuleCount(),o=r/e.size,i=document.createElementNS("http://www.w3.org/2000/svg","svg");i.setAttribute("width",e.size),i.setAttribute("height",e.size),i.setAttribute("viewBox","0 0 "+r+" "+r);for(var n=0;r>n;n++)for(var u=0;r>u;u++){var a=document.createElementNS("http://www.w3.org/2000/svg","rect"),l=s({row:n,col:u,count:r,options:e});a.setAttribute("x",u),a.setAttribute("y",n),a.setAttribute("width",1),a.setAttribute("height",1),a.setAttribute("stroke-width",0),t.modules[n][u]?a.setAttribute("fill",l):a.setAttribute("fill",e.background),i.appendChild(a)}if(e.image){var h=document.createElementNS("http://www.w3.org/2000/svg","image");h.setAttributeNS("http://www.w3.org/1999/xlink","href",e.image),h.setAttribute("x",((r-e.imageSize*o)/2).toFixed(2)),h.setAttribute("y",((r-e.imageSize*o)/2).toFixed(2)),h.setAttribute("width",e.imageSize*o),h.setAttribute("height",e.imageSize*o),i.appendChild(h)}return i}}),t.exports=a},function(t,e){"use strict";function r(t){var e,r,o;return 128>t?[t]:2048>t?(e=192+(t>>6),r=128+(63&t),[e,r]):(e=224+(t>>12),r=128+(t>>6&63),o=128+(63&t),[e,r,o])}function o(t){for(var e=[],o=0;o=7&&this.setupTypeNumber(!0),this.mapData(this.dataCache,t)},setupPositionProbePattern:function(t,e){for(var r=-1;7>=r;r++)if(!(-1>=t+r||this.moduleCount<=t+r))for(var o=-1;7>=o;o++)-1>=e+o||this.moduleCount<=e+o||(r>=0&&6>=r&&(0==o||6==o)||o>=0&&6>=o&&(0==r||6==r)||r>=2&&4>=r&&o>=2&&4>=o?this.modules[t+r][e+o]=!0:this.modules[t+r][e+o]=!1)},createQrcode:function(){for(var t=0,e=0,r=null,o=0;8>o;o++){this.makeImpl(o);var i=l.getLostPoint(this);(0==o||t>i)&&(t=i,e=o,r=this.modules)}this.modules=r,this.setupTypeInfo(!1,e),this.typeNumber>=7&&this.setupTypeNumber(!1)},setupTimingPattern:function(){for(var t=8;t=n;n++)for(var s=-2;2>=s;s++)-2==n||2==n||-2==s||2==s||0==n&&0==s?this.modules[o+n][i+s]=!0:this.modules[o+n][i+s]=!1}},setupTypeNumber:function(t){for(var e=l.getBCHTypeNumber(this.typeNumber),r=0;18>r;r++){var o=!t&&1==(e>>r&1);this.modules[Math.floor(r/3)][r%3+this.moduleCount-8-3]=o,this.modules[r%3+this.moduleCount-8-3][Math.floor(r/3)]=o}},setupTypeInfo:function(t,e){for(var r=u[this.errorCorrectLevel]<<3|e,o=l.getBCHTypeInfo(r),i=0;15>i;i++){var n=!t&&1==(o>>i&1);6>i?this.modules[i][8]=n:8>i?this.modules[i+1][8]=n:this.modules[this.moduleCount-15+i][8]=n;var n=!t&&1==(o>>i&1);8>i?this.modules[8][this.moduleCount-i-1]=n:9>i?this.modules[8][15-i-1+1]=n:this.modules[8][15-i-1]=n}this.modules[this.moduleCount-8][8]=!t},createData:function(){var t=new s,e=this.typeNumber>9?16:8;t.put(4,4),t.put(this.utf8bytes.length,e);for(var r=0,o=this.utf8bytes.length;o>r;r++)t.put(this.utf8bytes[r],8);for(t.length+4<=8*this.totalDataCount&&t.put(0,4);t.length%8!=0;)t.putBit(!1);for(;;){if(t.length>=8*this.totalDataCount)break;if(t.put(i.PAD0,8),t.length>=8*this.totalDataCount)break;t.put(i.PAD1,8)}return this.createBytes(t)},createBytes:function(t){for(var e=0,r=0,o=0,i=this.rsBlock.length/3,s=new Array,u=0;i>u;u++)for(var a=this.rsBlock[3*u+0],h=this.rsBlock[3*u+1],g=this.rsBlock[3*u+2],c=0;a>c;c++)s.push([g,h]);for(var d=new Array(s.length),f=new Array(s.length),m=0;m=0?A.get(T):0}}for(var C=new Array(this.totalDataCount),x=0,u=0;r>u;u++)for(var m=0;mu;u++)for(var m=0;m0;s-=2)for(6==s&&s--;;){for(var u=0;2>u;u++)if(null==this.modules[o][s-u]){var a=!1;n>>i&1));var h=l.getMask(e,o,s-u);h&&(a=!a),this.modules[o][s-u]=a,i--,-1==i&&(n++,i=7)}if(o+=r,0>o||this.moduleCount<=o){o-=r,r=-r;break}}}},i.PAD0=236,i.PAD1=17;for(var u=[1,0,3,2],a={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7},l={PATTERN_POSITION_TABLE:[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58],[6,34,62],[6,26,46,66],[6,26,48,70],[6,26,50,74],[6,30,54,78],[6,30,56,82],[6,30,58,86],[6,34,62,90],[6,28,50,72,94],[6,26,50,74,98],[6,30,54,78,102],[6,28,54,80,106],[6,32,58,84,110],[6,30,58,86,114],[6,34,62,90,118],[6,26,50,74,98,122],[6,30,54,78,102,126],[6,26,52,78,104,130],[6,30,56,82,108,134],[6,34,60,86,112,138],[6,30,58,86,114,142],[6,34,62,90,118,146],[6,30,54,78,102,126,150],[6,24,50,76,102,128,154],[6,28,54,80,106,132,158],[6,32,58,84,110,136,162],[6,26,54,82,110,138,166],[6,30,58,86,114,142,170]],G15:1335,G18:7973,G15_MASK:21522,getBCHTypeInfo:function(t){for(var e=t<<10;l.getBCHDigit(e)-l.getBCHDigit(l.G15)>=0;)e^=l.G15<=0;)e^=l.G18<>>=1;return e},getPatternPosition:function(t){return l.PATTERN_POSITION_TABLE[t-1]},getMask:function(t,e,r){switch(t){case a.PATTERN000:return(e+r)%2==0;case a.PATTERN001:return e%2==0;case a.PATTERN010:return r%3==0;case a.PATTERN011:return(e+r)%3==0;case a.PATTERN100:return(Math.floor(e/2)+Math.floor(r/3))%2==0;case a.PATTERN101:return e*r%2+e*r%3==0;case a.PATTERN110:return(e*r%2+e*r%3)%2==0;case a.PATTERN111:return(e*r%3+(e+r)%2)%2==0;default:throw new Error("bad maskPattern:"+t)}},getErrorCorrectPolynomial:function(t){for(var e=new n([1],0),r=0;t>r;r++)e=e.multiply(new n([1,h.gexp(r)],0));return e},getLostPoint:function(t){for(var e=t.getModuleCount(),r=0,o=0,i=0;e>i;i++)for(var n=0,s=t.modules[i][0],u=0;e>u;u++){var a=t.modules[i][u];if(e-6>u&&a&&!t.modules[i][u+1]&&t.modules[i][u+2]&&t.modules[i][u+3]&&t.modules[i][u+4]&&!t.modules[i][u+5]&&t.modules[i][u+6]&&(e-10>u?t.modules[i][u+7]&&t.modules[i][u+8]&&t.modules[i][u+9]&&t.modules[i][u+10]&&(r+=40):u>3&&t.modules[i][u-1]&&t.modules[i][u-2]&&t.modules[i][u-3]&&t.modules[i][u-4]&&(r+=40)),e-1>i&&e-1>u){var l=0;a&&l++,t.modules[i+1][u]&&l++,t.modules[i][u+1]&&l++,t.modules[i+1][u+1]&&l++,(0==l||4==l)&&(r+=3)}s^a?n++:(s=a,n>=5&&(r+=3+n-5),n=1),a&&o++}for(var u=0;e>u;u++)for(var n=0,s=t.modules[0][u],i=0;e>i;i++){var a=t.modules[i][u];e-6>i&&a&&!t.modules[i+1][u]&&t.modules[i+2][u]&&t.modules[i+3][u]&&t.modules[i+4][u]&&!t.modules[i+5][u]&&t.modules[i+6][u]&&(e-10>i?t.modules[i+7][u]&&t.modules[i+8][u]&&t.modules[i+9][u]&&t.modules[i+10][u]&&(r+=40):i>3&&t.modules[i-1][u]&&t.modules[i-2][u]&&t.modules[i-3][u]&&t.modules[i-4][u]&&(r+=40)),s^a?n++:(s=a,n>=5&&(r+=3+n-5),n=1)}var h=Math.abs(100*o/e/e-50)/5;return r+=10*h}},h={glog:function(t){if(1>t)throw new Error("glog("+t+")");return h.LOG_TABLE[t]},gexp:function(t){for(;0>t;)t+=255;for(;t>=256;)t-=255;return h.EXP_TABLE[t]},EXP_TABLE:new Array(256),LOG_TABLE:new Array(256)},g=0;8>g;g++)h.EXP_TABLE[g]=1<g;g++)h.EXP_TABLE[g]=h.EXP_TABLE[g-4]^h.EXP_TABLE[g-5]^h.EXP_TABLE[g-6]^h.EXP_TABLE[g-8];for(var g=0;255>g;g++)h.LOG_TABLE[h.EXP_TABLE[g]]=g;n.prototype={get:function(t){return this.num[t]},getLength:function(){return this.num.length},multiply:function(t){for(var e=new Array(this.getLength()+t.getLength()-1),r=0;re-r)return this;for(var o=new Array(e),i=0;e>i;i++)o[i]=this.get(i);for(;o.length>=r;){for(var s=h.glog(o[0])-h.glog(t.get(0)),i=0;it;t++){var e=c[4*(t-1)+this.errorCorrectLevel];if(void 0==e)throw new Error("bad rs block @ typeNumber:"+t+"/errorCorrectLevel:"+this.errorCorrectLevel);for(var r=e.length/3,o=0,i=0;r>i;i++){var n=e[3*i+0],s=e[3*i+2];o+=s*n}var u=t>9?2:1;if(this.utf8bytes.length+u>>7-t%8&1},put:function(t,e){for(var r=0;e>r;r++)this.putBit(t>>>e-r-1&1)},putBit:function(t){var e=Math.floor(this.length/8);this.buffer.length<=e&&this.buffer.push(0),t&&(this.buffer[e]|=128>>>this.length%8),this.length++}},t.exports=i},function(t,e){t.exports=function(t){for(var e,r=Array.prototype.slice.call(arguments,1),o=0;e=r[o];o++)if(e)for(var i in e)t[i]=e[i];return t}}]); \ No newline at end of file From d2d81dfb7595caeb95f99f0ff064c6f976a1be17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8F=B6=E8=A8=80?= Date: Mon, 30 Nov 2015 10:18:32 +0800 Subject: [PATCH 10/10] =?UTF-8?q?fix:CI=20=E8=B6=85=E6=97=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/qrcode-spec.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tests/qrcode-spec.js b/tests/qrcode-spec.js index c1a43c2..690c016 100644 --- a/tests/qrcode-spec.js +++ b/tests/qrcode-spec.js @@ -70,10 +70,11 @@ describe('qrcode', function() { }); }); it('最长字符串', function() { - var s = ''; - for(var i = 0; i < 2953; i++){ + var s = '0123456789'; + for(var i = 0; i < 295; i+=10){ s += i%10; } + s+='012'; var qrnode = new qrcode({ width:500, height:500, @@ -83,8 +84,8 @@ describe('qrcode', function() { }); it('超过最长字符串容错处理,截取前2953个字符', function() { var s = ''; - var t = '0123456789'; - for(var i = 0; i < 3000; i+=10){ + var t = '01234567890123456789'; + for(var i = 0; i < 150; i+=20){ s += t; } var qrnode = new qrcode({