我想在二维码的中心剪切一个矩形,但是它不能满足我的要求。
node
第一个是反转剪辑,然后我调换和命令的顺序clip
,第二个无法满足剪辑效果。我该如何实现效果?
MWE 正在关注
\documentclass[tikz]{standalone}
\usepackage{qrcode}
\pagecolor{yellow!10}
\begin{document}
\begin{tikzpicture}
\node at (0,0) {\includegraphics [width=4em] {example-image.pdf}};
\begin{scope}
\clip [draw] (-.5em,-.5em) rectangle (.5em,.5em);
\node [inner sep=0] at (0,0) {
\qrcode[height=3em,level=M]{LaTeX}};
\end{scope}
\end{tikzpicture}
\begin{tikzpicture}
\node at (0,0) {\includegraphics [width=4em] {example-image.pdf}};
\begin{scope}
\node [inner sep=0] at (0,0) {
\qrcode[height=3em,level=M]{LaTeX}};
\clip [draw] (-.5em,-.5em) rectangle (.5em,.5em);
\end{scope}
\end{tikzpicture}
\end{document}
答案1
\clip
执行下列操作。如果要将部分图像包含在二维码的中心,则应更改图片中指令的顺序:
%% draw the QR code
\node [inner sep=0] at (0,0) {\qrcode[height=3em,level=M]{LaTeX}};
%% clip
\clip [draw] (-.5em,-.5em) rectangle (.5em,.5em);
%% all following drawings are now clipped, draw the image
\node at (0,0) {\includegraphics [width=4em] {example-image.pdf}};
但我不确定剪辑的二维码链接是否还能起作用。
完整示例:
\documentclass[tikz]{standalone}
\usepackage{qrcode}
\pagecolor{yellow!10}
\begin{document}
\begin{tikzpicture}
%% draw the QR code
\node [inner sep=0] at (0,0) {\qrcode[height=3em,level=M]{LaTeX}};
%% clip
\clip [draw] (-.5em,-.5em) rectangle (.5em,.5em);
%% all following drawings are now clipped, draw the image
\node at (0,0) {\includegraphics [width=4em] {example-image.pdf}};
\end{tikzpicture}
\end{document}