1 // var Utils = require('./utils')
3 exports.render = function (qrData, options, cb) {
4 var size = qrData.modules.size
5 var data = qrData.modules.data
7 // var opts = Utils.getOptions(options)
9 // use same scheme as https://github.com/gtanner/qrcode-terminal because it actually works! =)
10 var black = '\x1b[40m \x1b[0m'
11 var white = '\x1b[47m \x1b[0m'
14 var hMargin = Array(size + 3).join(white)
15 var vMargin = Array(2).join(white)
17 output += hMargin + '\n'
18 for (var i = 0; i < size; ++i) {
20 for (var j = 0; j < size; j++) {
21 // var topModule = data[i * size + j]
22 // var bottomModule = data[(i + 1) * size + j]
24 output += data[i * size + j] ? black : white// getBlockChar(topModule, bottomModule)
26 // output += white+'\n'
27 output += vMargin + '\n'
30 output += hMargin + '\n'
32 if (typeof cb === 'function') {
39 exports.renderToFile = function renderToFile (path, qrData, options, cb) {
40 if (typeof cb === 'undefined') {
45 var fs = require('fs')
46 var utf8 = exports.render(qrData, options)
47 fs.writeFile(path, utf8, cb)