为了更好地控制 Spirograph 模式,可以使用以下答案中的 Spirograph 代码这个问题,需要修改。
此代码是
\documentclass{beamer}
\beamertemplatenavigationsymbolsempty
\usepackage{tikz}
\usetikzlibrary{shadings}
\begin{document}
\tikzset{pics/spiro/.style={code={
\tikzset{spiro/.cd,#1}
\def\pv##1{\pgfkeysvalueof{/tikz/spiro/##1}}
\draw[trig format=rad,pic actions] plot[variable=\t,domain=0:2*pi*\pv{nRotations}, samples=90*\pv{nRotations}+1,smooth cycle]
(
{(\pv{R}+\pv{r})*cos(\t)+\pv{p}*cos((\pv{R}+\pv{r})*\t/\pv{r})},
{(\pv{R}+\pv{r})*sin(\t)+\pv{p}*sin((\pv{R}+\pv{r})*\t/\pv{r})}
);
}},
spiro/.cd,R/.initial=6,r/.initial=-1.5,p/.initial=1,nRotations/.initial=1}
\begin{frame}[fragile,t]
\frametitle{Spiro 1 orig}
\begin{tikzpicture}[]
\draw
(0,0) pic[scale=0.5, violet, line width=0.6mm, rotate=45, lower left=orange, lower right=yellow, upper left=red, upper right=magenta]{spiro}
;
\end{tikzpicture}
\end{frame}
\end{document}
这是我的想法。我需要分段绘制图案,并确定起点的位置。
点 P 完成一个周期(360 度)需要行进的距离表示为 2*pi。因此,要绘制曲线的 0.25 倍、0.5 倍或整条曲线,您需要分别表示 (2*pi*0.25)、(2*pi*0.5) 或 (2*pi*1)。
完成整个图案可能需要不止一个循环。要绘制左侧的图形,需要 2 个 nRotations。第一个绘制红色图形,第二个绘制蓝色图形,以得到右侧的图形。
在原始代码中
t = vectorin(0, 0.05, 2*pi*nRotations)
其中 (0, 0.05, 2*pi) 指示程序以小线条绘制曲线,从点 0 到点 2*pi 的增量为 5% (0.05)。0.05 的增量决定了曲线的平滑度,尤其是对于更复杂的图案。
例如使用
t = vectorin(0, 0.05, 2 * pi * v_nRotations)
使用时
t = vectorin(0, 0.005, 2 * pi * v_nRotations) 产生更平滑的曲线
要绘制分段图案,我们必须控制点 P 的旋转
原始代码
spirograph = function (R, r, p, nRotations, color)
t = vectorin(0, 0.05, 2*pi*nRotations)
spirograph(60, -15, 10, 1, green)
修改为将图案绘制成 4 个单独的部分,每个部分使用不同的颜色。点 P 也不是从点 2*pi*0 开始,而是从点 2*pi*(0.000-.125) 开始(使每个峰值都具有一种颜色),并以 2*pi*(0.125)*2 为步长(通过乘以一个因子)到达点 2*pi*(0.125)*7(完成 360 度循环)。
这个想法是,第一个段不是从位置 0 开始,而是从位置 0 之前的一半开始;并且在其之后的一半结束。
新代码变为
spirograph = function (R, r, p, start, step, stop, object, lineSize, color, scale, n, fill)
t=vectorin(start, step, stop) (which provides more control on the beginning, increment, and end of the rotation cycle than when using nRotations)
addplot(object, x*scale, y* scale, n, lineSize, color, 0, 0, fill) (x*scale, y* scale is used in other drawings to control the x and y scaling separately)
以下代码:(其中 P 从点 2*pi*0.0 开始到 2*pi*1.0)以绿色绘制图案
spirograph(60*1.25 , -15*1.25 , 12*1.25 , 2*pi*0.00 , 0.05, 2*pi*1.00, p, 6, Green, 3.5, 0*360/4/6, "Transparent")
showplot(p, 0, 1, 1)
使用以下代码:其中 P 从点 2*pi*(0.000-.125) 开始到 2*pi*(0.000+.125),然后旋转得到的峰值
spirograph(60*1.25 , -15*1.25 , 12*1.25 , 2*pi*(0.000-.125) , 0.05, 2*pi*(0.000+.125), p, 6, Green, 3.5, 0*360/4, "Transparent")
spirograph(60*1.25 , -15*1.25 , 12*1.25 , 2*pi*(0.000-.125) , 0.05, 2*pi*(0.000+.125), p, 6, Blue , 3.5, 1*360/4, "Transparent")
spirograph(60*1.25 , -15*1.25 , 12*1.25 , 2*pi*(0.000-.125) , 0.05, 2*pi*(0.000+.125), p, 6, Red , 3.5, 2*360/4, "Transparent")
spirograph(60*1.25 , -15*1.25 , 12*1.25 , 2*pi*(0.000-.125) , 0.05, 2*pi*(0.000+.125), p, 6, Violet, 3.5, 3*360/4, "Transparent")
showplot(p, 0, 1, 1)
或使用以下代码(从点 2*pi*(0.125)*-1 开始并通过乘以一个因子进行旋转)
spirograph(60*1.25 , -15*1.25 , 12*1.25 , 2*pi*(0.125)*-1 , 0.05, 2*pi*(0.125)*1, p, 6, Green , 3.5, 0*360/4, "Transparent")
spirograph(60*1.25 , -15*1.25 , 12*1.25 , 2*pi*(0.125)*1 , 0.05, 2*pi*(0.125)*3, p, 6, Blue , 3.5, 0*360/4, "Transparent")
spirograph(60*1.25 , -15*1.25 , 12*1.25 , 2*pi*(0.125)*3 , 0.05, 2*pi*(0.125)*5, p, 6, Red , 3.5, 0*360/4, "Transparent")
spirograph(60*1.25 , -15*1.25 , 12*1.25 , 2*pi*(0.125)*5 , 0.05, 2*pi*(0.125)*7, p, 6, Violet, 3.5, 0*360/4, "Transparent")
showplot(p, 0, 1, 1)
可以重复和旋转此例程以绘制正确的图形,并填充
spirograph(60*1.25 , -15*1.25 , 12*1.25 , 2*pi*(0.000-.125) , 0.05, 2*pi*(0.000+.125), p, 6, Green, 3.5, 0*360/4/6, "#5500ff00")
spirograph(60*1.25 , -15*1.25 , 12*1.25 , 2*pi*(0.250*1-.125) , 0.05, 2*pi*(0.250*1+.125), p, 6, Blue, 3.5, 0*360/4/6, "#550000ff")
spirograph(60*1.25 , -15*1.25 , 12*1.25 , 2*pi*(0.250*2-.125) , 0.05, 2*pi*(0.250*2+.125), p, 6, Red, 3.5, 0*360/4/6, "#55ff0000")
spirograph(60*1.25 , -15*1.25 , 12*1.25 , 2*pi*(0.250*3-.125) , 0.05, 2*pi*(0.250*3+.125), p, 6, Violet,3.5, 0*360/4/6, "#55ff00ff")
spirograph(60*1.25 , -15*1.25 , 12*1.25 , 2*pi*(0.000-.125) , 0.05, 2*pi*(0.000+.125), p, 6, Green, 3.5, 1*360/4/6, "#5500ff00")
spirograph(60*1.25 , -15*1.25 , 12*1.25 , 2*pi*(0.250*1-.125) , 0.05, 2*pi*(0.250*1+.125), p, 6, Blue, 3.5, 1*360/4/6, "#550000ff")
spirograph(60*1.25 , -15*1.25 , 12*1.25 , 2*pi*(0.250*2-.125) , 0.05, 2*pi*(0.250*2+.125), p, 6, Red, 3.5, 1*360/4/6, "#55ff0000")
spirograph(60*1.25 , -15*1.25 , 12*1.25 , 2*pi*(0.250*3-.125) , 0.05, 2*pi*(0.250*3+.125), p, 6, Violet,3.5, 1*360/4/6, "#55ff00ff")
spirograph(60*1.25 , -15*1.25 , 12*1.25 , 2*pi*(0.000-.125) , 0.05, 2*pi*(0.000+.125), p, 6, Green, 3.5, 2*360/4/6, "#5500ff00")
spirograph(60*1.25 , -15*1.25 , 12*1.25 , 2*pi*(0.250*1-.125) , 0.05, 2*pi*(0.250*1+.125), p, 6, Blue, 3.5, 2*360/4/6, "#550000ff")
spirograph(60*1.25 , -15*1.25 , 12*1.25 , 2*pi*(0.250*2-.125) , 0.05, 2*pi*(0.250*2+.125), p, 6, Red, 3.5, 2*360/4/6, "#55ff0000")
spirograph(60*1.25 , -15*1.25 , 12*1.25 , 2*pi*(0.250*3-.125) , 0.05, 2*pi*(0.250*3+.125), p, 6, Violet,3.5, 2*360/4/6, "#55ff00ff")
spirograph(60*1.25 , -15*1.25 , 12*1.25 , 2*pi*(0.000-.125) , 0.05, 2*pi*(0.000+.125), p, 6, Green, 3.5, 3*360/4/6, "#5500ff00")
spirograph(60*1.25 , -15*1.25 , 12*1.25 , 2*pi*(0.250*1-.125) , 0.05, 2*pi*(0.250*1+.125), p, 6, Blue, 3.5, 3*360/4/6, "#550000ff")
spirograph(60*1.25 , -15*1.25 , 12*1.25 , 2*pi*(0.250*2-.125) , 0.05, 2*pi*(0.250*2+.125), p, 6, Red, 3.5, 3*360/4/6, "#55ff0000")
spirograph(60*1.25 , -15*1.25 , 12*1.25 , 2*pi*(0.250*3-.125) , 0.05, 2*pi*(0.250*3+.125), p, 6, Violet,3.5, 3*360/4/6, "#55ff00ff")
spirograph(60*1.25 , -15*1.25 , 12*1.25 , 2*pi*(0.000-.125) , 0.05, 2*pi*(0.000+.125), p, 6, Green, 3.5, 4*360/4/6, "#5500ff00")
spirograph(60*1.25 , -15*1.25 , 12*1.25 , 2*pi*(0.250*1-.125) , 0.05, 2*pi*(0.250*1+.125), p, 6, Blue, 3.5, 4*360/4/6, "#550000ff")
spirograph(60*1.25 , -15*1.25 , 12*1.25 , 2*pi*(0.250*2-.125) , 0.05, 2*pi*(0.250*2+.125), p, 6, Red, 3.5, 4*360/4/6, "#55ff0000")
spirograph(60*1.25 , -15*1.25 , 12*1.25 , 2*pi*(0.250*3-.125) , 0.05, 2*pi*(0.250*3+.125), p, 6, Violet,3.5, 4*360/4/6, "#55ff00ff")
spirograph(60*1.25 , -15*1.25 , 12*1.25 , 2*pi*(0.000-.125) , 0.05, 2*pi*(0.000+.125), p, 6, Green, 3.5, 5*360/4/6, "#5500ff00")
spirograph(60*1.25 , -15*1.25 , 12*1.25 , 2*pi*(0.250*1-.125) , 0.05, 2*pi*(0.250*1+.125), p, 6, Blue, 3.5, 5*360/4/6, "#550000ff")
spirograph(60*1.25 , -15*1.25 , 12*1.25 , 2*pi*(0.250*2-.125) , 0.05, 2*pi*(0.250*2+.125), p, 6, Red, 3.5, 5*360/4/6, "#55ff0000")
spirograph(60*1.25 , -15*1.25 , 12*1.25 , 2*pi*(0.250*3-.125) , 0.05, 2*pi*(0.250*3+.125), p, 6, Violet,3.5, 5*360/4/6, "#55ff00ff")
showplot(p, 0, 1, 1)
不必分段绘制整个图案,只需绘制、重复、旋转、填充和缩放图案的一部分即可制作出更具吸引力的图画。需要进行一些实验来找出使用的部分相交的地方,以避免它们重叠。
spirograph(60*1.5 , -15*1.5 , 12*1.5 , 2*pi*(0.000-.055), 0.05, 2*pi*(0.000+.055), p, 2, "#008800", 3.0, 0*(360/4/8)+0, "Transparent")
spirograph(60*1.5 , -15*1.5 , 12*1.5 , 2*pi*(0.250-.055), 0.05, 2*pi*(0.250+.055), p, 2, "#008800", 3.0, 0*(360/4/8)+0, "Transparent")
spirograph(60*1.5 , -15*1.5 , 12*1.5 , 2*pi*(0.500-.055), 0.05, 2*pi*(0.500+.055), p, 2, "#008800", 3.0, 0*(360/4/8)+0, "Transparent")
spirograph(60*1.5 , -15*1.5 , 12*1.5 , 2*pi*(0.750-.055), 0.05, 2*pi*(0.750+.055), p, 2, "#008800", 3.0, 0*(360/4/8)+0, "Transparent")
spirograph(60*1.5 , -15*1.5 , 12*1.5 , 2*pi*(0.000-.055), 0.05, 2*pi*(0.000+.055), p, 2, "#0000AA", 3.0, 1*(360/4/8)+0, "Transparent")
spirograph(60*1.5 , -15*1.5 , 12*1.5 , 2*pi*(0.250-.055), 0.05, 2*pi*(0.250+.055), p, 2, "#0000AA", 3.0, 1*(360/4/8)+0, "Transparent")
spirograph(60*1.5 , -15*1.5 , 12*1.5 , 2*pi*(0.500-.055), 0.05, 2*pi*(0.500+.055), p, 2, "#0000AA", 3.0, 1*(360/4/8)+0, "Transparent")
spirograph(60*1.5 , -15*1.5 , 12*1.5 , 2*pi*(0.750-.055), 0.05, 2*pi*(0.750+.055), p, 2, "#0000AA", 3.0, 1*(360/4/8)+0, "Transparent")
spirograph(60*1.5 , -15*1.5 , 12*1.5 , 2*pi*(0.000-.055), 0.05, 2*pi*(0.000+.055), p, 2, "#9933CC", 3.0, 2*(360/4/8)+0, "Transparent")
spirograph(60*1.5 , -15*1.5 , 12*1.5 , 2*pi*(0.250-.055), 0.05, 2*pi*(0.250+.055), p, 2, "#9933CC", 3.0, 2*(360/4/8)+0, "Transparent")
spirograph(60*1.5 , -15*1.5 , 12*1.5 , 2*pi*(0.500-.055), 0.05, 2*pi*(0.500+.055), p, 2, "#9933CC", 3.0, 2*(360/4/8)+0, "Transparent")
spirograph(60*1.5 , -15*1.5 , 12*1.5 , 2*pi*(0.750-.055), 0.05, 2*pi*(0.750+.055), p, 2, "#9933CC", 3.0, 2*(360/4/8)+0, "Transparent")
spirograph(60*1.5 , -15*1.5 , 12*1.5 , 2*pi*(0.000-.055), 0.05, 2*pi*(0.000+.055), p, 2, "#AA0000", 3.0, 3*(360/4/8)+0, "Transparent")
spirograph(60*1.5 , -15*1.5 , 12*1.5 , 2*pi*(0.250-.055), 0.05, 2*pi*(0.250+.055), p, 2, "#AA0000", 3.0, 3*(360/4/8)+0, "Transparent")
spirograph(60*1.5 , -15*1.5 , 12*1.5 , 2*pi*(0.500-.055), 0.05, 2*pi*(0.500+.055), p, 2, "#AA0000", 3.0, 3*(360/4/8)+0, "Transparent")
spirograph(60*1.5 , -15*1.5 , 12*1.5 , 2*pi*(0.750-.055), 0.05, 2*pi*(0.750+.055), p, 2, "#AA0000", 3.0, 3*(360/4/8)+0, "Transparent")
spirograph(60*1.5 , -15*1.5 , 12*1.5 , 2*pi*(0.000-.055), 0.05, 2*pi*(0.000+.055), p, 2, "#D2691E", 3.0, 4*(360/4/8)+0, "Transparent")
spirograph(60*1.5 , -15*1.5 , 12*1.5 , 2*pi*(0.250-.055), 0.05, 2*pi*(0.250+.055), p, 2, "#D2691E", 3.0, 4*(360/4/8)+0, "Transparent")
spirograph(60*1.5 , -15*1.5 , 12*1.5 , 2*pi*(0.500-.055), 0.05, 2*pi*(0.500+.055), p, 2, "#D2691E", 3.0, 4*(360/4/8)+0, "Transparent")
spirograph(60*1.5 , -15*1.5 , 12*1.5 , 2*pi*(0.750-.055), 0.05, 2*pi*(0.750+.055), p, 2, "#D2691E", 3.0, 4*(360/4/8)+0, "Transparent")
spirograph(60*1.5 , -15*1.5 , 12*1.5 , 2*pi*(0.000-.055), 0.05, 2*pi*(0.000+.055), p, 2, "#E9967A", 3.0, 5*(360/4/8)+0, "Transparent")
spirograph(60*1.5 , -15*1.5 , 12*1.5 , 2*pi*(0.250-.055), 0.05, 2*pi*(0.250+.055), p, 2, "#E9967A", 3.0, 5*(360/4/8)+0, "Transparent")
spirograph(60*1.5 , -15*1.5 , 12*1.5 , 2*pi*(0.500-.055), 0.05, 2*pi*(0.500+.055), p, 2, "#E9967A", 3.0, 5*(360/4/8)+0, "Transparent")
spirograph(60*1.5 , -15*1.5 , 12*1.5 , 2*pi*(0.750-.055), 0.05, 2*pi*(0.750+.055), p, 2, "#E9967A", 3.0, 5*(360/4/8)+0, "Transparent")
spirograph(60*1.5 , -15*1.5 , 12*1.5 , 2*pi*(0.000-.055), 0.05, 2*pi*(0.000+.055), p, 2, "#DAA520", 3.0, 6*(360/4/8)+0, "Transparent")
spirograph(60*1.5 , -15*1.5 , 12*1.5 , 2*pi*(0.250-.055), 0.05, 2*pi*(0.250+.055), p, 2, "#DAA520", 3.0, 6*(360/4/8)+0, "Transparent")
spirograph(60*1.5 , -15*1.5 , 12*1.5 , 2*pi*(0.500-.055), 0.05, 2*pi*(0.500+.055), p, 2, "#DAA520", 3.0, 6*(360/4/8)+0, "Transparent")
spirograph(60*1.5 , -15*1.5 , 12*1.5 , 2*pi*(0.750-.055), 0.05, 2*pi*(0.750+.055), p, 2, "#DAA520", 3.0, 6*(360/4/8)+0, "Transparent")
spirograph(60*1.5 , -15*1.5 , 12*1.5 , 2*pi*(0.000-.055), 0.05, 2*pi*(0.000+.055), p, 2, "#FFDD00", 3.0, 7*(360/4/8)+0, "Transparent")
spirograph(60*1.5 , -15*1.5 , 12*1.5 , 2*pi*(0.250-.055), 0.05, 2*pi*(0.250+.055), p, 2, "#FFDD00", 3.0, 7*(360/4/8)+0, "Transparent")
spirograph(60*1.5 , -15*1.5 , 12*1.5 , 2*pi*(0.500-.055), 0.05, 2*pi*(0.500+.055), p, 2, "#FFDD00", 3.0, 7*(360/4/8)+0, "Transparent")
spirograph(60*1.5 , -15*1.5 , 12*1.5 , 2*pi*(0.750-.055), 0.05, 2*pi*(0.750+.055), p, 2, "#FFDD00", 3.0, 7*(360/4/8)+0, "Transparent")
"showplot(p, 0, 1, 1)"
---------------------------------------------------------------------------------------------------------
"p = createplot()"
spirograph(60*1.25 , -15*1.25 , 12*1.25 , 2*pi*(0.000-.055), 0.05, 2*pi*(0.000+.055), p, 2, "#008800", 3.0, 0*(360/4/8)+0, "Transparent")
spirograph(60*1.25 , -15*1.25 , 12*1.25 , 2*pi*(0.250-.055), 0.05, 2*pi*(0.250+.055), p, 2, "#008800", 3.0, 0*(360/4/8)+0, "Transparent")
spirograph(60*1.25 , -15*1.25 , 12*1.25 , 2*pi*(0.500-.055), 0.05, 2*pi*(0.500+.055), p, 2, "#008800", 3.0, 0*(360/4/8)+0, "Transparent")
spirograph(60*1.25 , -15*1.25 , 12*1.25 , 2*pi*(0.750-.055), 0.05, 2*pi*(0.750+.055), p, 2, "#008800", 3.0, 0*(360/4/8)+0, "Transparent")
spirograph(60*1.25 , -15*1.25 , 12*1.25 , 2*pi*(0.000-.055), 0.05, 2*pi*(0.000+.055), p, 2, "#0000AA", 3.0, 1*(360/4/8)+0, "Transparent")
spirograph(60*1.25 , -15*1.25 , 12*1.25 , 2*pi*(0.250-.055), 0.05, 2*pi*(0.250+.055), p, 2, "#0000AA", 3.0, 1*(360/4/8)+0, "Transparent")
spirograph(60*1.25 , -15*1.25 , 12*1.25 , 2*pi*(0.500-.055), 0.05, 2*pi*(0.500+.055), p, 2, "#0000AA", 3.0, 1*(360/4/8)+0, "Transparent")
spirograph(60*1.25 , -15*1.25 , 12*1.25 , 2*pi*(0.750-.055), 0.05, 2*pi*(0.750+.055), p, 2, "#0000AA", 3.0, 1*(360/4/8)+0, "Transparent")
spirograph(60*1.25 , -15*1.25 , 12*1.25 , 2*pi*(0.000-.055), 0.05, 2*pi*(0.000+.055), p, 2, "#9933CC", 3.0, 2*(360/4/8)+0, "Transparent")
spirograph(60*1.25 , -15*1.25 , 12*1.25 , 2*pi*(0.250-.055), 0.05, 2*pi*(0.250+.055), p, 2, "#9933CC", 3.0, 2*(360/4/8)+0, "Transparent")
spirograph(60*1.25 , -15*1.25 , 12*1.25 , 2*pi*(0.500-.055), 0.05, 2*pi*(0.500+.055), p, 2, "#9933CC", 3.0, 2*(360/4/8)+0, "Transparent")
spirograph(60*1.25 , -15*1.25 , 12*1.25 , 2*pi*(0.750-.055), 0.05, 2*pi*(0.750+.055), p, 2, "#9933CC", 3.0, 2*(360/4/8)+0, "Transparent")
spirograph(60*1.25 , -15*1.25 , 12*1.25 , 2*pi*(0.000-.055), 0.05, 2*pi*(0.000+.055), p, 2, "#AA0000", 3.0, 3*(360/4/8)+0, "Transparent")
spirograph(60*1.25 , -15*1.25 , 12*1.25 , 2*pi*(0.250-.055), 0.05, 2*pi*(0.250+.055), p, 2, "#AA0000", 3.0, 3*(360/4/8)+0, "Transparent")
spirograph(60*1.25 , -15*1.25 , 12*1.25 , 2*pi*(0.500-.055), 0.05, 2*pi*(0.500+.055), p, 2, "#AA0000", 3.0, 3*(360/4/8)+0, "Transparent")
spirograph(60*1.25 , -15*1.25 , 12*1.25 , 2*pi*(0.750-.055), 0.05, 2*pi*(0.750+.055), p, 2, "#AA0000", 3.0, 3*(360/4/8)+0, "Transparent")
spirograph(60*1.25 , -15*1.25 , 12*1.25 , 2*pi*(0.000-.055), 0.05, 2*pi*(0.000+.055), p, 2, "#D2691E", 3.0, 4*(360/4/8)+0, "Transparent")
spirograph(60*1.25 , -15*1.25 , 12*1.25 , 2*pi*(0.250-.055), 0.05, 2*pi*(0.250+.055), p, 2, "#D2691E", 3.0, 4*(360/4/8)+0, "Transparent")
spirograph(60*1.25 , -15*1.25 , 12*1.25 , 2*pi*(0.500-.055), 0.05, 2*pi*(0.500+.055), p, 2, "#D2691E", 3.0, 4*(360/4/8)+0, "Transparent")
spirograph(60*1.25 , -15*1.25 , 12*1.25 , 2*pi*(0.750-.055), 0.05, 2*pi*(0.750+.055), p, 2, "#D2691E", 3.0, 4*(360/4/8)+0, "Transparent")
spirograph(60*1.25 , -15*1.25 , 12*1.25 , 2*pi*(0.000-.055), 0.05, 2*pi*(0.000+.055), p, 2, "#E9967A", 3.0, 5*(360/4/8)+0, "Transparent")
spirograph(60*1.25 , -15*1.25 , 12*1.25 , 2*pi*(0.250-.055), 0.05, 2*pi*(0.250+.055), p, 2, "#E9967A", 3.0, 5*(360/4/8)+0, "Transparent")
spirograph(60*1.25 , -15*1.25 , 12*1.25 , 2*pi*(0.500-.055), 0.05, 2*pi*(0.500+.055), p, 2, "#E9967A", 3.0, 5*(360/4/8)+0, "Transparent")
spirograph(60*1.25 , -15*1.25 , 12*1.25 , 2*pi*(0.750-.055), 0.05, 2*pi*(0.750+.055), p, 2, "#E9967A", 3.0, 5*(360/4/8)+0, "Transparent")
spirograph(60*1.25 , -15*1.25 , 12*1.25 , 2*pi*(0.000-.055), 0.05, 2*pi*(0.000+.055), p, 2, "#DAA520", 3.0, 6*(360/4/8)+0, "Transparent")
spirograph(60*1.25 , -15*1.25 , 12*1.25 , 2*pi*(0.250-.055), 0.05, 2*pi*(0.250+.055), p, 2, "#DAA520", 3.0, 6*(360/4/8)+0, "Transparent")
spirograph(60*1.25 , -15*1.25 , 12*1.25 , 2*pi*(0.500-.055), 0.05, 2*pi*(0.500+.055), p, 2, "#DAA520", 3.0, 6*(360/4/8)+0, "Transparent")
spirograph(60*1.25 , -15*1.25 , 12*1.25 , 2*pi*(0.750-.055), 0.05, 2*pi*(0.750+.055), p, 2, "#DAA520", 3.0, 6*(360/4/8)+0, "Transparent")
spirograph(60*1.25 , -15*1.25 , 12*1.25 , 2*pi*(0.000-.055), 0.05, 2*pi*(0.000+.055), p, 2, "#FFDD00", 3.0, 7*(360/4/8)+0, "Transparent")
spirograph(60*1.25 , -15*1.25 , 12*1.25 , 2*pi*(0.250-.055), 0.05, 2*pi*(0.250+.055), p, 2, "#FFDD00", 3.0, 7*(360/4/8)+0, "Transparent")
spirograph(60*1.25 , -15*1.25 , 12*1.25 , 2*pi*(0.500-.055), 0.05, 2*pi*(0.500+.055), p, 2, "#FFDD00", 3.0, 7*(360/4/8)+0, "Transparent")
spirograph(60*1.25 , -15*1.25 , 12*1.25 , 2*pi*(0.750-.055), 0.05, 2*pi*(0.750+.055), p, 2, "#FFDD00", 3.0, 7*(360/4/8)+0, "Transparent")
"showplot(p, 0, 1, 1)"
---------------------------------------------------------------------------------------------------------
and so on
另一种方法是用彩色绘制需要的部分,用白色或透明绘制不需要的部分。
spirograph(60*1.5 , -15*1.5 , 10*1.5 , 2*pi*(.250-.045) , 0.05, 2*pi*(.250+.045), p, 2, Green, 3.0, 0*360/4/8,"#FF7CFC00")
spirograph(60*1.5 , -15*1.5 , 10*1.5 , 2*pi*(.250+.045) , 0.05, 2*pi*(.500-.045), p, 2, Transparent, 3.0, 0*360/4/8,"Transparent")
spirograph(60*1.5 , -15*1.5 , 10*1.5 , 2*pi*(.500-.045) , 0.05, 2*pi*(.500+.045), p, 2, Blue, 3.0, 0*360/4/8,"#AA0000FF")
spirograph(60*1.5 , -15*1.5 , 10*1.5 , 2*pi*(.500+.045) , 0.05, 2*pi*(.750-.045), p, 2, Transparent, 3.0, 0*360/4/8,"Transparent")
spirograph(60*1.5 , -15*1.5 , 10*1.5 , 2*pi*(.750-.045) , 0.05, 2*pi*(.750+.045), p, 2, Red, 3.0, 0*360/4/8,"#AAFF0000")
spirograph(60*1.5 , -15*1.5 , 10*1.5 , 2*pi*(.750+.045) , 0.05, 2*pi*(1.000-.045), p, 2, Transparent, 3.0, 0*360/4/8,"Transparent")
spirograph(60*1.5 , -15*1.5 , 10*1.5 , 2*pi*(1.000-.045) , 0.05, 2*pi*(1.000+.045), p, 2, Violet, 3.0, 0*360/4/8,"#AAFF8C00")
spirograph(60*1.5 , -15*1.5 , 10*1.5 , 2*pi*(1.000+.045) , 0.05, 2*pi*(1.250-.045), p, 2, Transparent, 3.0, 0*360/4/8,"Transparent")
spirograph(60*1.5 , -15*1.5 , 10*1.5 , 2*pi*(.250-.045) , 0.05, 2*pi*(.250+.045), p, 2, Green, 3.0, 1*360/4/8,"#FF7CFC00")
pirograph(60*1.5 , -15*1.5 , 10*1.5 , 2*pi*(.250+.045) , 0.05, 2*pi*(.500-.045), p, 2, Transparent, 3.0, 1*360/4/8,"Transparent")
spirograph(60*1.5 , -15*1.5 , 10*1.5 , 2*pi*(.500-.045) , 0.05, 2*pi*(.500+.045), p, 2, Blue, 3.0, 1*360/4/8,"#AA0000FF")
spirograph(60*1.5 , -15*1.5 , 10*1.5 , 2*pi*(.500+.045) , 0.05, 2*pi*(.750-.045), p, 2, Transparent, 3.0, 1*360/4/8,"Transparent")
spirograph(60*1.5 , -15*1.5 , 10*1.5 , 2*pi*(.750-.045) , 0.05, 2*pi*(.750+.045), p, 2, Red, 3.0, 1*360/4/8,"#AAFF0000")
spirograph(60*1.5 , -15*1.5 , 10*1.5 , 2*pi*(.750+.045) , 0.05, 2*pi*(1.000-.045), p, 2, Transparent, 3.0, 1*360/4/8,"Transparent")
spirograph(60*1.5 , -15*1.5 , 10*1.5 , 2*pi*(1.000-.045) , 0.05, 2*pi*(1.000+.045), p, 2, Violet, 3.0, 1*360/4/8,"#AAFF8C00")
spirograph(60*1.5 , -15*1.5 , 10*1.5 , 2*pi*(1.000+.045) , 0.05, 2*pi*(1.250-.045), p, 2, Transparent, 3.0, 1*360/4/8,"Transparent")
spirograph(60*1.5 , -15*1.5 , 10*1.5 , 2*pi*(.250-.045) , 0.05, 2*pi*(.250+.045), p, 2, Green, 3.0, 2*360/4/8,"#FF7CFC00")
spirograph(60*1.5 , -15*1.5 , 10*1.5 , 2*pi*(.250+.045) , 0.05, 2*pi*(.500-.045), p, 2, Transparent, 3.0, 2*360/4/8,"Transparent")
spirograph(60*1.5 , -15*1.5 , 10*1.5 , 2*pi*(.500-.045) , 0.05, 2*pi*(.500+.045), p, 2, Blue, 3.0, 2*360/4/8,"#AA0000FF")
spirograph(60*1.5 , -15*1.5 , 10*1.5 , 2*pi*(.500+.045) , 0.05, 2*pi*(.750-.045), p, 2, Transparent, 3.0, 2*360/4/8,"Transparent")
spirograph(60*1.5 , -15*1.5 , 10*1.5 , 2*pi*(.750-.045) , 0.05, 2*pi*(.750+.045), p, 2, Red, 3.0, 2*360/4/8,"#AAFF0000")
spirograph(60*1.5 , -15*1.5 , 10*1.5 , 2*pi*(.750+.045) , 0.05, 2*pi*(1.000-.045), p, 2, Transparent, 3.0, 2*360/4/8,"Transparent")
spirograph(60*1.5 , -15*1.5 , 10*1.5 , 2*pi*(1.000-.045) , 0.05, 2*pi*(1.000+.045), p, 2, Violet, 3.0, 2*360/4/8,"#AAFF8C00")
spirograph(60*1.5 , -15*1.5 , 10*1.5 , 2*pi*(1.000+.045) , 0.05, 2*pi*(1.250-.045), p, 2, Transparent, 3.0, 2*360/4/8,"Transparent")
spirograph(60*1.5 , -15*1.5 , 10*1.5 , 2*pi*(.250-.045) , 0.05, 2*pi*(.250+.045), p, 2, Green, 3.0, 3*360/4/8,"#FF7CFC00")
spirograph(60*1.5 , -15*1.5 , 10*1.5 , 2*pi*(.250+.045) , 0.05, 2*pi*(.500-.045), p, 2, Transparent, 3.0, 3*360/4/8,"Transparent")
spirograph(60*1.5 , -15*1.5 , 10*1.5 , 2*pi*(.500-.045) , 0.05, 2*pi*(.500+.045), p, 2, Blue, 3.0, 3*360/4/8,"#AA0000FF")
spirograph(60*1.5 , -15*1.5 , 10*1.5 , 2*pi*(.500+.045) , 0.05, 2*pi*(.750-.045), p, 2, Transparent, 3.0, 3*360/4/8,"Transparent")
spirograph(60*1.5 , -15*1.5 , 10*1.5 , 2*pi*(.750-.045) , 0.05, 2*pi*(.750+.045), p, 2, Red, 3.0, 3*360/4/8,"#AAFF0000")
spirograph(60*1.5 , -15*1.5 , 10*1.5 , 2*pi*(.750+.045) , 0.05, 2*pi*(1.000-.045), p, 2, Transparent, 3.0, 3*360/4/8,"Transparent")
spirograph(60*1.5 , -15*1.5 , 10*1.5 , 2*pi*(1.000-.045) , 0.05, 2*pi*(1.000+.045), p, 2, Violet, 3.0, 3*360/4/8,"#AAFF8C00")
spirograph(60*1.5 , -15*1.5 , 10*1.5 , 2*pi*(1.000+.045) , 0.05, 2*pi*(1.250-.045), p, 2, Transparent, 3.0, 3*360/4/8,"Transparent")
spirograph(60*1.5 , -15*1.5 , 10*1.5 , 2*pi*(.250-.045) , 0.05, 2*pi*(.250+.045), p, 2, Green, 3.0, 4*360/4/8,"#FF7CFC00")
spirograph(60*1.5 , -15*1.5 , 10*1.5 , 2*pi*(.250+.045) , 0.05, 2*pi*(.500-.045), p, 2, Transparent, 3.0, 4*360/4/8,"Transparent")
spirograph(60*1.5 , -15*1.5 , 10*1.5 , 2*pi*(.500-.045) , 0.05, 2*pi*(.500+.045), p, 2, Blue, 3.0, 4*360/4/8,"#AA0000FF")
spirograph(60*1.5 , -15*1.5 , 10*1.5 , 2*pi*(.500+.045) , 0.05, 2*pi*(.750-.045), p, 2, Transparent, 3.0, 4*360/4/8,"Transparent")
spirograph(60*1.5 , -15*1.5 , 10*1.5 , 2*pi*(.750-.045) , 0.05, 2*pi*(.750+.045), p, 2, Red, 3.0, 4*360/4/8,"#AAFF0000")
spirograph(60*1.5 , -15*1.5 , 10*1.5 , 2*pi*(.750+.045) , 0.05, 2*pi*(1.000-.045), p, 2, Transparent, 3.0, 4*360/4/8,"Transparent")
spirograph(60*1.5 , -15*1.5 , 10*1.5 , 2*pi*(1.000-.045) , 0.05, 2*pi*(1.000+.045), p, 2, Violet, 3.0, 4*360/4/8,"#AAFF8C00")
spirograph(60*1.5 , -15*1.5 , 10*1.5 , 2*pi*(1.000+.045) , 0.05, 2*pi*(1.250-.045), p, 2, Transparent, 3.0, 4*360/4/8,"Transparent")
spirograph(60*1.5 , -15*1.5 , 10*1.5 , 2*pi*(.250-.045) , 0.05, 2*pi*(.250+.045), p, 2, Green, 3.0, 5*360/4/8,"#FF7CFC00")
spirograph(60*1.5 , -15*1.5 , 10*1.5 , 2*pi*(.250+.045) , 0.05, 2*pi*(.500-.045), p, 2, Transparent, 3.0, 5*360/4/8,"Transparent")
spirograph(60*1.5 , -15*1.5 , 10*1.5 , 2*pi*(.500-.045) , 0.05, 2*pi*(.500+.045), p, 2, Blue, 3.0, 5*360/4/8,"#AA0000FF")
spirograph(60*1.5 , -15*1.5 , 10*1.5 , 2*pi*(.500+.045) , 0.05, 2*pi*(.750-.045), p, 2, Transparent, 3.0, 5*360/4/8,"Transparent")
spirograph(60*1.5 , -15*1.5 , 10*1.5 , 2*pi*(.750-.045) , 0.05, 2*pi*(.750+.045), p, 2, Red, 3.0, 5*360/4/8,"#AAFF0000")
spirograph(60*1.5 , -15*1.5 , 10*1.5 , 2*pi*(.750+.045) , 0.05, 2*pi*(1.000-.045), p, 2, Transparent, 3.0, 5*360/4/8,"Transparent")
spirograph(60*1.5 , -15*1.5 , 10*1.5 , 2*pi*(1.000-.045) , 0.05, 2*pi*(1.000+.045), p, 2, Violet, 3.0, 5*360/4/8,"#AAFF8C00")
spirograph(60*1.5 , -15*1.5 , 10*1.5 , 2*pi*(1.000+.045) , 0.05, 2*pi*(1.250-.045), p, 2, Transparent, 3.0, 5*360/4/8,"Transparent")
spirograph(60*1.5 , -15*1.5 , 10*1.5 , 2*pi*(.250-.045) , 0.05, 2*pi*(.250+.045), p, 2, Green, 3.0, 6*360/4/8,"#FF7CFC00")
spirograph(60*1.5 , -15*1.5 , 10*1.5 , 2*pi*(.250+.045) , 0.05, 2*pi*(.500-.045), p, 2, Transparent, 3.0, 6*360/4/8,"Transparent")
spirograph(60*1.5 , -15*1.5 , 10*1.5 , 2*pi*(.500-.045) , 0.05, 2*pi*(.500+.045), p, 2, Blue, 3.0, 6*360/4/8,"#AA0000FF")
spirograph(60*1.5 , -15*1.5 , 10*1.5 , 2*pi*(.500+.045) , 0.05, 2*pi*(.750-.045), p, 2, Transparent, 3.0, 6*360/4/8,"Transparent")
spirograph(60*1.5 , -15*1.5 , 10*1.5 , 2*pi*(.750-.045) , 0.05, 2*pi*(.750+.045), p, 2, Red, 3.0, 6*360/4/8,"#AAFF0000")
spirograph(60*1.5 , -15*1.5 , 10*1.5 , 2*pi*(.750+.045) , 0.05, 2*pi*(1.000-.045), p, 2, Transparent, 3.0, 6*360/4/8,"Transparent")
spirograph(60*1.5 , -15*1.5 , 10*1.5 , 2*pi*(1.000-.045) , 0.05, 2*pi*(1.000+.045), p, 2, Violet, 3.0, 6*360/4/8,"#AAFF8C00")
spirograph(60*1.5 , -15*1.5 , 10*1.5 , 2*pi*(1.000+.045) , 0.05, 2*pi*(1.250-.045), p, 2, Transparent, 3.0, 6*360/4/8,"Transparent")
spirograph(60*1.5 , -15*1.5 , 10*1.5 , 2*pi*(.250-.045) , 0.05, 2*pi*(.250+.045), p, 2, Green, 3.0, 7*360/4/8,"#FF7CFC00")
spirograph(60*1.5 , -15*1.5 , 10*1.5 , 2*pi*(.250+.045) , 0.05, 2*pi*(.500-.045), p, 2, Transparent, 3.0, 7*360/4/8,"Transparent")
spirograph(60*1.5 , -15*1.5 , 10*1.5 , 2*pi*(.500-.045) , 0.05, 2*pi*(.500+.045), p, 2, Blue, 3.0, 7*360/4/8,"#AA0000FF")
spirograph(60*1.5 , -15*1.5 , 10*1.5 , 2*pi*(.500+.045) , 0.05, 2*pi*(.750-.045), p, 2, Transparent, 3.0, 7*360/4/8,"Transparent")
spirograph(60*1.5 , -15*1.5 , 10*1.5 , 2*pi*(.750-.045) , 0.05, 2*pi*(.750+.045), p, 2, Red, 3.0, 7*360/4/8,"#AAFF0000")
spirograph(60*1.5 , -15*1.5 , 10*1.5 , 2*pi*(.750+.045) , 0.05, 2*pi*(1.000-.045), p, 2, Transparent, 3.0, 7*360/4/8,"Transparent")
spirograph(60*1.5 , -15*1.5 , 10*1.5 , 2*pi*(1.000-.045) , 0.05, 2*pi*(1.000+.045), p, 2, Violet, 3.0, 7*360/4/8,"#AAFF8C00")
spirograph(60*1.5 , -15*1.5 , 10*1.5 , 2*pi*(1.000+.045) , 0.05, 2*pi*(1.250-.045), p, 2, Transparent, 3.0, 7*360/4/8,"Transparent")
showplot(p, 0, 1, 1)
答案1
dx
在旧版图片中添加一些功能(如域和)非常容易spiro
。我只关注您的两个屏幕截图以进行说明,但我认为您可以使用调整后的语法完成所有这些操作。如果我遗漏了什么,请告诉我。
\documentclass[tikz,border=3mm]{standalone}
\tikzset{pics/spiro2/.style={code={
\tikzset{spiro2/.cd,#1}
\def\pv##1{\pgfkeysvalueof{/tikz/spiro2/##1}}
\pgfmathparse{(int(1/\pv{dx}+1)}
\tikzset{spiro2/samples=\pgfmathresult}
\draw[trig format=rad,pic actions]
plot[variable=\t,domain=\pv{xmin}-0.002:\pv{xmax}+0.002,
samples=\pv{samples}]
({(\pv{R}+\pv{r})*cos(\t)+\pv{p}*cos((\pv{R}+\pv{r})*\t/\pv{r})},
{(\pv{R}+\pv{r})*sin(\t)+\pv{p}*sin((\pv{R}+\pv{r})*\t/\pv{r})});
}},
spiro2/.cd,R/.initial=6,r/.initial=-1.5,p/.initial=1,
dx/.initial=0.005,samples/.initial=21,domain/.code args={#1:#2}{%
\pgfmathparse{#1}\tikzset{spiro2/xmin/.expanded=\pgfmathresult}
\pgfmathparse{#2}\tikzset{spiro2/xmax/.expanded=\pgfmathresult}},
xmin/.initial=0,xmax/.initial=2*pi}
\begin{document}
\begin{tikzpicture}[]
\draw
(0,0) foreach \X [count=\Y starting from 0] in {blue,red,purple,orange}
{pic[scale=0.5,draw=\X,ultra
thick]{spiro2={domain={-pi/4+(\Y-1)*pi/2}:{-pi/4+\Y*pi/2}}}};
\draw(0,-7) foreach \X [count=\Y starting from 0] in {blue,red,purple,orange}
{foreach \Z in {0,...,5}
{pic[scale=0.5,draw=\X,ultra thick,fill=\X,fill
opacity=0.2,rotate=\Z*15]{spiro2={domain={-pi/4+(\Y-1)*pi/2}:{-pi/4+\Y*pi/2}}}}};
\end{tikzpicture}
\end{document}
请注意,旧版本使用了,smooth cycle
因此可以用相对较少的样本获得良好的结果。另一方面,在这里,我按照您的指示用直线连接绘图点,因此需要更多样本和更长的编译时间。请告诉我是否应该返回该smooth
案例以提高速度。这样做会产生
\documentclass[tikz,border=3mm]{standalone}
\tikzset{pics/spiro2/.style={code={
\tikzset{spiro2/.cd,#1}
\def\pv##1{\pgfkeysvalueof{/tikz/spiro2/##1}}
\pgfmathparse{(int(1/\pv{dx}+1)}
\tikzset{spiro2/samples=\pgfmathresult}
\draw[trig format=rad,pic actions]
plot[variable=\t,domain=\pv{xmin}-0.002:\pv{xmax}+0.002,
samples=\pv{samples},smooth]
({(\pv{R}+\pv{r})*cos(\t)+\pv{p}*cos((\pv{R}+\pv{r})*\t/\pv{r})},
{(\pv{R}+\pv{r})*sin(\t)+\pv{p}*sin((\pv{R}+\pv{r})*\t/\pv{r})});
}},
spiro2/.cd,R/.initial=6,r/.initial=-1.5,p/.initial=1,
dx/.initial=0.05,samples/.initial=21,domain/.code args={#1:#2}{%
\pgfmathparse{#1}\tikzset{spiro2/xmin/.expanded=\pgfmathresult}
\pgfmathparse{#2}\tikzset{spiro2/xmax/.expanded=\pgfmathresult}},
xmin/.initial=0,xmax/.initial=2*pi}
\begin{document}
\begin{tikzpicture}
\draw
(0,0) foreach \X [count=\Y starting from 0] in {blue,red,purple,orange}
{pic[scale=0.5,draw=\X,ultra
thick]{spiro2={domain={-pi/4+(\Y-1)*pi/2}:{-pi/4+\Y*pi/2}}}};
\draw(0,-7) foreach \X [count=\Y starting from 0] in {blue,red,purple,orange}
{foreach \Z in {0,...,5}
{pic[scale=0.5,draw=\X,ultra thick,fill=\X,fill
opacity=0.2,rotate=\Z*15]{spiro2={domain={-pi/4+(\Y-1)*pi/2}:{-pi/4+\Y*pi/2}}}}};
\end{tikzpicture}
\end{document}
对我来说,将其与路径衰落结合起来似乎很自然。
\documentclass[border=3mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{shadings,fadings}
\tikzset{pics/spiro2/.style={code={
\tikzset{spiro2/.cd,#1}
\def\pv##1{\pgfkeysvalueof{/tikz/spiro2/##1}}
\pgfmathparse{(int(1/\pv{dx}+1)}
\tikzset{spiro2/samples=\pgfmathresult}
\draw[trig format=rad,pic actions]
plot[variable=\t,domain=\pv{xmin}-0.002:\pv{xmax}+0.002,
samples=\pv{samples},smooth]
({(\pv{R}+\pv{r})*cos(\t)+\pv{p}*cos((\pv{R}+\pv{r})*\t/\pv{r})},
{(\pv{R}+\pv{r})*sin(\t)+\pv{p}*sin((\pv{R}+\pv{r})*\t/\pv{r})});
}},
spiro2/.cd,R/.initial=6,r/.initial=-1.5,p/.initial=1,
dx/.initial=0.05,samples/.initial=21,domain/.code args={#1:#2}{%
\pgfmathparse{#1}\tikzset{spiro2/xmin/.expanded=\pgfmathresult}
\pgfmathparse{#2}\tikzset{spiro2/xmax/.expanded=\pgfmathresult}},
xmin/.initial=0,xmax/.initial=2*pi}
\begin{document}
\begin{tikzfadingfrompicture}[name=spiro]
\draw foreach \Y in {0,...,3}
{foreach \Z in {0,...,5}
{pic[scale=0.5,fill=transparent!60,
draw=transparent!20,
rotate=\Z*15]{spiro2={domain={-pi/4+(\Y-1)*pi/2}:{-pi/2+pi/9+\Y*pi/2}}}}};
\end{tikzfadingfrompicture}
\begin{tikzpicture}
\shade[shading=color wheel,
path fading=spiro,fit fading=false] (0,0) circle [radius=4cm];
\end{tikzpicture}
\end{document}
附录:这些是要求的图表。我在代码中添加了一些解释。要很好地解释某件事,需要了解其他用户遇到的困难。我没有这方面的知识。如果你问具体的问题,我会尽力回答。
\documentclass[tikz,border=3mm]{standalone}
% The following just sets up a plot where you can contol the parameters via pgf
% keys. The central object is the plot.
\tikzset{pics/spiro2/.style={code={
\tikzset{spiro2/.cd,#1}
\def\pv##1{\pgfkeysvalueof{/tikz/spiro2/##1}}
\pgfmathparse{(int(1/\pv{dx}+1)}
\tikzset{spiro2/samples=\pgfmathresult}
\draw[trig format=rad,pic actions]
plot[variable=\t,domain=\pv{xmin}-0.002:\pv{xmax}+0.002,
samples=\pv{samples},smooth]
({(\pv{R}+\pv{r})*cos(\t)+\pv{p}*cos((\pv{R}+\pv{r})*\t/\pv{r})},
{(\pv{R}+\pv{r})*sin(\t)+\pv{p}*sin((\pv{R}+\pv{r})*\t/\pv{r})});
}},
spiro2/.cd,R/.initial=6,r/.initial=-1.5,p/.initial=1,
dx/.initial=0.08,samples/.initial=21,domain/.code args={#1:#2}{%
\pgfmathparse{#1}\tikzset{spiro2/xmin/.expanded=\pgfmathresult}
\pgfmathparse{#2}\tikzset{spiro2/xmax/.expanded=\pgfmathresult}},
xmin/.initial=0,xmax/.initial=2*pi}
\begin{document}
\begin{tikzpicture}
\path (0,0)
pic[scale=0.5,draw=yellow,ultra thick]{spiro2={dx=0.03}}
foreach \X [count=\Y starting from 0] in {blue,red,purple,orange}
{pic[scale=0.5,draw=\X,ultra
thick]{spiro2={domain={-pi/12+\Y*pi/2}:{pi/12+\Y*pi/2}}}};
% This is a loop orgy. We loop over scale factors, overall rotations and colors.
\path[line cap=round] (7,0)
foreach \ScaleN
[evaluate=\ScaleN as \Scale using {pow(0.85,\ScaleN)/0.8}] % compute sale factor
in {1,...,5} %loop over scale
{foreach \Z in {0,...,3} %loop over 4 overall rotations
{foreach \X [count=\Y starting from 0] in
{yellow,orange,red,blue,purple,cyan,magenta,green!70!black} % colors
{pic[scale=0.5,draw=\X,rotate=\Y*90/8+\Z*90,
scale=\Scale,line width=\Scale*2pt]
{spiro2={domain={-pi/11.4}:{pi/11.4}}}}}};
\end{tikzpicture}
\end{document}