diff options
author | Hans Hagen <pragma@wxs.nl> | 2017-01-17 18:05:46 +0100 |
---|---|---|
committer | Context Git Mirror Bot <phg42.2a@gmail.com> | 2017-01-17 18:05:46 +0100 |
commit | 0cfeab235554eeee0dddd6c3f44d3939ab490ff1 (patch) | |
tree | fed70e9a3332741e5294a01197c716dff8556506 /tex/context/base/mkiv/grph-rul.lua | |
parent | 72d161c0a522fd92f32edd3588fa126c453f4a3d (diff) | |
download | context-0cfeab235554eeee0dddd6c3f44d3939ab490ff1.tar.gz |
2017-01-17 17:43:00
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 } |