Skip to content

Commit 61d143b

Browse files
authored
Merge pull request #41 from EagleoutIce/5-allow-for-circular-cut-outs-not-just-rectangle
Rounded Cutoff
2 parents 002c879 + b78809a commit 61d143b

File tree

3 files changed

+24
-5
lines changed

3 files changed

+24
-5
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ You may use `\fancyqr` just like the normal `\qrcode` (`\fancyqr[<qr-options>]{<
99

1010
*fancyqr* is actively developed by *Florian Sihler* (contact me at: <[email protected]>) under the [GPLv3 License](LICENSE). I am very happy about every contribution (see [CONTRIBUTING.md](CONTRIBUTING.md)). You can find it on CTAN (<https://www.ctan.org/pkg/fancyqr>).
1111

12-
If you do want to hide a center square (e.g., because you want to embed an image), you can use `\FancyQrDoNotPrintSquare{<x>}{<y>}` to hide a rectangle with radius x and y set from the center. If you choose this option, the default `\FancyQrRoundCut` that rounds cut corners can be changed with `\FancyQrHardCut`.
12+
If you do want to hide a center square (e.g., because you want to embed an image), you can use `\FancyQrDoNotPrintSquare{<x>}{<y>}` to hide a rectangle with radius x and y set from the center (with `\FancyQrDoNotPrintRadius{<factor>}` you can apply a [rounding](https://github.com/EagleoutIce/fancyqr/pull/41) to this!). If you choose this option, the default `\FancyQrRoundCut` that rounds cut corners can be changed with `\FancyQrHardCut`.
1313
At the moment, there are six other styles (`flat`, `frame`, `blobs`, `glitch`, and `dots`) that you can load (locally) by using `\FancyQrLoad{<name>}`. The default style is named `default` and can be 'reset' by `\FancyQrLoad{default}` or `\FancyQrLoadDefault`.
1414

1515
There are the following extra qr-options (you can set all of them with `\fancyqrset{<keys>}`):

fancyqr-doc.tex

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
\texttt{fancyqr} is a simple package to create fancy qr-codes with the help of the \textit{\href{https://www.ctan.org/pkg/qrcode}{qrcode}}-package.
4545
You can use the |\fancyqr|-macro just like the normal |\qrcode|.\footnote{\ltx{\\fancyqr[<qr-options>]\{<url>\}}}
4646

47-
If you do want to hide a center square (e.g, because you want to embed an image) you can use |\FancyQrDoNotPrintSquare{<x>}{<y>}| to hide a rectangle with radius x and y set from the center. If you choose this option, the default |\FancyQrRoundCut| that rounds cut corners can be changed with |\FancyQrHardCut|.
47+
If you do want to hide a center square (e.g, because you want to embed an image) you can use |\FancyQrDoNotPrintSquare{<x>}{<y>}| to hide a rectangle with radius x and y set from the center (with |\FancyQrDoNotPrintRadius{<factor>}| you can apply a \href{https://github.com/EagleoutIce/fancyqr/pull/41}{rounding} to this!). If you choose this option, the default |\FancyQrRoundCut| that rounds cut corners can be changed with |\FancyQrHardCut|.
4848
At the moment, there are six other styles for the qr-code |flat|, |frame|, |blobs|, |glitch|, and |dots|, that you can load (locally) by using |\FancyQrLoad{<name>}|. The default style is named |default| and can be 'reset' by |\FancyQrLoad{default}| or |\FancyQrLoadDefault|.
4949

5050
All of the extra qr-options (you can set all of them with |\fancyqrset{<keys>}|) are showcased in \autoref{tbl:extra-keys}.

fancyqr.sty

+22-3
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,30 @@
121121
\else\qr@white@format\fi
122122
}%
123123

124-
\def\FancyQrDoNotPrintSquare#1#2{\def\fancy@qr@donotprint@center@x{#1}\def\fancy@qr@donotprint@center@y{#2}}
124+
% #1 width
125+
% #2 height
126+
\def\FancyQrDoNotPrintSquare#1#2{%
127+
\def\fancy@qr@donotprint@center@x{#1}%
128+
\def\fancy@qr@donotprint@center@y{#2}%
129+
}
125130
\FancyQrDoNotPrintSquare00
131+
% is a factor between 0 and 1
132+
\def\FancyQrDoNotPrintRadius#1{%
133+
\def\fancy@qr@donotprint@center@r{#1}%
134+
}
135+
\FancyQrDoNotPrintRadius0
126136

127137
\newif\iffancy@qr@do@print@
128138
\def\qr@fancy@updateif#1#2{\fancy@qr@do@print@true
129-
\ifnum#1>\@do@y@min\relax \ifnum#1<\@do@y@max\relax \ifnum#2>\@do@x@min\relax \ifnum#2<\@do@x@max\relax \fancy@qr@do@print@false \fi\fi\fi\fi}
139+
\ifdim\fancy@qr@donotprint@center@r\p@>\z@
140+
\ifnum#1>\@do@y@min\relax \ifnum#1<\@do@y@max\relax \ifnum#2>\@do@x@min\relax \ifnum#2<\@do@x@max\relax
141+
\ifdim\fpeval{sqrt((#1-\@half@max@y)^2 + (#2-\@half@max@x)^2)}\p@<\@max@rcrad\p@
142+
\fancy@qr@do@print@false
143+
\fi
144+
\fi\fi\fi\fi
145+
\else
146+
\ifnum#1>\@do@y@min\relax \ifnum#1<\@do@y@max\relax \ifnum#2>\@do@x@min\relax \ifnum#2<\@do@x@max\relax \fancy@qr@do@print@false \fi\fi\fi\fi\fi
147+
}
130148

131149
\newif\iffancy@qr@roundcut@
132150
\fancy@qr@roundcut@true
@@ -147,8 +165,8 @@
147165

148166
\newif\if@fancyqr@image@
149167

168+
\def\qr@white{0}\def\qr@black{1}%
150169
\def\fancy@qr@printmatrix#1{%
151-
\def\qr@white{0}\def\qr@black{1}%
152170
\protected@edef\fancyqr@currprint{#1}%
153171
\let\qr@black@fixed\qr@black \let\qr@white@fixed\qr@white
154172
\let\qr@black@format\qr@black \let\qr@white@format\qr@white
@@ -180,6 +198,7 @@
180198
\edef\@do@x@max{\the\numexpr\@half@max@x+\fancy@qr@donotprint@center@x+\@ne}%
181199
\edef\@do@y@min{\the\numexpr\@half@max@y-\fancy@qr@donotprint@center@y-\@ne}%
182200
\edef\@do@y@max{\the\numexpr\@half@max@y+\fancy@qr@donotprint@center@y+\@ne}%
201+
\edef\@max@rcrad{\fpeval{max((\@ne-\fancy@qr@donotprint@center@r)*\fancy@qr@donotprint@center@x,(\@ne-\fancy@qr@donotprint@center@r)*\fancy@qr@donotprint@center@y)+\fancyqr@edge@compensate}}%
183202
\edef\@tmp@tight{\ifqr@tight\z@\else-4\fi}%
184203
\picture(\qr@minipagewidth,\qr@minipagewidth)(\the\numexpr\@ne+\@tmp@tight,\@tmp@tight)
185204
\qr@for \i=\@ne to \@max@y by \@ne{\qr@for \j=\@ne to \@max@x by \@ne{%

0 commit comments

Comments
 (0)