/bd{bind def}bind def
/1-{1 sub}bd
/1+{1 add}bd
/right{90 rotate}bd
/left{-90 rotate}bd
/forward{0 1 rlineto}bd
/pageSetup{
0.05 setlinewidth 2 setlinecap 2 setmiterlimit 0 setgray
3600 127 div dup scale % cm
15 7 translate % tweak this to keep the curve on the page
}bd
/dragonSetup{
newpath
0 0 moveto
}bd
% the curve turns 90 degrees left or right at each point.
% per wikipedia, you can obtain the direction of the turn
% by finding the bit above the lowest one-bit of the current
% iteration. this formula is due to hackers delight, probably.
/turn{dup dup 1- xor 1+ and 0 eq {left}{right}ifelse}bd
/dragon{-1 1 {turn forward} for}bd
pageSetup
dragonSetup
125 dragon
stroke
showpage
cc @jernej__s