我在看下面这个很好的文档.
看完了第一部分,我自己试着画了个赵爽弦图.代码如下:
1 import settings; 2 settings.tex = "pdflatex"; 3 pdfviewer="/usr/bin/okular"; 4 outformat="pdf"; 5 size(400); 6 texpreamble("\usepackage{CJKutf8}\AtBeginDocument{\begin{CJK}{UTF8}{gbsn}}\AtEndDocument{\clearpage\end{CJK}}"); 7 import math; 8 add( scale(1cm) * grid(7, 7, heavygray) ); 9 add( shift(0,3cm) * rotate(-aTan(3/4)) * scale(1cm) * grid(5, 5, heavygray) ); 10 fill( box((3cm,3cm), (4cm,4cm)), opacity(0.3)+yellow ); 11 filldraw((4cm,0)-- (4cm,3cm) -- (0,3cm) -- cycle,fillpen=opacity(0.1)+red, drawpen=red+0.5mm); 12 filldraw((7cm,4cm)-- (4cm,4cm) -- (4cm,0) -- cycle,fillpen=opacity(0.1)+red, drawpen=red+0.5mm); 13 filldraw((3cm,7cm) -- (3cm,4cm) -- (7cm,4cm) -- cycle,fillpen=opacity(0.1)+red, drawpen=red+0.5mm ); 14 filldraw((0,3cm) -- (3cm,3cm) -- (3cm,7cm) -- cycle,fillpen=opacity(0.1)+red, drawpen=red+0.5mm ); 15 label("朱实", (2cm,4cm),red); 16 label("黄实", (3.5cm,3.5cm),yellow); 17 label("弦实", (5cm,4cm),orange); 18 label( Label("勾三",Rotate(S)), (4cm,0)--(4cm,3cm), LeftSide ); 19 label( Label("股四",Rotate(E)), (4cm,3cm)--(0,3cm), LeftSide ); 20 label( Label("弦五",Rotate((4,-3))), (0,3cm)--(4cm,0), LeftSide );
在终端里先用asy命令启动Asymptote,然后将如上代码复制到终端里运行,编译得到如下图像: