本帖最后由 LiYanrui 于 2009-11-24 08:49 编辑
Hans 制作了一份讲述如何直接用 lua 来写“文档”的文档,可从 http://www.pragma-ade.com/general/manuals/cld-mkiv.pdf 下载。lua 粉丝或许会喜欢这样来写文档 :-)
比方说下面这份 test.lua “程序”源码:- local todimen = number.todimen
- context.startTEXpage()
- local paperwidth = tex.dimen.paperwidth
- local paperheight = tex.dimen.paperheight
- local nofsteps = 25
- local firstcolor = "darkblue"
- local secondcolor = "white"
- context.definelayer(
- { "titlepage" }
- )
- context.setuplayer(
- { "titlepage" },
- {
- width = todimen(paperwidth),
- height = todimen(paperheight),
- }
- )
- context.setlayerframed(
- { "titlepage" },
- { offset = "-5pt" },
- {
- width = todimen(paperwidth),
- height = todimen(paperheight),
- background = "color",
- backgroundcolor = firstcolor,
- backgroundoffset = "10pt",
- frame = "off",
- },
- ""
- )
- for i=1, nofsteps do
- for j=1, nofsteps do
- context.setlayerframed(
- { "titlepage" },
- {
- x = todimen((i-1) * paperwidth /nofsteps),
- y = todimen((j-1) * paperheight/nofsteps),
- rotation = math.random(360),
- },
- {
- frame = "off",
- background = "color",
- backgroundcolor = secondcolor,
- foregroundcolor = firstcolor,
- foregroundstyle = "type",
- },
- "CLD"
- )
- end
- end
- context.tightlayer(
- { "titlepage" }
- )
- context.stopTEXpage()
- return true
复制代码 用命令:来编译,就得到下面这个图案的 pdf 文件了。
 |