我使用以下代码来绘制此图
\documentclass{beamer}
\beamertemplatenavigationsymbolsempty
\usepackage{tikz}
\tikzset{contour/.style={insert path={(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
}}}
\begin{document}
\begin{frame}[t]
\frametitle{Spirograph 1 outline}
\begin{tikzpicture}
\begin{scope}
\foreach \Y [count=\Z starting from 0] in {red,blue,blue!50} {\draw[rotate=\Z*30,contour,fill opacity=0.5]; }
\foreach \Y in {0,1,2}
{
\begin{scope}
\foreach \Z in {0,1,2} {\ifnum\Y=\Z \else \path[clip,rotate=\Z*30,contour]; \fi};
\end{scope}
}
\foreach \Y [count=\Z starting from 0] in {red,blue,blue!50} {\draw[draw=\Y,line width=0.5mm,rotate=\Z*30,contour]; }
\end{scope}
\end{tikzpicture}
\end{frame}
\end{document}
从答案到这和这问题,其中只显示外部轮廓;我想应用这个使用过的代码
\begin{tikzpicture}[pics/fcross/.style={code={
\path[line width=.1cm,fill=blue!40!white, looseness=1,pic actions]
(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;
}}]
\begin{scope}[blend group=lighten,fill opacity=.4]
\path foreach \Y in {0,30,60} {pic[rotate=\Y,scale=2] {fcross}};
\end{scope}
\path foreach \Y in {0,30,60} {pic[rotate=\Y,scale=2,draw=blue!40] {fcross}};
\end{tikzpicture}
制作以下图纸。
答案1
使用 clip 您可以完成所有这些操作。
\documentclass{beamer}
\beamertemplatenavigationsymbolsempty
\usepackage{tikz}
\tikzset{contour/.style={insert path={(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
}}}
\begin{document}
\begin{frame}[t]
\frametitle{Spirograph 1 outline}
\begin{tikzpicture}
\begin{scope}
\foreach \Y [count=\Z starting from 0] in {red,blue,blue!50}
{\draw[draw=\Y,line width=0.5mm,rotate=\Z*30,contour]; }
\end{scope}
\begin{scope}[xshift=5cm]
\path[contour];
\path[rotate=45,contour];
\foreach \Y [count=\Z starting from 0] in {red,blue,blue!50}
{\begin{scope}
\clip[overlay] [rotate=\Z*30-30] (0:1) foreach \X in {0,90,180,270} {[rotate=\X]
--(0:1) -- (0:3) -- (60:3) -- (60:1)};
\draw[draw=\Y,line width=0.5mm,rotate=\Z*30,contour];
\end{scope}}
\end{scope}
\end{tikzpicture}
\end{frame}
\begin{frame}[t]
\frametitle{Spirograph 1 outline}
\begin{tikzpicture}
\begin{scope}
\path[contour];
\path[rotate=45,contour];
\foreach \Y [count=\Z starting from 0] in {red,blue,blue!50}
{\begin{scope}
\clip[overlay] [rotate=\Z*30-15] (0:1) foreach \X in {0,90,180,270}
{[rotate=\X]
--(0:1) -- (0:3) -- (30:3) -- (30:1)};
\draw[draw=\Y,line width=0.5mm,rotate=\Z*30,contour];
\end{scope}}
\end{scope}
\begin{scope}[xshift=5cm]
\foreach \Y [count=\Z starting from 0] in {red,blue,blue!50}
{\begin{scope}
\clip[overlay] [rotate=\Z*30-15] foreach \X in {0,90,180,270}
{[rotate=\X]
(15:1.37) --(0:1.6) -- (0:3) -- (30:3) -- (30:1.6) -- cycle};
\draw[draw=\Y,fill=\Y,fill opacity=0.4,line width=0.5mm,rotate=\Z*30,contour];
\end{scope}}
\foreach \Y [count=\Z starting from 0] in {red,blue,blue!50}
{\begin{scope}
\clip[overlay] [rotate=\Z*30-30] (0:1) foreach \X in {0,90,180,270} {[rotate=\X]
--(0:1) -- (0:3) -- (60:3) -- (60:1)};
\draw[draw=\Y,line width=0.5mm,rotate=\Z*30,contour];
\end{scope}}
\end{scope}
\end{tikzpicture}
\end{frame}
\end{document}