diff options
| author | Lua Team <team@lua.org> | 1995-11-28 12:00:00 +0000 |
|---|---|---|
| committer | repogen <> | 1995-11-28 12:00:00 +0000 |
| commit | 71754d2f6423fb9b6e87658e58bafc5470d53f65 (patch) | |
| tree | c704e97b80e52a52d3152738941bb4c8ca676b97 /test/examples/ps/hilbert.lua | |
| parent | a8b6ba0954edb9e0e669e1f451b9a8f145ce5166 (diff) | |
| download | lua-github-2.2.tar.gz | |
Lua 2.22.2
Diffstat (limited to 'test/examples/ps/hilbert.lua')
| -rw-r--r-- | test/examples/ps/hilbert.lua | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/test/examples/ps/hilbert.lua b/test/examples/ps/hilbert.lua new file mode 100644 index 00000000..b1042b57 --- /dev/null +++ b/test/examples/ps/hilbert.lua @@ -0,0 +1,44 @@ +-- hilbert.c +-- Hilbert curve +-- Luiz Henrique de Figueiredo (lhf@csg.uwaterloo.ca) +-- 10 Nov 95 + +$debug + +dofile("ps.lua") + +function p() + PS.lineto(x,y) +end + +function a(n) + if (n==0) then return else n=n-1 end + d(n); y=y+h; p(); a(n); x=x+h; p(); a(n); y=y-h; p(); b(n); +end + +function b(n) + if (n==0) then return else n=n-1 end + c(n); x=x-h; p(); b(n); y=y-h; p(); b(n); x=x+h; p(); a(n); +end + +function c(n) + if (n==0) then return else n=n-1 end + b(n); y=y-h; p(); c(n); x=x-h; p(); c(n); y=y+h; p(); d(n); +end + +function d(n) + if (n==0) then return else n=n-1 end + a(n); x=x+h; p(); d(n); y=y+h; p(); d(n); x=x-h; p(); c(n); +end + +function hilbert(n) + PS.open("hilbert curve") + h=2^(9-n) + x=0 + y=0 + PS.moveto(x,y) + a(n) + PS.close() +end + +hilbert(5) |
