Comparing version 0.1.1 to 0.1.2
{ | ||
"name": "qr.js", | ||
"name": "qrjs", | ||
"main": "qr.js", | ||
"version": "0.1.0", | ||
"version": "0.1.2", | ||
"homepage": "https://github.com/educastellano/qr.js", | ||
@@ -6,0 +6,0 @@ "authors": [ |
{ | ||
"name": "qrjs", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"description": "QR code generator in Javascript", | ||
@@ -5,0 +5,0 @@ "main": "qr.js", |
38
qr.js
@@ -735,2 +735,40 @@ /* qr.js -- QR code generator in Javascript (revision 2011-01-19) | ||
'generateSVG': function(data, options) { | ||
options = options || {}; | ||
var matrix = QRCode['generate'](data, options); | ||
var n = matrix.length; | ||
var modsize = Math.max(options.modulesize || 5, 0.5); | ||
var margin = Math.max(options.margin !== null ? options.margin : 4, 0.0); | ||
var size = modsize * (n + 2 * margin); | ||
var common = ' class= "fg"'+' width="'+modsize+'" height="'+modsize+'"/>'; | ||
var e = document.createElementNS('http://www.w3.org/2000/svg', 'svg'); | ||
e.setAttribute('viewBox', '0 0 '+size+' '+size); | ||
e.setAttribute('style', 'shape-rendering:crispEdges'); | ||
if (options.modulesize) { | ||
e.setAttribute('width', size); | ||
e.setAttribute('height', size); | ||
} | ||
var svg = [ | ||
'<style scoped>.bg{fill:#FFF}.fg{fill:#000}</style>', | ||
'<rect class="bg" x="0" y="0"', | ||
'width="'+size+'" height="'+size+'"/>', | ||
]; | ||
var yo = margin * modsize; | ||
for (var y = 0; y < n; ++y) { | ||
var xo = margin * modsize; | ||
for (var x = 0; x < n; ++x) { | ||
if (matrix[y][x]) | ||
svg.push('<rect x="'+xo+'" y="'+yo+'"', common); | ||
xo += modsize; | ||
} | ||
yo += modsize; | ||
} | ||
e.innerHTML = svg.join(''); | ||
return e; | ||
}, | ||
'generatePNG': function(data, options) { | ||
@@ -737,0 +775,0 @@ options = options || {}; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
29609
761