summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/meta-ini.mkiv
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/context/base/meta-ini.mkiv')
-rw-r--r--Master/texmf-dist/tex/context/base/meta-ini.mkiv107
1 files changed, 97 insertions, 10 deletions
diff --git a/Master/texmf-dist/tex/context/base/meta-ini.mkiv b/Master/texmf-dist/tex/context/base/meta-ini.mkiv
index 6502047fbc0..281143e40b0 100644
--- a/Master/texmf-dist/tex/context/base/meta-ini.mkiv
+++ b/Master/texmf-dist/tex/context/base/meta-ini.mkiv
@@ -264,7 +264,10 @@
\ifx\p_setups\empty \else
\setups[\p_setups]%
\fi
- \useMPinstancestyleandcolor\c!textstyle\c!textcolor}
+ \useMPinstancestyleparameter\c!textstyle}
+
+\def\meta_set_current_color
+ {\useMPinstancecolorparameter\c!textcolor}
\def\meta_stop_current_graphic
{\global\t_meta_definitions\emptytoks
@@ -317,7 +320,7 @@
\let\normal_meta_process_graphic_stop \meta_process_graphic_stop
\let\meta_process_graphic_start\relax
\let\meta_process_graphic_stop \relax
- \def\meta_process_graphic_figure_start{\startTEXpage\normal_meta_process_graphic_start}%
+ \def\meta_process_graphic_figure_start{\startTEXpage[\c!offset=\v!overlay,\c!align=]\normal_meta_process_graphic_start}%
\def\meta_process_graphic_figure_stop {\normal_meta_process_graphic_stop\stopTEXpage}
\def\MPaskedfigure{all}%
\meta_process_graphic{input "#1" ;}%
@@ -429,16 +432,19 @@
\hskip\cldcontext{fonts.hashes.parameters[font.current()].designsize}sp\relax
\endgroup}
+\definefontsynonym[MetafunDefault][Regular*default]
+
\startMPinitializations % scale is not yet ok
- defaultfont:="\truefontname{Regular}";
- defaultscale:=\the\bodyfontsize/10pt;
+ defaultfont:="\truefontname{MetafunDefault}";
+ % defaultscale:=\the\bodyfontsize/10pt; % only when hard coded 10pt
+ defaultscale:=1;
\stopMPinitializations
% watch out, this is a type1 font because mp can only handle 8 bit fonts
-\startMPinitializations % scale is not yet ok
- defaultfont:="rm-lmtt10";
-\stopMPinitializations
+% \startMPinitializations % scale is not yet ok
+% defaultfont:="rm-lmtt10";
+% \stopMPinitializations
%D A signal that we're in combined \CONTEXT||\METAFUN mode:
@@ -593,7 +599,7 @@
%D \stoptyping
\def\overlaystamp % watch the \MPcolor, since colors can be redefined
- {\overlaywidth:\overlayheight:\overlaydepth:\MPcolor\overlaycolor:\MPcolor\overlaylinecolor}
+ {\overlaywidth:\overlayheight:\overlaydepth:\overlayoffset:\overlaylinewidth:\MPcolor\overlaycolor:\MPcolor\overlaylinecolor}
%D A better approach is to let additional variables play a role
%D in determining the uniqueness. In the next macro, the
@@ -846,10 +852,12 @@
% This will change ...
-\def\MPdataMPDfile{\jobname-mpgraph.mpd}
+\def\MPdataMPDfile{\jobname-mpgraph.mpd} % this one will become obsolete
\def\MPdataMPOfile{\jobname-mpgraph.mpo}
\def\MPdataMPYfile{\jobname-mpgraph.mpy}
+% makempy.registerfile(filename)
+
\startMPinitializations
boolean collapse_data; collapse_data:=true;
def data_mpd_file = "\MPdataMPDfile" enddef ;
@@ -1094,8 +1102,9 @@
CurrentLayout:="\currentlayout";
OverlayWidth:=\overlaywidth;
OverlayHeight:=\overlayheight;
- OverlayDepth:=\overlayheight;
+ OverlayDepth:=\overlaydepth;
OverlayLineWidth:=\overlaylinewidth;
+ OverlayOffset:=\overlayoffset;
%
\m_meta_colo_initializations
%
@@ -1360,6 +1369,67 @@
defaultcolormodel := \ifcase\MPcolormethod1\or1\or3\else3\fi;
\stopMPinitializations
+%D macros
+%D {mprunvar,mpruntab,mprunset}
+%D
+%D \starttyping
+%D \startMPcode
+%D passvariable("version","1.0") ;
+%D passvariable("number",123) ;
+%D passvariable("string","whatever") ;
+%D passvariable("point",(1.5,2.8)) ;
+%D passvariable("triplet",(1/1,1/2,1/3)) ;
+%D passvariable("quad",(1.1,2.2,3.3,4.4)) ;
+%D passvariable("boolean",false) ;
+%D passvariable("path",fullcircle scaled 1cm) ;
+%D draw fullcircle scaled 20pt ;
+%D \stopMPcode
+%D
+%D \ctxlua{inspect(metapost.variables)}
+%D
+%D \MPrunvar{version} \MPruntab{quad}{3} (\MPrunset{triplet}{,})
+%D
+%D $(x,y) = (\MPruntab{point}{1},\MPruntab{point}{2})$
+%D $(x,y) = (\MPrunset{point}{,})$
+%D \stoptyping
+
+\def\MPrunvar #1{\ctxcommand{mprunvar("#1")}} \let\mprunvar\MPrunvar
+\def\MPruntab#1#2{\ctxcommand{mprunvar("#1",\number#2)}} \let\mpruntab\MPruntab
+\def\MPrunset#1#2{\ctxcommand{mprunvar("#1","#2")}} \let\mprunset\MPrunset
+
+%D We also provide an outputless run:
+
+\unexpanded\def\startMPcalculation
+ {\begingroup
+ \setbox\nextbox\hbox\bgroup
+ \dosinglegroupempty\meta_start_calculation}
+
+\def\meta_start_calculation
+ {\iffirstargument
+ \expandafter\meta_start_calculation_instance
+ \else
+ \expandafter\meta_start_calculation_standard
+ \fi}
+
+\def\meta_start_calculation_instance#1#2\stopMPcalculation
+ {\edef\currentMPinstance{#1}%
+ \let\currentMPgraphicname\empty
+ \edef\currentMPformat{\MPinstanceparameter\s!format}%
+ \meta_enable_include
+ \meta_process_graphic{#2;draw origin}%
+ \egroup
+ \endgroup}
+
+\def\meta_start_calculation_standard#1#2\stopMPcalculation
+ {\let\currentMPinstance\defaultMPinstance
+ \let\currentMPgraphicname\empty
+ \edef\currentMPformat{\MPinstanceparameter\s!format}%
+ \meta_process_graphic{#2;draw origin}%
+ \egroup
+ \endgroup}
+
+\let\stopMPcalculation\relax
+
%D \macros
%D {setupMPgraphics}
%D
@@ -1381,6 +1451,23 @@
\setupMPgraphics
[\c!color=\v!local]
+%D This can save some runtime: rename the mpy file from a first run (when stable) to
+%D another file and reuse it. One can also use the original filename, but a copy is
+%D often better.
+%D
+%D \starttyping
+%D \setupMPgraphics
+%D [mpy=\jobname.mpy]
+%D \stoptyping
+
+\appendtoks
+ \edef\p_mpy{\directMPgraphicsparameter{mpy}}%
+ \ifx\p_mpy\empty \else
+ \let\MPdataMPYfile\p_mpy
+ \ctxlua{metapost.makempy.registerfile("\p_mpy")}%
+ \fi
+\to \everysetupMPgraphics
+
%D Done.
\protect \endinput