UNPKG

react-fancy-qrcode

Version:

Customizable QR code generated for React & React Native

43 lines 1.52 kB
import React from "react"; /** * Creates a single pixel dot in the QRCode */ export default React.memo(function (_a) { var value = _a.value, row = _a.row, column = _a.column, cellSize = _a.cellSize, color = _a.color, logoStartCell = _a.logoStartCell, logoStopCell = _a.logoStopCell, sideCount = _a.sideCount, dotScale = _a.dotScale, dotRadius = _a.dotRadius, svgDom = _a.svgDom; if (!value) { return null; } var inPositioningPattern = function () { // Top left if (column <= 7 && row <= 7) { return true; } // Top right if (column >= sideCount - 8 && row <= 7) { return true; } // Bottom left if (column <= 7 && row >= sideCount - 7) { return true; } return false; }; var inLogoArea = logoStartCell && logoStopCell && column >= logoStartCell && column < logoStopCell && row >= logoStartCell && row < logoStopCell; // Do not add pixels to logo or positioning pattern areas if (inLogoArea || inPositioningPattern()) { return null; } // Scale the dot var size = cellSize * (dotScale || 1); var offset = dotScale !== 1 ? (cellSize - size) / 2 : 0; var x = column * cellSize + offset; var y = row * cellSize + offset; var Rect = svgDom.Rect; return (React.createElement(Rect, { x: x, y: y, width: size, height: size, fill: color, ry: dotRadius })); }); //# sourceMappingURL=Dot.js.map