diff options
author | Context Git Mirror Bot <phg42.2a@gmail.com> | 2016-05-17 10:29:20 +0200 |
---|---|---|
committer | Context Git Mirror Bot <phg42.2a@gmail.com> | 2016-05-17 10:29:20 +0200 |
commit | af172a8db5f7583d0117635edde17eba5619d883 (patch) | |
tree | 50688f3516ce1a3e3d19922666d80101d473f124 /tex/context/base/mkiv/grph-rul.lua | |
parent | b344014638169aad6e5f6d2a9a703cb03a8b5064 (diff) | |
download | context-af172a8db5f7583d0117635edde17eba5619d883.tar.gz |
2016-05-17 10:11:00
Diffstat (limited to 'tex/context/base/mkiv/grph-rul.lua')
-rw-r--r-- | tex/context/base/mkiv/grph-rul.lua | 43 |
1 files changed, 27 insertions, 16 deletions
diff --git a/tex/context/base/mkiv/grph-rul.lua b/tex/context/base/mkiv/grph-rul.lua index e6b10cce6..9222af319 100644 --- a/tex/context/base/mkiv/grph-rul.lua +++ b/tex/context/base/mkiv/grph-rul.lua @@ -29,6 +29,7 @@ local report_mp = logs.reporter("rules","mp") local floor = math.floor local random = math.random +local formatters = string.formatters do @@ -36,6 +37,7 @@ do local cachesize = 0 local maxcachesize = 256*1024 local cachethreshold = 1024 + local caching = false -- otherwise random issues so we need a dedicated randomizer first -- local maxcachesize = 8*1024 -- local cachethreshold = 1024/2 @@ -66,6 +68,7 @@ do FakeWord(%width%,%height%,%depth%,%line%,%color%); ]], ["fake:rule"] = replacer[[ +%initializations% FakeRule(%width%,%height%,%depth%,%line%,%color%); ]], ["fake:rest"] = replacer [[ @@ -82,26 +85,34 @@ def RuleColor = %color% enddef ; ]] } + local initialized = false ; + ruleactions.mp = function(p,h,v,i,n) local name = p.name or "fake:rest" local code = (predefined[name] or predefined["fake:rest"]) { - data = p.data or "", - width = p.width * bpfactor, - height = p.height * bpfactor, - depth = p.depth * bpfactor, - factor = (p.factor or 0) * bpfactor, -- needs checking - offset = p.offset or 0, - line = (p.line or 65536) * bpfactor, - color = mpcolor(p.ma,p.ca,p.ta), - option = p.option or "", - direction = p.direction or "TLT", + data = p.data or "", + width = p.width * bpfactor, + height = p.height * bpfactor, + depth = p.depth * bpfactor, + factor = (p.factor or 0) * bpfactor, -- needs checking + offset = p.offset or 0, + line = (p.line or 65536) * bpfactor, + color = mpcolor(p.ma,p.ca,p.ta), + option = p.option or "", + direction = p.direction or "TLT", + } - local m = cache[code] + if not initialized then + initialized = true + simplemetapost("rulefun",formatters["randomseed := %s;"](random(0,4095))) + end + local pdf = caching and cache[code] or simplemetapost("rulefun",code) -- w, h, d if trace_mp then - report_mp(m) + report_mp("code: %s",code) + report_mp("pdf : %s",pdf) end - if m and m ~= "" then - pdfprint("direct",m) + if pdf and pdf ~= "" then + pdfprint("direct",pdf) end end @@ -109,8 +120,8 @@ end do - local f_rectangle = string.formatters["%F w %F %F %F %F re %s"] - local f_radtangle = string.formatters[ [[ + local f_rectangle = formatters["%F w %F %F %F %F re %s"] + local f_radtangle = formatters[ [[ %F w %F %F m %F %F l %F %F %F %F y %F %F l %F %F %F %F y |