请考虑以下示例:
代码
% xelatex filename.tex
\documentclass{article}
\usepackage{pst-poly,pstricks-add}
\usepackage[locale=DE]{siunitx}
\ExplSyntaxOn
\cs_new_eq:NN \calc \fp_eval:n
\ExplSyntaxOff
\begin{document}
\def\radius{5 }
\def\factorA{\calc{(1/10*(5+5^(1/2)))^(1/2)*\radius}}
\def\factorB{\calc{1/2*(3+5^(1/2))}}
\def\factorC{\calc{\factorA*\factorB}}
%\def\firstcoor{\calc{5/4*(5^(1/2)-1)*\factorB}}
%\def\secondcoor{\calc{1/4*(10*(5+5^(1/2)))^(1/2)*\factorB}}
\def\dist{\calc{(1/10*(5-5^(1/2)))^(1/2)*\factorB*\radius}}
\def\firstcoorA{\calc{\dist*cos(3/10*pi)}}
\def\secondcoorA{\calc{\dist*sin(3/10*pi)}}
\def\firstcoorB{\calc{\dist*cos(7/10*pi)}}
\def\secondcoorB{\calc{\dist*sin(7/10*pi)}}
\def\firstcoorC{\calc{\dist*cos(11/10*pi)}}
\def\secondcoorC{\calc{\dist*sin(11/10*pi)}}
\def\firstcoorD{\calc{\dist*cos(15/10*pi)}}
\def\secondcoorD{\calc{\dist*sin(15/10*pi)}}
\def\firstcoorE{\calc{\dist*cos(19/10*pi)}}
\def\secondcoorE{\calc{\dist*sin(19/10*pi)}}
\psset{unit=0.5}
\begin{pspicture}(-10.7,-11.2)(10.7,9)
{\psset{%
linewidth=2\pslinewidth,%
linecolor=green!90!yellow!70!blue!70,%
fillstyle=solid,%
fillcolor=green!60!yellow!80!blue!80%
}
\rput(0,0){\PstPentagon[unit=\factorA]}
\rput{ 36}(\firstcoorA,\secondcoorA){\PstPentagon[unit=\factorA]}
\rput{ 36}(\firstcoorB,\secondcoorB){\PstPentagon[unit=\factorA]}
\rput{ 36}(\firstcoorC,\secondcoorC){\PstPentagon[unit=\factorA]}
\rput{180}(\firstcoorD,\secondcoorD){\PstPentagon[unit=\factorA]}
\rput{ 36}(\firstcoorE,\secondcoorE){\PstPentagon[unit=\factorA]}
}
\rput{180}(0,0){\PstPentagon[unit=\factorC,linewidth=2\pslinewidth]}
\rput(!0.8 \radius mul neg 0.26 \radius mul neg){\num{\radius}}
\end{pspicture}
\end{document}
输出
问题
如何使用\multido
命令在中心五边形周围绘制五个绿色五边形?
答案1
\documentclass{article}
\usepackage{pst-poly}
\begin{document}
\def\Radius{2 } \def\myCoor{}
\begin{pspicture}[showgrid](-5,-5)(5,5)
\psset{linewidth=2\pslinewidth,%
linecolor=green!90!yellow!70!blue!70,%
fillstyle=solid,fillcolor=green!60!yellow!80!blue!80}
\rput(0,0){\PstPentagon[unit=\Radius]}
\pstVerb{/R1 \Radius 36 cos mul dup add def /R2 R1 \Radius add def }
\multido{\iA=-90+72}{5}{%
\xdef\myCoor{\myCoor(!R2 \iA\space PtoC)} %
\rput{36}(! R1 \iA\space PtoC){\PstPentagon[unit=\Radius]}}
\psset{linecolor=black,linewidth=1.5pt,fillstyle=none}
\expandafter\pspolygon\myCoor
\end{pspicture}
\end{document}