summaryrefslogtreecommitdiff
path: root/metapost
diff options
context:
space:
mode:
authorHans Hagen <pragma@wxs.nl>2022-04-11 20:12:40 +0200
committerContext Git Mirror Bot <phg@phi-gamma.net>2022-04-11 20:12:40 +0200
commit1e69816bbbeebedafd52684fc4182ce977d92a8a (patch)
tree06d7cfe0c8490e66eb8f6447bd6f9c50afb8d90e /metapost
parentc1224cc330e695938cfcf944f8e9d0c14c15fa8c (diff)
downloadcontext-1e69816bbbeebedafd52684fc4182ce977d92a8a.tar.gz
2022-04-11 19:22:00
Diffstat (limited to 'metapost')
-rw-r--r--metapost/context/base/mpxl/mp-lmtx.mpxl14
-rw-r--r--metapost/context/base/mpxl/mp-luas.mpxl12
-rw-r--r--metapost/context/base/mpxl/mp-tool.mpxl31
3 files changed, 54 insertions, 3 deletions
diff --git a/metapost/context/base/mpxl/mp-lmtx.mpxl b/metapost/context/base/mpxl/mp-lmtx.mpxl
index 9adacb9d9..f8ee2032a 100644
--- a/metapost/context/base/mpxl/mp-lmtx.mpxl
+++ b/metapost/context/base/mpxl/mp-lmtx.mpxl
@@ -602,6 +602,7 @@ presetparameters "function" [
yarrow = "",
reverse = false,
% function : metatable is parent
+ axis = "both",
] ;
def lmt_function = applyparameters "function" "lmt_do_function" enddef ;
@@ -640,8 +641,8 @@ vardef lmt_do_function =
pickup pencircle xyscaled(lw/sx,lw/sy) ;
draw image (
save xmin, xmax, xstep, xsmall, xlarge, ymin, ymax, ystep, ysmall, ylarge, p ;
- save code, option, txl, txs, tyl, tys, swap ;
- string code, option, shape ;
+ save code, option, txl, txs, tyl, tys, swap, axis ;
+ string code, option, shape, axis ;
path txl, txs, tyl, tys ; boolean swap, close ;
picture p ;
@@ -659,6 +660,7 @@ vardef lmt_do_function =
swap := getparameter "reverse" ;
shape := getparameter "shape" ;
close := getparameter "close" ;
+axis := getparameter "axis" ;
p := image (
if (getparametercount "functions") > 0 :
for s = 1 upto getparametercount "functions" :
@@ -700,6 +702,12 @@ vardef lmt_do_function =
if not swap : draw p fi ;
+if (axis = "") or (axis = "no") :
+ % nothing
+else :
+
+ % todo: x y both
+
option := getparameter "xticks" ;
if option = "top" :
txs := (0,0) -- (0,tl) ;
@@ -887,6 +895,8 @@ vardef lmt_do_function =
shifted (xmin-tl,0)
shifted center leftboundary currentpicture ;
fi ;
+
+fi ;
)
xyscaled(sx,sy) ;
diff --git a/metapost/context/base/mpxl/mp-luas.mpxl b/metapost/context/base/mpxl/mp-luas.mpxl
index f10c3507a..cc760f93e 100644
--- a/metapost/context/base/mpxl/mp-luas.mpxl
+++ b/metapost/context/base/mpxl/mp-luas.mpxl
@@ -231,6 +231,14 @@ let dppart = bluepart ;
permanent wdpart, htpart, dppart;
+newscriptindex mfid_sortedpath ; mfid_sortedpath := scriptindex "sortedpath" ;
+newscriptindex mfid_uniquepath ; mfid_uniquepath := scriptindex "uniquepath" ;
+
+def sortedpath = runscript mfid_sortedpath enddef ;
+def uniquepath = runscript mfid_uniquepath enddef ;
+
+permanent sortpath, uniquepath ;
+
newscriptindex mfid_texvar ; mfid_texvar := scriptindex "texvar" ; vardef texvar(expr s) = runscript mfid_texvar s enddef ;
newscriptindex mfid_texstr ; mfid_texstr := scriptindex "texstr" ; vardef texstr(expr s) = runscript mfid_texstr s enddef ;
@@ -313,6 +321,7 @@ permanent getparameters, presetparameters, hasparameter, hasoption, getparameter
newscriptindex mfun_newrecord ; mfun_newrecord := scriptindex "newrecord" ;
newscriptindex mfun_setrecord ; mfun_setrecord := scriptindex "setrecord" ;
newscriptindex mfun_getrecord ; mfun_getrecord := scriptindex "getrecord" ;
+newscriptindex mfun_cntrecord ; mfun_cntrecord := scriptindex "cntrecord" ;
% let record = runscript ; % We need to use "let" because we don't expand!
@@ -321,9 +330,10 @@ def record = newinternal numeric runscript enddef ;
def newrecord = runscript mfun_newrecord ; enddef ; % semicolon prevents lookahead
def setrecord = runscript mfun_setrecord ; enddef ;
def getrecord = runscript mfun_getrecord enddef ;
+def cntrecord = runscript mfun_cntrecord enddef ;
permanent
- record, newrecord, setrecord, getrecord ;
+ record, newrecord, setrecord, getrecord, cntrecord ;
% No vardef's because we need to scan for an assignment too and we'll see
% an endgroup otherwise.
diff --git a/metapost/context/base/mpxl/mp-tool.mpxl b/metapost/context/base/mpxl/mp-tool.mpxl
index 28d1bbf3e..d99439c5b 100644
--- a/metapost/context/base/mpxl/mp-tool.mpxl
+++ b/metapost/context/base/mpxl/mp-tool.mpxl
@@ -3946,3 +3946,34 @@ primarydef p withdashes len =
enddef ;
permanent withdashes ;
+
+%D For Mikael:
+
+path mfun_b ;
+pair mfun_k ;
+
+tertiarydef p intersectionpath q =
+ begingroup ;
+ save mfun_b ; path mfun_b ; mfun_b := sortedpath (p intersectiontimeslist q) ;
+ save mfun_k ; pair mfun_k ; mfun_k := point 0 of mfun_b;
+ .5[point xpart mfun_k of p, point ypart mfun_k of q]
+ for i = 1 upto length(mfun_b) :
+ hide(mfun_k := point i of mfun_b;)
+ -- .5[point xpart mfun_k of p, point ypart mfun_k of q]
+ endfor
+ endgroup
+enddef ;
+
+tertiarydef p firstintersectionpath q =
+ begingroup ;
+ save mfun_b ; path mfun_b ; mfun_b := sortedpath (p intersectiontimeslist q) ;
+ point xpart (point 0 of mfun_b) of p
+ for i = 1 upto length(mfun_b) :
+ -- point xpart (point i of mfun_b) of p
+ endfor
+ endgroup
+enddef ;
+
+tertiarydef p secondintersectionpath q =
+ q firstintersectionpath p
+enddef;