summaryrefslogtreecommitdiff
path: root/metapost
diff options
context:
space:
mode:
authorHans Hagen <pragma@wxs.nl>2020-12-27 17:39:33 +0100
committerContext Git Mirror Bot <phg@phi-gamma.net>2020-12-27 17:39:33 +0100
commit4a099fb402241bb64a08a0167b458bed09ec8a3e (patch)
treea06162bbffed3cb308f29e0176b0975a578213d7 /metapost
parent34bc3e479e76b06633436a744a30719f4d7f20f7 (diff)
downloadcontext-4a099fb402241bb64a08a0167b458bed09ec8a3e.tar.gz
2020-12-27 16:37:00
Diffstat (limited to 'metapost')
-rw-r--r--metapost/context/base/mpxl/metafun.mpxl4
-rw-r--r--metapost/context/base/mpxl/minifun.mpxl4
-rw-r--r--metapost/context/base/mpxl/mp-abck.mpxl4
-rw-r--r--metapost/context/base/mpxl/mp-apos.mpxl4
-rw-r--r--metapost/context/base/mpxl/mp-base.mpxl12
-rw-r--r--metapost/context/base/mpxl/mp-blob.mpxl4
-rw-r--r--metapost/context/base/mpxl/mp-butt.mpxl4
-rw-r--r--metapost/context/base/mpxl/mp-cont.mpxl4
-rw-r--r--metapost/context/base/mpxl/mp-figs.mpxl4
-rw-r--r--metapost/context/base/mpxl/mp-form.mpxl4
-rw-r--r--metapost/context/base/mpxl/mp-func.mpxl4
-rw-r--r--metapost/context/base/mpxl/mp-grid.mpxl27
-rw-r--r--metapost/context/base/mpxl/mp-grph.mpxl4
-rw-r--r--metapost/context/base/mpxl/mp-lmtx.mpxl4
-rw-r--r--metapost/context/base/mpxl/mp-luas.mpxl4
-rw-r--r--metapost/context/base/mpxl/mp-math.mpxl4
-rw-r--r--metapost/context/base/mpxl/mp-mlib.mpxl10
-rw-r--r--metapost/context/base/mpxl/mp-node.mpxl4
-rw-r--r--metapost/context/base/mpxl/mp-page.mpxl4
-rw-r--r--metapost/context/base/mpxl/mp-shap.mpxl4
-rw-r--r--metapost/context/base/mpxl/mp-tool.mpxl179
21 files changed, 145 insertions, 151 deletions
diff --git a/metapost/context/base/mpxl/metafun.mpxl b/metapost/context/base/mpxl/metafun.mpxl
index 2c21110de..6f817e948 100644
--- a/metapost/context/base/mpxl/metafun.mpxl
+++ b/metapost/context/base/mpxl/metafun.mpxl
@@ -25,7 +25,7 @@ def mutable = setproperty -3 : enddef; % not yet used
permanent permanent, immutable, mutable, primitive, frozen ; % we reserve frozen
-boolean contextlmtxmode ; contextlmtxmode := true ; immutable contextlmtxmode ;
+newinternal boolean contextlmtxmode ; contextlmtxmode := true ; immutable contextlmtxmode ;
% But it will move here:
@@ -49,7 +49,7 @@ input "mp-abck.mpxl" ;
input "mp-blob.mpxl" ;
input "mp-lmtx.mpxl" ;
-string metafunversion ; metafunversion = "metafun xl " & mfun_timestamp;
+newinternal string metafunversion ; metafunversion := "metafun xl " & mfun_timestamp;
immutable metafunversion ;
diff --git a/metapost/context/base/mpxl/minifun.mpxl b/metapost/context/base/mpxl/minifun.mpxl
index 8da5f1d37..e1b1cda36 100644
--- a/metapost/context/base/mpxl/minifun.mpxl
+++ b/metapost/context/base/mpxl/minifun.mpxl
@@ -22,7 +22,7 @@ def mutable = setproperty -3 : enddef; % not yet used
permanent permanent, immutable, mutable, primitive, frozen ; % we reserve frozen
-boolean contextlmtxmode ; contextlmtxmode := true ; immutable contextlmtxmode ;
+newinternal boolean contextlmtxmode ; contextlmtxmode := true ; immutable contextlmtxmode ;
input "mp-base.mpiv" ;
input "mp-tool.mpxl" ;
@@ -32,7 +32,7 @@ input "mp-math.mpxl" ;
input "mp-cont.mpxl" ;
input "mp-page.mpxl" ;
-string minifunversion ; minifunversion = "minifun xl " & mfun_timestamp;
+newinternal string minifunversion ; minifunversion := "minifun xl " & mfun_timestamp;
let normalend = end ;
diff --git a/metapost/context/base/mpxl/mp-abck.mpxl b/metapost/context/base/mpxl/mp-abck.mpxl
index 650a76ebb..c27758fa9 100644
--- a/metapost/context/base/mpxl/mp-abck.mpxl
+++ b/metapost/context/base/mpxl/mp-abck.mpxl
@@ -11,9 +11,9 @@
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
-if known context_abck : endinput ; fi ;
+if known metafun_loaded_abck : endinput ; fi ;
-boolean context_abck ; context_abck := true ; immutable context_abck ;
+newinternal boolean metafun_loaded_abck ; metafun_loaded_abck := true ; immutable metafun_loaded_abck ;
path multiregs[], % region used for multipar (tracing only)
multipars[], % effective area (shape)
diff --git a/metapost/context/base/mpxl/mp-apos.mpxl b/metapost/context/base/mpxl/mp-apos.mpxl
index f9c8b28dc..878577bd9 100644
--- a/metapost/context/base/mpxl/mp-apos.mpxl
+++ b/metapost/context/base/mpxl/mp-apos.mpxl
@@ -11,9 +11,9 @@
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
-if known context_apos : endinput ; fi ;
+if known metafun_loaded_apos : endinput ; fi ;
-boolean context_apos ; context_apos := true ; immutable context_apos ;
+newinternal boolean metafun_loaded_apos ; metafun_loaded_apos := true ; immutable metafun_loaded_apos ;
path posboxes[],
posregions[] ;
diff --git a/metapost/context/base/mpxl/mp-base.mpxl b/metapost/context/base/mpxl/mp-base.mpxl
index a111c7337..430e75a62 100644
--- a/metapost/context/base/mpxl/mp-base.mpxl
+++ b/metapost/context/base/mpxl/mp-base.mpxl
@@ -10,12 +10,11 @@
% remove some code as well). After all, there is no development in
% this format.
-string base_name, base_version ;
+message "loading metafun for lmtx, including the plain 1.004 base definitions";
-base_name := "plain" ;
-base_version := "1.004 for metafun iv and xl" ;
+if known metafun_loaded_base : endinput ; fi ;
-message "loading metafun, including plain.mp version " & base_version ;
+newinternal boolean metafun_loaded_base ; metafun_loaded_base := true ; immutable metafun_loaded_base ;
delimiters () ; % this makes parentheses behave like parentheses
@@ -57,7 +56,8 @@ enddef ;
% \\ and ??? can go
-permanent $, $$, (, ), upto, downto, exitunless, relax, \\, [[, ]], --, ---, ..., gobble, gobbled, stop, ?, ??? ;
+permanent $, $$, (, ), upto, downto, exitunless, relax, \\, [[, ]], --, ---, ..., gobble, gobbled, stop, ??? ;
+mutable ? ;
% These need to be adapted to a library approach:
@@ -475,7 +475,7 @@ tertiarydef p softjoin q =
endgroup
enddef ;
-permanent direction, directionpoint, softjoin ;
+permanent direction, directionpoint, intersectionpoint, softjoin ;
newinternal join_radius ;
path cuttings ; % what got cut off
diff --git a/metapost/context/base/mpxl/mp-blob.mpxl b/metapost/context/base/mpxl/mp-blob.mpxl
index 9dffc3e80..c6b0843b5 100644
--- a/metapost/context/base/mpxl/mp-blob.mpxl
+++ b/metapost/context/base/mpxl/mp-blob.mpxl
@@ -13,9 +13,9 @@
%D This is a follow up on good old \type {meta-imp-txt}.
-if known context_blob : endinput ; fi ;
+if known metafun_loaded_blob : endinput ; fi ;
-boolean context_blob ; context_blob := true ; immutable context_blob ;
+newinternal boolean metafun_loaded_blob ; metafun_loaded_blob := true ; immutable metafun_loaded_blob ;
numeric mfun_blob_n ; mfun_blob_n := 0 ;
picture mfun_blob_c ;
diff --git a/metapost/context/base/mpxl/mp-butt.mpxl b/metapost/context/base/mpxl/mp-butt.mpxl
index 7900c6037..4db36c1c9 100644
--- a/metapost/context/base/mpxl/mp-butt.mpxl
+++ b/metapost/context/base/mpxl/mp-butt.mpxl
@@ -11,9 +11,9 @@
%C therefore copyrighted by \PRAGMA. See licen-en.pdf for
%C details.
-if known context_butt : endinput ; fi ;
+if known metafun_loaded_butt : endinput ; fi ;
-boolean context_butt ; context_butt := true ; immutable context_butt ;
+newinternal boolean metafun_loaded_butt ; metafun_loaded_butt := true ; immutable metafun_loaded_butt ;
def predefinedbutton (expr button_type, button_size, button_linecolor, button_fillcolor) =
diff --git a/metapost/context/base/mpxl/mp-cont.mpxl b/metapost/context/base/mpxl/mp-cont.mpxl
index c65d27412..d153a9ccb 100644
--- a/metapost/context/base/mpxl/mp-cont.mpxl
+++ b/metapost/context/base/mpxl/mp-cont.mpxl
@@ -13,9 +13,9 @@
%D This module is rather preliminary and subjected to changes.
-if known context_cont : endinput ; fi ;
+if known metafun_loaded_cont : endinput ; fi ;
-boolean context_cont ; context_cont := true ; immutable context_cont ;
+newinternal boolean metafun_loaded_cont ; metafun_loaded_cont := true ; immutable metafun_loaded_cont ;
string CurrentLayout ; CurrentLayout := "default" ;
diff --git a/metapost/context/base/mpxl/mp-figs.mpxl b/metapost/context/base/mpxl/mp-figs.mpxl
index b077056cb..1a99c138a 100644
--- a/metapost/context/base/mpxl/mp-figs.mpxl
+++ b/metapost/context/base/mpxl/mp-figs.mpxl
@@ -11,9 +11,9 @@
%C therefore copyrighted by \PRAGMA. See licen-en.pdf for
%C details.
-if known context_figs : endinput ; fi ;
+if known metafun_loaded_figs : endinput ; fi ;
-boolean context_figs ; context_figs := true ; immutable context_figs ;
+newinternal boolean metafun_loaded_figs ; metafun_loaded_figs := true ; immutable metafun_loaded_figs ;
% todo: check defined
diff --git a/metapost/context/base/mpxl/mp-form.mpxl b/metapost/context/base/mpxl/mp-form.mpxl
index fcd0c1137..9bc02616d 100644
--- a/metapost/context/base/mpxl/mp-form.mpxl
+++ b/metapost/context/base/mpxl/mp-form.mpxl
@@ -14,9 +14,9 @@
% The graph package will be replaced by our own variant using
% MetaPost 2 features and textext.
-if known context_form : endinput ; fi ;
+if known metafun_loaded_form : endinput ; fi ;
-boolean context_form ; context_form := true ; immutable context_form ;
+newinternal boolean metafun_loaded_form ; metafun_loaded_form := true ; immutable metafun_loaded_form ;
% The following function accept a number or string that can be
% converted to a number by \LUA. The first argument is a format
diff --git a/metapost/context/base/mpxl/mp-func.mpxl b/metapost/context/base/mpxl/mp-func.mpxl
index 859e6ead3..8f3e8ba20 100644
--- a/metapost/context/base/mpxl/mp-func.mpxl
+++ b/metapost/context/base/mpxl/mp-func.mpxl
@@ -13,9 +13,9 @@
%D Under construction.
-if known context_func : endinput ; fi ;
+if known metafun_loaded_func : endinput ; fi ;
-boolean context_func ; context_func := true ; immutable context_func ;
+newinternal boolean metafun_loaded_func ; metafun_loaded_func := true ; immutable metafun_loaded_func ;
string mfun_pathconnectors[] ;
diff --git a/metapost/context/base/mpxl/mp-grid.mpxl b/metapost/context/base/mpxl/mp-grid.mpxl
index 466d82555..95bb03786 100644
--- a/metapost/context/base/mpxl/mp-grid.mpxl
+++ b/metapost/context/base/mpxl/mp-grid.mpxl
@@ -13,9 +13,9 @@
%D Under construction.
-if known context_grid : endinput ; fi ;
+if known metafun_loaded_grid : endinput ; fi ;
-boolean context_grid ; context_grid := true ; immutable context_grid ;
+newinternal boolean metafun_loaded_grid ; metafun_loaded_grid := true ; immutable metafun_loaded_grid ;
string fmt_separator ; fmt_separator := "@" ;
numeric fmt_precision ; fmt_precision := 3 ;
@@ -111,6 +111,8 @@ vardef vlinlabel@#(expr asked_min, asked_max, asked_step, asked_length) text t =
)
enddef ;
+% these will be replace by lmt_* variants
+
vardef linlog(expr xy) = ( xpart xy, log(ypart xy)) enddef ;
vardef loglin(expr xy) = (log(xpart xy), ypart xy) enddef ;
vardef loglog(expr xy) = (log(xpart xy), log(ypart xy)) enddef ;
@@ -121,22 +123,5 @@ vardef linlogpath primary p = processpath (p) (linlog) enddef ;
vardef loglogpath primary p = processpath (p) (loglog) enddef ;
vardef linlinpath primary p = processpath (p) (linlin) enddef ;
-vardef processpath (expr p) (text pp) =
- if path p :
- for i=0 upto length(p)-1 :
- pp(point i of p) .. controls
- pp(postcontrol i of p) and
- pp(precontrol (i+1) of p) ..
- endfor
- if cycle p :
- cycle
- else :
- pp(point length(p) of p)
- fi
- elseif pair p :
- pp(p)
- else :
- p
- fi
-enddef ;
-
+permanent hlingrid, vlingrid, hloggrid, vloggrid, hlintext, vlintext, hlogtext, vlogtext, hlinlabel, vlinlabel ;
+permanent linlog, loglin, loglog, linlin, loglinpath, linlogpath, loglogpath, linlinpath ;
diff --git a/metapost/context/base/mpxl/mp-grph.mpxl b/metapost/context/base/mpxl/mp-grph.mpxl
index bfe8304fd..4826e4540 100644
--- a/metapost/context/base/mpxl/mp-grph.mpxl
+++ b/metapost/context/base/mpxl/mp-grph.mpxl
@@ -13,9 +13,9 @@
%D Under construction.
-if known context_grph : endinput ; fi ;
+if known metafun_loaded_grph : endinput ; fi ;
-boolean context_grph ; context_grph := true ; immutable context_grph ;
+newinternal boolean metafun_loaded_grph ; metafun_loaded_grph := true ; immutable metafun_loaded_grph ;
numeric mfun_fig_nesting ; mfun_fig_nesting := 0 ;
diff --git a/metapost/context/base/mpxl/mp-lmtx.mpxl b/metapost/context/base/mpxl/mp-lmtx.mpxl
index f1bdf4fd5..28fdb1417 100644
--- a/metapost/context/base/mpxl/mp-lmtx.mpxl
+++ b/metapost/context/base/mpxl/mp-lmtx.mpxl
@@ -14,9 +14,9 @@
% This is an experimental module where I test some new interface methods;
% for real advanced graphics use the luapost module.
-if known context_lmtx : endinput ; fi ;
+if known metafun_loaded_lmtx : endinput ; fi ;
-boolean context_lmtx ; context_lmtx := true ; immutable context_lmtx ;
+newinternal boolean metafun_loaded_lmtx ; metafun_loaded_lmtx := true ; immutable metafun_loaded_lmtx ;
presetparameters "text" [
offset = 0,
diff --git a/metapost/context/base/mpxl/mp-luas.mpxl b/metapost/context/base/mpxl/mp-luas.mpxl
index d652140c4..c13db4d59 100644
--- a/metapost/context/base/mpxl/mp-luas.mpxl
+++ b/metapost/context/base/mpxl/mp-luas.mpxl
@@ -11,7 +11,7 @@
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
-if known context_luas : endinput ; fi ;
+if known metafun_loaded_luas : endinput ; fi ;
% When I prototyped the runscript primitive I was just thinking of a usage like
% the original \directlua primitive in luatex: genererate something and pipe
@@ -22,7 +22,7 @@ if known context_luas : endinput ; fi ;
% other metafun modules too. Of course in retrospect I should have done this five
% years earlier.
-boolean context_luas ; context_luas := true ; immutable context_luas ;
+newinternal boolean metafun_loaded_luas ; metafun_loaded_luas := true ; immutable metafun_loaded_luas ;
def newscriptindex suffix t = newinternal t ; immutable t ; enddef ;
diff --git a/metapost/context/base/mpxl/mp-math.mpxl b/metapost/context/base/mpxl/mp-math.mpxl
index aabd4c658..c2723b0f6 100644
--- a/metapost/context/base/mpxl/mp-math.mpxl
+++ b/metapost/context/base/mpxl/mp-math.mpxl
@@ -11,9 +11,9 @@
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
-if known context_math : endinput ; fi ;
+if known metafun_loaded_math : endinput ; fi ;
-boolean context_math ; context_math := true ; immutable context_math ;
+newinternal boolean metafun_loaded_math ; metafun_loaded_math := true ; immutable metafun_loaded_math ;
% draw textext(decimal runscript("mp.numeric(xmath.gamma(.12))")) ;
diff --git a/metapost/context/base/mpxl/mp-mlib.mpxl b/metapost/context/base/mpxl/mp-mlib.mpxl
index dc5bad4d7..4e4db3b44 100644
--- a/metapost/context/base/mpxl/mp-mlib.mpxl
+++ b/metapost/context/base/mpxl/mp-mlib.mpxl
@@ -11,9 +11,9 @@
%C therefore copyrighted by \PRAGMA. See licen-en.pdf for
%C details.
-if known context_mlib : endinput ; fi ;
+if known metafun_loaded_mlib : endinput ; fi ;
-boolean context_mlib ; context_mlib := true ; immutable context_mlib ;
+newinternal boolean metafun_loaded_mlib ; metafun_loaded_mlib := true ; immutable metafun_loaded_mlib ;
% numeric LUATEXFUNCTIONALITY ; LUATEXFUNCTIONALITY := runscript("mp.print(LUATEXFUNCTIONALITY or (status and status.development_id) or 6346)") ;
@@ -212,6 +212,8 @@ def notcached =
withprescript "tx_cache=no"
enddef ;
+permanent keepcached, notcached ;
+
% todo: onetime
rgbcolor mfun_tt_r ;
@@ -402,6 +404,8 @@ vardef installlabel@# (expr type, x, y, offset) =
numeric mfun_labyf @# ; mfun_labyf @# := y ;
enddef ;
+permanent installlabel ;
+
installlabel.center (0, 0.5, 0.5, (0,0)) ;
installlabel.c (0, 0.5, 0.5, (0,0)) ;
@@ -609,6 +613,7 @@ primarydef s infont name = % nasty hack
enddef ;
permanent theoffset, thelabel, anchored ;
+primitive infont ; % fake primitive
% Helper
@@ -1755,6 +1760,7 @@ def eofill text t = fill t withpostscript "evenodd" enddef ;
def nofill text t = fill t withpostscript "collect" enddef ;
def nodraw text t = draw t withpostscript "collect" enddef ;
def dodraw text t = draw t withpostscript "flush" enddef ;
+% eodraw text t = draw t withpostscript "evenodd" enddef ;
def dofill text t = fill t withpostscript "flush" enddef ;
def eoclip text t = clip t withpostscript "evenodd" enddef ;
diff --git a/metapost/context/base/mpxl/mp-node.mpxl b/metapost/context/base/mpxl/mp-node.mpxl
index ce3f888b5..7d6b9dd05 100644
--- a/metapost/context/base/mpxl/mp-node.mpxl
+++ b/metapost/context/base/mpxl/mp-node.mpxl
@@ -14,9 +14,9 @@
%D The crossing macros were written as part of this module but as they
%D can be of use elsewhere they are defined in mp-tool.
-if known context_node : endinput ; fi ;
+if known metafun_loaded_node : endinput ; fi ;
-boolean context_node ; context_node := true ; immutable context_node ;
+newinternal boolean metafun_loaded_node ; metafun_loaded_node := true ; immutable metafun_loaded_node ;
% Build a path from the node positions.
% Must be integer and continuous in index starting at 0.
diff --git a/metapost/context/base/mpxl/mp-page.mpxl b/metapost/context/base/mpxl/mp-page.mpxl
index bb9d8e893..72831e927 100644
--- a/metapost/context/base/mpxl/mp-page.mpxl
+++ b/metapost/context/base/mpxl/mp-page.mpxl
@@ -14,9 +14,9 @@
%D This module is rather preliminary and subjected to changes.In the process of
%D moving to \METAFUN2\ this might change.
-if known context_page : endinput ; fi ;
+if known metafun_loaded_page : endinput ; fi ;
-boolean context_page ; context_page := true ; immutable context_page ;
+newinternal boolean metafun_loaded_page ; metafun_loaded_page := true ; immutable metafun_loaded_page ;
def LoadPageState = enddef ; % just in case some old style uses it
diff --git a/metapost/context/base/mpxl/mp-shap.mpxl b/metapost/context/base/mpxl/mp-shap.mpxl
index c4e2a7bf0..e43b81280 100644
--- a/metapost/context/base/mpxl/mp-shap.mpxl
+++ b/metapost/context/base/mpxl/mp-shap.mpxl
@@ -11,9 +11,9 @@
%C therefore copyrighted by \PRAGMA. See licen-en.pdf for
%C details.
-if known context_shap : endinput ; fi ;
+if known metafun_loaded_shap : endinput ; fi ;
-boolean context_shap ; context_shap := true ; immutable context_shap ;
+newinternal boolean metafun_loaded_shap ; metafun_loaded_shap := true ; immutable metafun_loaded_shap ;
path predefined_shapes[] ;
diff --git a/metapost/context/base/mpxl/mp-tool.mpxl b/metapost/context/base/mpxl/mp-tool.mpxl
index 44cad274d..6aca09d7e 100644
--- a/metapost/context/base/mpxl/mp-tool.mpxl
+++ b/metapost/context/base/mpxl/mp-tool.mpxl
@@ -11,9 +11,9 @@
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
-if known context_tool : endinput ; fi ;
+if known metafun_loaded_tool : endinput ; fi ;
-boolean context_tool ; context_tool := true ; immutable context_tool ;
+newinternal boolean metafun_loaded_tool ; metafun_loaded_tool := true ; immutable metafun_loaded_tool ;
let @## = @# ;
@@ -243,15 +243,8 @@ permanent decimal, ddecimal, dddecimal, ddddecimal, colordecimals, colordecimals
% endfor
% enddef ;
-%D We have standardized data file names:
-
-def job_name =
- jobname
-enddef ;
-
-%D Because \METAPOST\ has a hard coded limit of 4~datafiles,
-%D we need some trickery when we have multiple files. This will
-%D be redone (via \LUA).
+%D Because \METAPOST\ has a hard coded limit of 4~datafiles, we need some trickery
+%D when we have multiple files. This will be redone (via \LUA).
boolean savingdata ; savingdata := false ;
boolean savingdatadone ; savingdatadone := false ;
@@ -272,9 +265,8 @@ def finishsavingdata =
lua.mp.mf_finish_saving_data() ;
enddef ;
-%D Instead of a keystroke eating save and allocation
-%D sequence, you can use the \citeer {new} alternatives to
-%D save and allocate in one command.
+%D Instead of a keystroke eating save and allocation sequence, you can use the \quote
+%D {new} alternatives to save and allocate in one command.
%D These might go away!
@@ -287,10 +279,9 @@ enddef ;
% def newstring text v = forsuffixes i=v : save i ; string i ; endfor ; enddef ;
% def newpair text v = forsuffixes i=v : save i ; pair i ; endfor ; enddef ;
-%D Sometimes we don't want parts of the graphics add to the
-%D bounding box. One way of doing this is to save the bounding
-%D box, draw the graphics that may not count, and restore the
-%D bounding box.
+%D Sometimes we don't want parts of the graphics add to the bounding box. One way of
+%D doing this is to save the bounding box, draw the graphics that may not count, and
+%D restore the bounding box.
%D
%D \starttyping
%D push_boundingbox currentpicture;
@@ -305,9 +296,8 @@ enddef ;
%D outer_boundingbox currentpicture
%D \stoptyping
%D
-%D Especially the latter one can be of use when we include
-%D the graphic in a document that is clipped to the bounding
-%D box. In such occasions one can use:
+%D Especially the latter one can be of use when we include the graphic in a document
+%D that is clipped to the bounding box. In such occasions one can use:
%D
%D \starttyping
%D set_outer_boundingbox currentpicture;
@@ -427,8 +417,8 @@ enddef ;
permanent mirrored, mirroredabout ;
-%D Some missing functions can be implemented rather straightforward (thanks to
-%D Taco and others):
+%D Some missing functions can be implemented rather straightforward (thanks to Taco
+%D and others):
% oldpi := 3.14159265358979323846 ; % from <math.h>
pi := 3.14159265358979323846264338327950288419716939937510 ; % 50 digits
@@ -484,13 +474,11 @@ enddef ;
permanent undashed ;
-%D We provide two macros for drawing stripes across a shape.
-%D The first method (with the n suffix) uses another method,
-%D slower in calculation, but more efficient when drawn. The
-%D first macro divides the sides into n equal parts. The
-%D first argument specifies the way the lines are drawn, while
-%D the second argument identifier the way the shape is to be
-%D drawn.
+%D We provide two macros for drawing stripes across a shape. The first method (with the
+%D n suffix) uses another method, slower in calculation, but more efficient when drawn.
+%D The first macro divides the sides into n equal parts. The first argument specifies the
+%D way the lines are drawn, while the second argument identifier the way the shape is to
+%D be drawn.
%D
%D \starttyping
%D stripe_path_n
@@ -499,8 +487,7 @@ permanent undashed ;
%D fullcircle xscaled 100 yscaled 40 shifted (50,50) withpen pencircle scaled 4;
%D \stoptyping
%D
-%D The a (or angle) alternative supports arbitrary angles and
-%D is therefore more versatile.
+%D The a (or angle) alternative supports arbitrary angles and is therefore more versatile.
%D
%D \starttyping
%D stripe_path_a
@@ -509,8 +496,7 @@ permanent undashed ;
%D fullcircle xscaled 100 yscaled 40 withcolor blue;
%D \stoptyping
%D
-%D We have two alternatives, controlled by arguments or defaults (when arguments
-%D are zero).
+%D We have two alternatives, controlled by arguments or defaults (when arguments are zero).
%D
%D The newer and nicer interface is used as follows (triggered by a question by Mari):
%D
@@ -731,26 +717,25 @@ let sized = xysized ;
permanent xsized, ysized, xysized, sized ;
-def xscale_currentpicture(expr w) = % obsolete
- currentpicture := currentpicture xsized w ;
-enddef;
-
-def yscale_currentpicture(expr h) = % obsolete
- currentpicture := currentpicture ysized h ;
-enddef;
-
-def xyscale_currentpicture(expr w, h) = % obsolete
- currentpicture := currentpicture xysized (w,h) ;
-enddef;
-
-def scale_currentpicture(expr w, h) = % obsolete
- currentpicture := currentpicture xsized w ;
- currentpicture := currentpicture ysized h ;
-enddef;
+% def xscale_currentpicture(expr w) = % obsolete
+% currentpicture := currentpicture xsized w ;
+% enddef;
+%
+% def yscale_currentpicture(expr h) = % obsolete
+% currentpicture := currentpicture ysized h ;
+% enddef;
+%
+% def xyscale_currentpicture(expr w, h) = % obsolete
+% currentpicture := currentpicture xysized (w,h) ;
+% enddef;
+%
+% def scale_currentpicture(expr w, h) = % obsolete
+% currentpicture := currentpicture xsized w ;
+% currentpicture := currentpicture ysized h ;
+% enddef;
-%D A full circle is centered at the origin, while a unitsquare
-%D is located in the first quadrant. Now guess what kind of
-%D path fullsquare and unitcircle do return.
+%D A full circle is centered at the origin, while a unitsquare is located in the first
+%D quadrant. Now guess what kind of path fullsquare and unitcircle do return.
path fullsquare, unitcircle ;
@@ -894,7 +879,7 @@ secondarydef p peepholed q =
endgroup
enddef ;
-boolean intersection_found ;
+newinternal boolean intersection_found ;
secondarydef p intersection_point q =
begingroup
@@ -910,6 +895,8 @@ secondarydef p intersection_point q =
endgroup
enddef ;
+permanent intersection_found, intersection_point ;
+
%D New, undocumented, experimental:
vardef tensecircle (expr width, height, offset) =
@@ -949,12 +936,11 @@ enddef ;
permanent resolvedcolor, normalwithcolor, withcolor ;
-% I don't want a "withcolor black" in case of an empty string ... who knows
-% how that can interfere with outer colors. Somehow the next one doesn't
-% always work out ok, but why ... must be some parsing issue. Anyway, when
-% we cannot do that, we need to fix some chem macros instead as empty strings
-% now lead to black while everywhere else in context empty means: leave color
-% untouched.
+% I don't want a "withcolor black" in case of an empty string ... who knows how that can
+% interfere with outer colors. Somehow the next one doesn't always work out ok, but why
+% ... must be some parsing issue. Anyway, when we cannot do that, we need to fix some
+% chem macros instead as empty strings now lead to black while everywhere else in context
+% empty means: leave color untouched.
% def withcolor expr c =
% if not string c :
@@ -1030,8 +1016,8 @@ permanent colortype, whitecolor, blackcolor, complementary, complemented ;
% draw t ;
% enddef;
-%D This two step approach saves the path first, since it can
-%D be a function. Attributes must not be randomized.
+%D This two step approach saves the path first, since it can be a function. Attributes
+%D must not be randomized.
def drawfill expr c =
path temp_c ; temp_c := c ;
@@ -1297,9 +1283,9 @@ permanent interpolated ;
% primarydef p paralleled d = (
% p shifted ((d*unitvector(direction 0 of p) - point 0 of p) rotated 90)
% ) enddef ;
-%
-% Alan came up with an improved version and stepwise we ended up with (or
-% might up with a variant of):
+
+%D Alan came up with an improved version and stepwise we ended up with (or might up
+%D with a variant of):
def istextext(expr p) =
(picture p and ((substring(0,3) of prescriptpart p) = "tx_"))
@@ -1782,8 +1768,8 @@ def mfun_decoration_i expr i =
withpostscript postscriptpart i
enddef ;
-% We could collapse all in one helper but in context we nowaways don't want
-% the added obscurity. Tokens come cheap.
+%D We could collapse all in one helper but in context we nowaways don't want the added
+%D obscurity. Tokens come cheap.
numeric mfun_arrow_snippets ;
numeric mfun_arrow_count ;
@@ -1825,8 +1811,8 @@ enddef ;
def mfun_draw_arrow_nothing text t =
enddef ;
-% The path is shortened so that the arrow head extends it to the original
-% length. In case of a double arrow the path gets shortened twice.
+%D The path is shortened so that the arrow head extends it to the original length. In
+%D case of a double arrow the path gets shortened twice.
def mfun_draw_arrow_path text t =
if autoarrows :
@@ -1847,10 +1833,9 @@ def mfun_draw_arrow_path_double text t =
endgroup ;
enddef ;
-% The picture variant is not treating each path but only the first and
-% last path. This can be somewhat counterintuitive but is needed for Alan's
-% macros. So here the last and in case of a double path first paths in a
-% picture get the shortening.
+%D The picture variant is not treating each path but only the first and last path. This
+%D can be somewhat counterintuitive but is needed for Alan's macros. So here the last
+%D and in case of a double path first paths in a icture get the shortening.
def mfun_with_arrow_picture (text t) =
mfun_arrow_count := 0 ;
@@ -2040,7 +2025,7 @@ vardef freelabel (expr asked_text, asked_location, asked_origin) =
draw thefreelabel(asked_text,asked_location,asked_origin) ;
enddef ;
-vardef freedotlabel (expr asked_text, loc, asked_origin) =
+vardef freedotlabel (expr asked_text, asked_location, asked_origin) =
interim linecap := rounded ;
draw asked_location withpen pencircle scaled freedotlabelsize ;
draw thefreelabel(asked_text,asked_location,asked_origin) ;
@@ -2526,9 +2511,8 @@ vardef mfun_repathed (expr mode, p) text t =
endgroup
enddef ;
-% After a question of Denis on how to erase a z variable, Jacko
-% suggested to assign whatever to x and y. So a clearz
-% variable can be defined as:
+%D After a question of Denis on how to erase a z variable, Jacko suggested to assign
+%D whatever to x and y. So a clearz variable can be defined as:
%
% vardef clearz@# =
% x@# := whatever ;
@@ -3232,10 +3216,10 @@ enddef ;
permanent snapped ;
-% Take a look at mp-tool.mpiv for the old implementation if the next code. We only
-% provide this for old times sake. We assume that the lmt_ commands are defined by
-% the time this is used:
-%
+%D Take a look at mp-tool.mpiv for the old implementation if the next code. We only provide
+%D this for old times sake. We assume that the lmt_ commands are defined by the time this
+%D is used:
+
% beginfont("demo-symbols");
% beginglyph(9754,2,4,0) ; % high voltage
% interim ahlength := 1 ;
@@ -3282,8 +3266,8 @@ enddef ;
permanent beginfont, endfont, beginglyph, endglyph ;
-%D Dimensions have never been an issue as traditional MP can't make that large
-%D pictures, but with double mode we need a catch:
+%D Dimensions have never been an issue as traditional MP can't make that large pictures,
+%D but with double mode we need a catch:
newinternal maxdimensions ; maxdimensions := 14000 ;
@@ -3312,9 +3296,8 @@ fulltriangle := point 0 along fullcircle
immutable unittriangle, fulltriangle ;
-%D Kind of special and undocumented. On Wikipedia one can find examples
-%D of quick sort routines. Here we have a variant that permits a
-%D method.
+%D Kind of special and undocumented. On Wikipedia one can find examples of quick sort
+%D routines. Here we have a variant that permits a method.
% vardef listsize(suffix list) =
% numeric len ; len := 0 ;
@@ -3519,8 +3502,7 @@ def do_drawpathwithpoints(expr p) text t =
fi ;
enddef ;
-%D These new helpers are by Alan and are used in for instance the mp-node
-%D module.
+%D These new helpers are by Alan and are used in for instance the mp-node module.
newinternal crossingdebug ; crossingdebug := 0 ;
newinternal crossingscale ; crossingscale := 10 ;
@@ -3823,3 +3805,24 @@ def yslanted primary s =
enddef ;
permanent xslanted, yslanted ;
+
+vardef processpath (expr p) (text pp) =
+ if path p :
+ for i=0 upto length(p)-1 :
+ pp(point i of p) .. controls
+ pp(postcontrol i of p) and
+ pp(precontrol (i+1) of p) ..
+ endfor
+ if cycle p :
+ cycle
+ else :
+ pp(point length(p) of p)
+ fi
+ elseif pair p :
+ pp(p)
+ else :
+ p
+ fi
+enddef ;
+
+permanent processpath ;