0

How would one begin to adapt this useful little package (https://ctan.org/pkg/qrcode?lang=en) to enable a call such as:

\qrcode[rounded corners=0.1mm]{348b0b3}%

Where the outcome is being able to control the corner radius of each black module from 0 to the module half-width (in which case one gets a circular modules).

  • 1
    In principle, I think this is possible. You can maybe patch the macro \rule within \qrcode. However, the result may not be what you expect, because the package draws each pixel independently, so connected blocks of black will appear as black dots, instead of a black rectangle with rounded corners. – jessexknight Feb 20 '24 at 22:29

2 Answers2

5

This technically answers your question, but the result may not be what you expected. Option 1 (commented & result) draws a tikzpicture for each pixel, so it's slow but very flexible. Option 2 (uncommented & not shown) scales any character to the pixel size, so it's fast but less flexible.

MWE

\documentclass{article}
\usepackage{qrcode,tikz,graphicx}
\makeatletter
\let\xqrcode@int\qrcode@int% store package macro
\def\qrcode@int{\let\xrule\rule% store old rule
  \let\rule\altrule% overwrite rule
  \xqrcode@int% package macro
  \let\rule\xrule% restore rule
}
\makeatother
% option 1: tikz (slow but flexible); tikz package
% \newcommand{\altrule}[2]{\tikzpicture% custom tikz rule
%     \fill[rounded corners=.3mm] (0,0) rectangle (#1,#2);
%   \endtikzpicture}
% option 2: any character (fast but less flexible); graphicx package
\newcommand{\altsym}{$\bullet$}% alt symbol
\newcommand{\altrule}[2]{% custom rule: logix
  \resizebox{#1}{!}{%
    \ifdim#2>0pt\altsym\else\phantom{\altsym}\fi}}
\begin{document}
\qrcode{348b0b3}
\end{document}

Result

result

jessexknight
  • 2,732
4

PSTricks package pst-barcode provides an option for circular modules: dotty.

Typeset with lualatex:

\documentclass[border=1bp]{standalone}
\usepackage{pst-barcode}

\begin{document} \makebox[1in][l]{\rule{0pt}{1in}% % option inkspread controls overlapping amount (in pt) of dots; <0 enlarges dots \psbarcode{348b0b3}{dotty inkspread=0.05 width=1 height=1}{qrcode}% } \end{document}

enter image description here

AlexG
  • 54,894