qrcode
Advanced tools
Comparing version 1.3.4 to 1.4.0
@@ -10,20 +10,31 @@ var Utils = require('./utils') | ||
function getBlockChar (top, bottom) { | ||
if (top && bottom) return BLOCK_CHAR.BB | ||
if (top && !bottom) return BLOCK_CHAR.BW | ||
if (!top && bottom) return BLOCK_CHAR.WB | ||
return BLOCK_CHAR.WW | ||
var INVERTED_BLOCK_CHAR = { | ||
BB: ' ', | ||
BW: '▄', | ||
WW: '█', | ||
WB: '▀' | ||
} | ||
function getBlockChar (top, bottom, blocks) { | ||
if (top && bottom) return blocks.BB | ||
if (top && !bottom) return blocks.BW | ||
if (!top && bottom) return blocks.WB | ||
return blocks.WW | ||
} | ||
exports.render = function (qrData, options, cb) { | ||
var opts = Utils.getOptions(options) | ||
var blocks = BLOCK_CHAR | ||
if (opts.color.dark.hex === '#ffffff' || opts.color.light.hex === '#000000') { | ||
blocks = INVERTED_BLOCK_CHAR | ||
} | ||
var size = qrData.modules.size | ||
var data = qrData.modules.data | ||
var opts = Utils.getOptions(options) | ||
var output = '' | ||
var hMargin = Array(size + (opts.margin * 2) + 1).join(BLOCK_CHAR.WW) | ||
var hMargin = Array(size + (opts.margin * 2) + 1).join(blocks.WW) | ||
hMargin = Array((opts.margin / 2) + 1).join(hMargin + '\n') | ||
var vMargin = Array(opts.margin + 1).join(BLOCK_CHAR.WW) | ||
var vMargin = Array(opts.margin + 1).join(blocks.WW) | ||
@@ -37,3 +48,3 @@ output += hMargin | ||
output += getBlockChar(topModule, bottomModule) | ||
output += getBlockChar(topModule, bottomModule, blocks) | ||
} | ||
@@ -40,0 +51,0 @@ |
{ | ||
"name": "qrcode", | ||
"description": "QRCode / 2d Barcode api with both server side and client side support using canvas", | ||
"version": "1.3.4", | ||
"version": "1.4.0", | ||
"author": "Ryan Day <soldair@gmail.com>", | ||
@@ -6,0 +6,0 @@ "contributors": [ |
546839
7001