diff options
author | Hans Hagen <pragma@wxs.nl> | 2020-07-14 00:25:53 +0200 |
---|---|---|
committer | Context Git Mirror Bot <phg@phi-gamma.net> | 2020-07-14 00:25:53 +0200 |
commit | f1129626606384a7a55a21a83531f51f8b5dee25 (patch) | |
tree | 9bfaf9a8bf2c218007291023f771babc9ac2e1d9 /tex/context/base/mkiv/mlib-lmp.lmt | |
parent | b821116421f0d942052ad225f4ea62aef2696817 (diff) | |
download | context-f1129626606384a7a55a21a83531f51f8b5dee25.tar.gz |
2020-07-13 23:52:00
Diffstat (limited to 'tex/context/base/mkiv/mlib-lmp.lmt')
-rw-r--r-- | tex/context/base/mkiv/mlib-lmp.lmt | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/tex/context/base/mkiv/mlib-lmp.lmt b/tex/context/base/mkiv/mlib-lmp.lmt new file mode 100644 index 000000000..ff9682e87 --- /dev/null +++ b/tex/context/base/mkiv/mlib-lmp.lmt @@ -0,0 +1,70 @@ +if not modules then modules = { } end modules ['mlib-lmp'] = { + 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", +} + +-- path relates stuff ... todo: use a stack (or numeric index to list) + +local type = type + +local aux = mp.aux +local mpnumeric = aux.numeric +local mppair = aux.pair + +local p = nil +local n = 0 + +local function mf_path_reset() + p = nil + n = 0 +end + +local scan = mp.scan +local scannumber = scan.number +local scanpath = scan.path + +local function mf_path_length() + p = scanpath() + n = p and #p or 1 + mpnumeric(n) +end + +local function mf_path_point() + local i = scannumber() + if i > 0 and i <= n then + local pi = p[i] + mppair(pi[1],pi[2]) + end +end + +local function mf_path_left() + local i = scannumber() + if i > 0 and i <= n then + local pi = p[i] + mppair(pi[5],pi[6]) + end +end + +local function mf_path_right() + local i = scannumber() + if i > 0 and i <= n then + local pn + if i == 1 then + pn = p[2] or p[1] + else + pn = p[i+1] or p[1] + end + mppair(pn[3],pn[4]) + end +end + +local registerscript = metapost.registerscript + +registerscript("pathreset", mf_path_reset) +registerscript("pathlengthof", mf_path_length) +registerscript("pathpointof", mf_path_point) +registerscript("pathleftof", mf_path_left) +registerscript("pathrightof", mf_path_right) |