diff options
Diffstat (limited to 'tex/context/base/mkiv/grph-rul.lua')
-rw-r--r-- | tex/context/base/mkiv/grph-rul.lua | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/tex/context/base/mkiv/grph-rul.lua b/tex/context/base/mkiv/grph-rul.lua index f3d0bb95c..d5a7577d2 100644 --- a/tex/context/base/mkiv/grph-rul.lua +++ b/tex/context/base/mkiv/grph-rul.lua @@ -15,6 +15,9 @@ local userrule = nodes.rules.userrule local bpfactor = number.dimenfactors.bp local pdfprint = pdf.print +local currentattr = nodes.current_attr +local setfield = nodes.setfield + local getattribute = tex.getattribute local a_color = attributes.private('color') @@ -28,7 +31,7 @@ local trace_mp = false trackers.register("rules.mp", function(v) trace_mp local report_mp = logs.reporter("rules","mp") local floor = math.floor -local random = math.random +local getrandom = utilities.randomizer.get local formatters = string.formatters do @@ -108,7 +111,7 @@ def RuleColor = %color% enddef ; } if not initialized then initialized = true - simplemetapost("rulefun",formatters["randomseed := %s;"](random(0,4095))) + simplemetapost("rulefun",formatters["randomseed := %s;"](getrandom("rulefun",0,4095))) end local pdf = caching and cache[code] or simplemetapost("rulefun",code) -- w, h, d if trace_mp then @@ -172,20 +175,21 @@ interfaces.implement { { "name", "string" }, } } , actions = function(t) - local r = userrule(t) + local rule = userrule(t) local ma = getattribute(a_colormodel) or 1 local ca = getattribute(a_color) local ta = getattribute(a_transparency) + setfield(rule,"attr",currentattr()) if t.type == "mp" then t.ma = ma t.ca = ca t.ta = ta else - r[a_colormodel] = ma - r[a_color] = ca - r[a_transparency] = ta + rule[a_colormodel] = ma + rule[a_color] = ca + rule[a_transparency] = ta end - context(r) + context(rule) end } @@ -200,10 +204,11 @@ interfaces.implement { } } , actions = function(t) local factor = t.factor or 0 + local amount = getrandom("fakeword",t.min,t.max) local rule = userrule { height = 1.25*factor, depth = 0.25*factor, - width = floor(random(t.min,t.max)/10000) * 10000, + width = floor(amount/10000) * 10000, line = 0.10*factor, ma = getattribute(a_colormodel) or 1, ca = getattribute(a_color), @@ -211,6 +216,7 @@ interfaces.implement { type = "mp", name = t.name, } + setfield(rule,"attr",currentattr()) context(rule) end } |