我使用了以下代码
\documentclass{beamer}
\beamertemplatenavigationsymbolsempty
\usepackage{tikz}
\begin{document}
\begin{frame}[t]
\frametitle{}
\begin{tikzpicture}
\draw[line width=.1cm,blue, fill=blue!40!white, opacity=.4, looseness=1, rounded corners=.4cm] (0,0) to [out=60,in=-150] ++ (2,2) to [out=150,in=-60] ++ (-2,2) to [out=-120,in=30] ++ (-2,-2) to [out=-30,in=120] ++ (2,-2) -- cycle;
\end{tikzpicture}
\end{frame}
\end{document}
绘制以下形状,
这产生了一个延伸的圆角。
从答案到这个问题,我明白这是由于计算错误或使用了圆角和长度为 0 的路径造成的,但我不知道如何摆脱它。
答案1
您在长度为 0 的路径上使用圆角,为此您还使用了--
,即-- cycle
拉伸。 有很多方法可以纠正这个问题,这里是其中一种,它可能不是最短的,但可以显示问题所在。
\documentclass{beamer}
\beamertemplatenavigationsymbolsempty
\usepackage{tikz}
\begin{document}
\begin{frame}[t]
\frametitle{}
\begin{tikzpicture}
\draw[line width=.1cm,blue, fill=blue!40!white, opacity=.4, looseness=1, rounded
corners=.4cm] (30:0.2) to [out=60,in=-150] (2,2) to [out=150,in=-60] ++ (-2,2)
to [out=-120,in=30] ++ (-2,-2) [sharp corners] to [out=-30,in=120] (150:0.2)
to[out=-60,in=-120] cycle;
\end{tikzpicture}
\end{frame}
\end{document}
不过,我会使用循环来绘制它。
\documentclass{beamer}
\beamertemplatenavigationsymbolsempty
\usepackage{tikz}
\begin{document}
\begin{frame}[t]
\frametitle{}
\begin{tikzpicture}
\begin{scope}[transparency group,opacity=.4,]
\draw[line width=.1cm,blue, fill=blue!40!white, looseness=1]
(0,-2) foreach \X in {0,90,180,270}
{[rotate=\X] -- (0,-2) to[out=0,in=-120] ++ (0.2,0.1) to[out=60,in=-150] ++ (1.7,1.7)
to[out=30,in=-90] ++ (0.1,0.2)} -- cycle;
\end{scope}
\end{tikzpicture}
\end{frame}
\end{document}
你也可以plot[smooth cycle]
在这里使用。右边的图只是为了解释参数。
\documentclass{beamer}
\beamertemplatenavigationsymbolsempty
\usepackage{tikz}
\begin{document}
\begin{frame}[t]
\frametitle{}
\begin{tikzpicture}[declare function={alpha=8;r1=2;r2=1.85;r3=1.2;}]
\begin{scope}[transparency group,opacity=.4]
\draw[line width=.1cm,blue, fill=blue!40!white]
plot[smooth cycle] coordinates
{(0:r1)
(alpha:r2) (45:1.3) (90-alpha:r2) (90:r1)
(alpha+90:r2) (45+90:1.3) (90-alpha+90:r2) (90+90:r1)
(alpha+180:r2) (45+180:1.3) (90-alpha+180:r2) (90+180:r1)
(alpha+270:r2) (45+270:1.3) (90-alpha+270:r2) };
\end{scope}
\begin{scope}[xshift=5cm,>=stealth]
\begin{scope}[transparency group,opacity=.4]
\draw[line width=.1cm,blue, fill=blue!40!white]
plot[smooth cycle] coordinates
{(0:r1)
(alpha:r2) (45:1.3) (90-alpha:r2) (90:r1)
(alpha+90:r2) (45+90:1.3) (90-alpha+90:r2) (90+90:r1)
(alpha+180:r2) (45+180:1.3) (90-alpha+180:r2) (90+180:r1)
(alpha+270:r2) (45+270:1.3) (90-alpha+270:r2) };
\end{scope}
\draw (2.4,0) -- (0,0) -- (alpha:2.4)
(2.2,0) arc(0:alpha:2.2) (alpha/2:2.5) node{$\alpha$};
\draw[<->] (0,0) -- node[right] {$r_1$}(90:r1);
\draw[<->] (0,0) -- node[left] {$r_2$}(90+alpha:r2);
\draw[<->] (0,0) -- node[below left] {$r_3$}(90+45:r3);
\end{scope}
\end{tikzpicture}
\end{frame}
\end{document}