hilbert.lua

来自「lua解释器早期3.0版本」· LUA 代码 · 共 45 行

LUA
45
字号
-- hilbert.c-- Hilbert curve-- Luiz Henrique de Figueiredo (lhf@csg.uwaterloo.ca)-- 10 Nov 95$debugdofile("ps.lua")function p() PS.lineto(x,y)endfunction 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);endfunction 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);endfunction 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);endfunction 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);endfunction hilbert(n) PS.open("hilbert curve") h=2^(9-n) x=0 y=0 PS.moveto(x,y) a(n) PS.close()endhilbert(5)

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?