我使用tcolorbox
作为图片的背景。最终颜色尚未确定。目前是green!5!white
。其中一张图片应显示一种类似于纸张上打孔的图案。背景应通过这些孔可见。此外,这张纸应有阴影,阴影也应通过这些打孔可见,但仅在顶部和左侧边框处可见。我目前得到的结果:
\documentclass[border=5pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{shadows}
\begin{document}
\begin{tikzpicture}[%
d0/.style={%
font=\ttfamily},
d1/.style={%
minimum width = 0.50 cm,
minimum height = 0.75 cm,
draw,
fill=green!5!white,
}
]
\path [fill=white, draw, drop shadow] (-0.4,2.25) rectangle (2.9,8.5);
\node at (1.25,9){bumpmap};
\foreach \f [count=\x] in {%
% percentage signs are necessary,
% otherwise node style is not recognized correctly
1,0,1,0,1,1,%
0,0,0,0,1,0,%
0,1,1,0,0,0,%
0,1,0,0,0,1,%
0,1,0,1,1,0,%
0,0,0,0,1,1,%
1,0,1,0,0,0,%
0,0,1,0,0,1%
}{%
\pgfmathMod{\x-1}{6};
\edef\myx{\pgfmathresult};
\pgfmathdiv{\x-1}{6};
\edef\myy{\pgfmathresult};
\node [d\f] at (\myx*0.5,8-\myy*0.75) {};
}
\end{tikzpicture}
\end{document}
我的 MWE 上的打孔是假的。我无法处理evenoddrule
这么多孔,而且我也错过了绿色孔内的阴影。非常感谢您的想法、提示或解决方案。
提前谢谢了
答案1
正如我在评论中所指出的,我想发布一种解决方法,虽然它并不完美并且仍然会显示非常细的不需要的线条,但它至少显示了我想要的打孔。
\documentclass[border=5pt]{standalone}
\usepackage{tikz}
\usepackage{ifthen}
\usetikzlibrary{shadows}
\begin{document}
\begin{tikzpicture}[even odd rule]
\begin{scope}[shift={(0,0)}]
\node at (1.5,9.25){Pattern};
\foreach \f [count=\x] in {%
1,0,1,0,1,1,%
0,0,0,0,1,0,%
0,1,1,0,0,0,%
0,1,0,0,0,1,%
0,1,0,1,1,0,%
0,0,0,0,1,1,%
1,0,1,0,0,0,%
0,0,1,0,0,1%
}{%
\pgfmathMod{\x-1}{6};
\edef\myx{\pgfmathresult};
\pgfmathdiv{\x-1}{6};
\edef\myy{\pgfmathresult};
\ifthenelse {\f=0}
{\fill [drop shadow,fill=brown!20!white]
(\myx*0.5,8-\myy*0.8) rectangle ++(0.5,0.8);
}
{\fill [drop shadow,fill=brown!20!white]
(\myx*0.5,8-\myy*0.8) rectangle ++(0.5,0.8)
(\myx*0.5+0.1,8-\myy*0.8+0.1) rectangle ++(0.3,0.6);
}
\path [draw] (0,2.4) rectangle (3,8.8);
}
\end{scope}
\end{tikzpicture}
\end{document}