Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | 6x 6x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 31x 31x 31x 31x 31x 31x | import { createDataURL } from './data-url-canvas.render.js'
import { escapeXml } from '../utils/escape-xml.util.js'
/**
* @param {object} opts - function parameters
* @param {number} [opts.cellSize] - cell size in pixels, defaults to 2
* @param {number} [opts.margin] - margin in pixels, defaults to {@link cellSize} * 4
* @param {string} [opts.alt] - image description
* @param {import('../qr-code.js').QrCode} opts.qrcode - QR Code data
* @param {import('../utils/css-colors.util.js').QRCodeCssColors} [opts.colors] - qr code colors
* @param {import('../utils/css-qrcode-style.util.js').QRCodeCssStyles} [opts.style] - qr code colors
* @returns {string} <img> element outer HTML
*/
export function createImgTag ({ cellSize, margin, alt, qrcode, colors, style }) {
cellSize ||= 2
margin ??= cellSize * 4
const size = qrcode.moduleCount * cellSize + margin * 2
const altAttr = alt ? ` alt="${escapeXml(alt)}"` : ''
return `<img src="${createDataURL({ cellSize, margin, qrcode, colors, style })}" width="${size}" height="${size}"${altAttr}/>`
};
|