diff options
author | Karl Berry <karl@freefriends.org> | 2020-03-05 00:48:46 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2020-03-05 00:48:46 +0000 |
commit | f210bce174e1f2f05305ab03e88e120a1cbfc4da (patch) | |
tree | 5c4e2ad096b5c745e859516ac3196fa0864292d5 /Master/texmf-dist/tex/context/base/mkiv/mlib-lmt.lua | |
parent | 35fd641a3546acc0c62e0aa7f134888e36da30d4 (diff) |
context (from cont-tmf.zip of Feb 17 16:00, size 116339406)
git-svn-id: svn://tug.org/texlive/trunk@54086 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/context/base/mkiv/mlib-lmt.lua')
-rw-r--r-- | Master/texmf-dist/tex/context/base/mkiv/mlib-lmt.lua | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/context/base/mkiv/mlib-lmt.lua b/Master/texmf-dist/tex/context/base/mkiv/mlib-lmt.lua new file mode 100644 index 00000000000..9137861a58e --- /dev/null +++ b/Master/texmf-dist/tex/context/base/mkiv/mlib-lmt.lua @@ -0,0 +1,63 @@ +if not modules then modules = { } end modules ['mlib-lmt'] = { + version = 1.001, + comment = "companion to mlib-ctx.mkiv", + author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", + copyright = "PRAGMA ADE / ConTeXt Development Team", + license = "see context related readme files", +} + +local mppath = mp.path + +local scannumeric = mp.scan.numeric +local scanpath = mp.scan.path + +local getparameter = metapost.getparameter + +function mp.lmt_function_x(xmin,xmax,xstep,code,shape) -- experimental + local code = "return function(x) return " .. code .. " end" + local action = load(code) + local points = { } + local nofpoints = 0 + if action then + action = action() + end + if shape == "steps" then + local halfx = xstep / 2 + local lastx = xmin + local lasty = action(xmin) + for xi = xmin, xmax, xstep do + local yi = action(xi) + local xx = lastx + halfx + nofpoints = nofpoints + 1 ; points[nofpoints] = { xx, lasty } + nofpoints = nofpoints + 1 ; points[nofpoints] = { xx, yi } + lastx = xi + lasty = yi + end + if points[nofpoints][1] ~= xmax then + local yi = action(xmax) + local xx = lastx + halfx + nofpoints = nofpoints + 1 ; points[nofpoints] = { xx, lasty } + nofpoints = nofpoints + 1 ; points[nofpoints] = { xx, yi } + lastx = xi + lasty = yi + end + else + for xi = xmin, xmax, xstep do + nofpoints = nofpoints + 1 ; points[nofpoints] = { xi, action(xi) } + end + if points[nofpoints][1] ~= xmax then + nofpoints = nofpoints + 1 ; points[nofpoints] = { xmax, action(xmax) } + end + end + mppath(points,shape == "curve" and ".." or "--",false) +end + +function mp.lmt_mesh_set() + local mesh = getparameter { "mesh", "paths" } + structures.references.currentset.mesh = mesh +end + +function mp.lmt_mesh_update() + local mesh = getparameter { "paths" } or getparameter { "mesh", "paths" } + mesh[scannumeric()] = scanpath(true) +end |