PostScript でフラクタル

PostScript TUTORIAL and COOKBOOKの72ページ。72 Chapter 7: LOOPS AND CONDITIONALS に再帰フラクタルを描くサンプルがあります。パラメータを変えると図形も変ります。

/depth 0 def

/maxdepth 15 def
/down {/depth depth 1 add def} def
/up {/depth depth 1 sub def } def

/DoLine { 0 144 rlineto currentpoint  stroke translate 0 0 moveto} def

/FractArrow
  { gsave .7 .7 scale 
    10 setlinewidth 
    down DoLine
    depth maxdepth le { 45 rotate FractArrow -90 rotate FractArrow} if
    up grestore } def

300 400 moveto
FractArrow
stroke
showpage