代码如下:
1 import settings; 2 settings.tex = "pdflatex"; 3 pdfviewer="/usr/bin/okular"; 4 outformat="pdf"; 5 texpreamble("\usepackage{CJKutf8}\AtBeginDocument{\begin{CJK}{UTF8}{gbsn}}\AtEndDocument{\clearpage\end{CJK}}"); 6 size(5cm,0); 7 pair z=(0.5,0); 8 guide leave1=(0,0){dir(15)}..(1,0); 9 guide leave2=(1,0){dir(-165)}..(0,0);10 guide leave3=leave1 & leave2&cycle;11 12 13 for (int a=0;a<10;++a)14 {15 for (int b=0;b<5;++b)16 {17 draw(shift(a,b)*rotate(18(a+b),z)*leave3,heavygreen+0.2mm);18 fill(shift(a,b)*rotate(18(a+b),z)*leave3,green);19 draw(shift(a,b)*rotate(18(a+b),z)*leave2,lightgreen+0.2mm);20 }21 22 }
编译后产生的图像效果如下: