move(s) = sprintf(" rto %f,%f", s*cos(th), -s*sin(th)) right(x) = sprintf("", th = th - x) left(x) = sprintf("", th = th + x) hilbert(n, angl) = (0 < n) ? right(angl).\ hilbert(n-1, -angl).move(s).left(angl).\ hilbert(n-1, angl).move(s).\ hilbert(n-1, angl).left(angl).move(s).\ hilbert(n-1, -angl).right(angl): "" N = 7 # order s = 1 # global parameter th = 0 # global variable L = 2**N set xr [0:L] set yr [-1:L] unset key unset border unset tics set lmargin 0 set rmargin 0 set tmargin 0 set bmargin 0 set size square path = hilbert(N, pi/2) path = sprintf("set object polygon from 0,0").path path = path.sprintf("to -10000,10000 lw 1") eval path set term pngc enh font ",10" size L*4,L*4 set out "hilbert.png" plot -10 !display "hilbert.png" |