summaryrefslogtreecommitdiff
path: root/tex/context/base/mkiv/mlib-lua.lmt
diff options
context:
space:
mode:
Diffstat (limited to 'tex/context/base/mkiv/mlib-lua.lmt')
-rw-r--r--tex/context/base/mkiv/mlib-lua.lmt49
1 files changed, 48 insertions, 1 deletions
diff --git a/tex/context/base/mkiv/mlib-lua.lmt b/tex/context/base/mkiv/mlib-lua.lmt
index ed65b9401..30fc2ff63 100644
--- a/tex/context/base/mkiv/mlib-lua.lmt
+++ b/tex/context/base/mkiv/mlib-lua.lmt
@@ -45,6 +45,12 @@ scan.transform = function(t) return scan_transform (currentmpx,t) end
scan.path = function(t) return scan_path (currentmpx,t) end
scan.pen = function(t) return scan_pen (currentmpx,t) end
+local solve_path = mplib.solve_path
+
+mp.solve = function(...)
+ return solve_path(currentmpx,...)
+end
+
local inject_path = mplib.inject_path
local inject_numeric = mplib.inject_numeric
local inject_pair = mplib.inject_pair
@@ -56,7 +62,7 @@ local inject_cmykcolor = mplib.inject_cmykcolor
local inject_transform = mplib.inject_transform
local inject_whatever = mplib.inject_whatever
-inject.path = function(t,cycle,curled) return inject_path (currentmpx,t,cycle,curled) end
+------.path = function(t,cycle,curled) return inject_path (currentmpx,t,cycle,curled) end
inject.numeric = function(n) return inject_numeric (currentmpx,n) end
inject.pair = function(x,y) return inject_pair (currentmpx,x,y) end
inject.boolean = function(b) return inject_boolean (currentmpx,b) end
@@ -67,6 +73,47 @@ inject.cmykcolor = function(c,m,y,k) return inject_cmykcolor(currentmpx,
inject.transform = function(x,y,xx,xy,yx,yy) return inject_transform(currentmpx,x,y,xx,xy,yx,yy) end
inject.whatever = function(...) return inject_whatever (currentmpx,...) end
+local function same(p,n)
+ local f = p[1]
+ local l = p[n]
+ local nf = #f
+ local nl = #l
+ if nf == nl then
+ for i=1,nf do
+ if f[i] ~= l[i] then
+ return false
+ end
+ end
+ return true
+ end
+ return false
+end
+
+-- local p = mp.scan.path()
+-- mp.inject.path(p,true,true)
+
+function inject.path(p,close,connector)
+ local curled = false
+ local n = #p
+ if p.close then
+ close = true
+ end
+ if n > 1 then
+ -- [ ../true | --/false | nil/auto ]
+ if connector == nil or connector == "auto" then
+ connector = #p[1] > 2
+ end
+ if connector == false or connector == "--" then
+ curled = true
+ elseif connector == true or connector == ".." then
+ if close and not same(p,n) then
+ p[n+1] = p[1]
+ end
+ end
+ end
+ return inject_path(currentmpx,p,curled,close)
+end
+
-- bonus:
scan .number = scan .numeric