我正在寻找一个好看的解决方案,用 Tikz 绘制带有剪刀符号的切口。
我的出发点解释了要做的事情如下:
相应的当前 LaTeX/Tikz 代码如下:
\documentclass{standalone}
\usepackage{tikz}
\usepackage{bbding}
\begin{document}
\begin{tikzpicture}
\begin{scope}
\clip (-0.5,0.3) .. controls +(1,0.4) and +(-1,-0.4) .. (3.7,0.3) -- (3.7,2) -- (0,2) -- cycle;
\node[fill=blue!20!white,rectangle,rounded corners=0.5cm,thick,inner sep=15pt,draw,anchor=south west]
at (0,0) {Hello World};
\end{scope}
\draw[thick,color=black!50!white,dashed] (-0.5,0.3) .. controls +(1,0.4) and +(-1,-0.4) ..
node[pos=0.2] {\color{black} \scriptsize \ScissorRightBrokenBottom}
node[pos=0.4] {\color{black} \scriptsize \ScissorRightBrokenBottom}
node[pos=0.6] {\color{black} \scriptsize \ScissorRightBrokenBottom}
node[pos=0.8] {\color{black} \scriptsize \ScissorRightBrokenBottom}
(3.7,0.3);
\end{tikzpicture}
\end{document}
但这还不够好:
- 剪刀不旋转并且位置有点太低。
- 重复的切割路径也不是最佳的。
我的问题是:如何提高解决方案的质量(同时在最佳情况下修复切割路径的冗余度)。
答案1
您可以使用decorations.markings
库:
\documentclass[tikz, border=3mm]{standalone}
\usetikzlibrary{decorations.markings}
\usepackage{bbding}
\begin{document}
\begin{tikzpicture}[
decoration={markings,
mark=between positions 0.2 and 0.8 step 0.2
with { \node[font=\scriptsize,yshift=\pgflinewidth,
transform shape] {\ScissorRightBrokenBottom};}}
]
\begin{scope}
\clip (-0.5,0.3) .. controls +(1,0.4) and +(-1,-0.4) .. (3.7,0.3) -- (3.7,2) -| cycle;
\node[rounded corners=0.5cm,draw,thick,fill=blue!20!white,
inner sep=15pt,anchor=south west] {Hello World};
\end{scope}
\path[draw=black!50!white, thick, dashed,
postaction={decorate}] (-0.5,0.3) .. controls +(1,0.4) and +(-1,-0.4) .. (3.7,0.3);
\end{tikzpicture}
\end{document}
编辑: 现在剪刀方向按照 OP 评论中的要求沿着线移动。