const wx2my = require('../wx2my');
const Behavior = require('../Behavior');
var barcode = require('./barcode');

var qrcode = require('./qrcode');

function convert_length(length) {
  return Math.round(wx2my.getSystemInfoSync().windowWidth * length / 750);
}

function barc(id, code, width, height) {
  barcode.code128(wx2my.createCanvasContext(id), code, convert_length(width), convert_length(height));
}

function qrc(id, code, width, height) {
  qrcode.api.draw(code, {
    ctx: wx2my.createCanvasContext(id),
    width: convert_length(width),
    height: convert_length(height)
  });
}

module.exports = {
  barcode: barc,
  qrcode: qrc
};