PostScript Program for a Dragon Curve

(download)

%!PS

/N 7 def

/X {
  dup 0 ne
  {1 sub 4 {dup} repeat - F X + + F Y -}
  if pop
} def

/Y {
  dup 0 ne
  {1 sub 4 {dup} repeat + F X - - F Y +}
  if pop
} def

/F {
  0 eq { 10 0 rlineto } if 
} bind def

/- { -45 rotate } bind def

/+ { 45 rotate } bind def

1 setlinejoin
1 setlinecap

newpath
220 180 moveto
50 N { 2 sqrt div } repeat dup scale
90 rotate
N X
stroke

showpage