diff options
Diffstat (limited to 'Master/texmf-dist/tex/context/base/meta-ini.mkiv')
-rw-r--r-- | Master/texmf-dist/tex/context/base/meta-ini.mkiv | 133 |
1 files changed, 67 insertions, 66 deletions
diff --git a/Master/texmf-dist/tex/context/base/meta-ini.mkiv b/Master/texmf-dist/tex/context/base/meta-ini.mkiv index ff4d48c1db2..61acbca32c7 100644 --- a/Master/texmf-dist/tex/context/base/meta-ini.mkiv +++ b/Master/texmf-dist/tex/context/base/meta-ini.mkiv @@ -87,7 +87,7 @@ \def\MPinstancetoks{\csname\@@MPF::\currentMPgraphicinstance\endcsname} -\def\defineMPinstance +\unexpanded\def\defineMPinstance {\dodoubleargument\dodefineMPinstance} \def\dodefineMPinstance[#1][#2]% @@ -111,7 +111,12 @@ \else \edef\currentMPgraphicinstance{#1}% \fi - \edef\currentMPgraphicformat{\csname\@@MPF\currentMPgraphicinstance\s!format\endcsname}} + \edef\currentMPgraphicformat + {\ifcsname\@@MPF\currentMPgraphicinstance\s!format\endcsname + \csname\@@MPF\currentMPgraphicinstance\s!format\endcsname + \else + \defaultMPgraphicinstance + \fi}} \def\currentMPgraphicinstance{\defaultMPgraphicinstance} \def\currentMPgraphicformat {\currentMPgraphicinstance} @@ -133,9 +138,14 @@ \def\MPaskedfigure{false} -\long\def\processMPgraphic#1% todo: extensions and inclusions outside beginfig - {\begingroup % needed? -\forgetall +\def\currentMPinitializations + {\ifconditional\includeMPinitializations\the\MPinitializations;\fi\theMPrandomseed;} + +\def\currentMPpreamble + {\ifconditional\includeMPextensions\the\MPextensions;\the\MPuserinclusions;\fi\the\MPinstancetoks;} + +\def\dostartcurrentMPgraphic + {\begingroup \enableincludeMPgraphics \the\everyMPgraphic \presetMPdefinitions @@ -146,18 +156,28 @@ {\setfalse\includeMPextensions}% \doifelsevalue{\@@MPF\currentMPgraphicinstance\s!initializations}\v!yes {\settrue \includeMPinitializations}% - {\setfalse\includeMPinitializations}% + {\setfalse\includeMPinitializations}} + +\def\dostopcurrentMPgraphic + {\global\MPinstancetoks\emptytoks + \global\settrue\METAFUNinitialized % becomes obsolete + \endgroup} + +\unexpanded\long\def\processMPgraphic#1% todo: extensions and inclusions outside beginfig + {\dostartcurrentMPgraphic + \forgetall \setbox\MPgraphicbox\hbox\bgroup - \normalexpanded{\noexpand\ctxlua{metapost.graphic("\currentMPgraphicinstance", "\currentMPgraphicformat", - \!!bs\ifconditional\includeMPinitializations\the\MPinitializations;\fi\theMPrandomseed;#1;\!!es, - \!!bs\ifconditional\includeMPextensions\the\MPextensions;\the\MPuserinclusions;\fi\the\MPinstancetoks;\!!es, - \MPaskedfigure + \normalexpanded{\noexpand\ctxlua{metapost.graphic( + "\currentMPgraphicinstance", + "\currentMPgraphicformat", + \!!bs#1\!!es, + \!!bs\currentMPinitializations\!!es, + \!!bs\currentMPpreamble\!!es, + \MPaskedfigure )}}% \egroup - \global\MPinstancetoks\emptytoks - \global\settrue\METAFUNinitialized % becomes obsolete \placeMPgraphic - \endgroup} + \dostopcurrentMPgraphic} \newif\ifsetMPrandomseed \setMPrandomseedtrue % false by default @@ -230,7 +250,7 @@ \def\getMPdrawing {\ifMPdrawingdone - \expandafter\processMPgraphic\expandafter{\MPdrawingdata}% + \expandafter\processMPgraphic\expandafter{\MPdrawingdata}% is this expansion still needed? \fi} \def\startMPdrawing @@ -247,19 +267,26 @@ \let\stopMPdrawing\relax -\long\def\startMPclip#1#2\stopMPclip - {\long\setgvalue{MPC:#1}{\ctxlua{metapost.getclippath(\!!bs#2\!!es)}}} - \let\stopMPclip\relax +\long\def\startMPclip#1#2\stopMPclip % todo: store at the lua end or just store less + {\long\setgvalue{MPC:#1}{#2}} + \def\grabMPclippath#1#2#3#4#5% #5 is alternative {\begingroup \edef\width {#3\space}\let\overlaywidth \width \edef\height{#4\space}\let\overlayheight\height \ifcsname MPC:#1\endcsname - \xdef\MPclippath{\getvalue{MPC:#1}}% + \dostartcurrentMPgraphic + \xdef\MPclippath{\normalexpanded{\noexpand\ctxlua{metapost.theclippath( + "\currentMPgraphicinstance", + "\currentMPgraphicformat", + \!!bs\getvalue{MPC:#1}\!!es, + \!!bs\currentMPinitializations\!!es, + \!!bs\currentMPpreamble\!!es + )}}}% + \dostopcurrentMPgraphic \ifx\MPclippath\empty\xdef\MPclippath{#5}\fi - \setxvalue{MPC:#1}{\MPclippath}% \else \xdef\MPclippath{#5}% \fi @@ -325,7 +352,7 @@ \def\@@meta{meta:} -\def\setupMPvariables +\unexpanded\def\setupMPvariables {\dodoubleempty\dosetupMPvariables} \def\dosetupMPvariables[#1][#2]% @@ -421,7 +448,7 @@ \let\MPshiftdrawingtrue \ignoreMPboxdepth \let\MPshiftdrawingfalse\normalMPboxdepth -\def\placeMPgraphic +\unexpanded\def\placeMPgraphic {\ifcase\MPboxmode \or % 1 \doobeyMPboxdepth @@ -435,15 +462,14 @@ \xdef\MPlly{#3}% ugly as well \xdef\MPurx{#4}% \xdef\MPury{#5}% - \getobject{MP}{#1}} + \hbox{\forcecolorhack\getobject{MP}{#1}}} % else no proper color intent \long\def\handleuniqueMPgraphic#1#2#3% {\begingroup \def\@@meta{#1:}% \extendMPoverlaystamp{#2}% incl prepare \ifcsname\@@MPG\overlaystamp:#1\endcsname\else - \enableincludeMPgraphics -% \forgetall + \enableincludeMPgraphics % redundant \global\advance\MPobjectcounter\plusone \setobject{MP}{\number\MPobjectcounter}\hbox{\processMPgraphic{#3}}% was vbox, graphic must end up as hbox \setxvalue{\@@MPG\overlaystamp:#1}{\noexpand\reuseMPbox{\number\MPobjectcounter}{\MPllx}{\MPlly}{\MPurx}{\MPury}}% @@ -451,7 +477,7 @@ \getvalue{\@@MPG\overlaystamp:#1}% \endgroup} -\long\def\startuniqueMPgraphic +\long\unexpanded\def\startuniqueMPgraphic {\dodoublegroupempty\dostartuniqueMPgraphic} \long\def\dostartuniqueMPgraphic#1#2#3\stopuniqueMPgraphic% @@ -470,20 +496,19 @@ \long\def\handleuseMPgraphic#1#2#3% {\begingroup -% \forgetall % check this \def\@@meta{#1:}% \prepareMPvariables{#2}% - \enableincludeMPgraphics + \enableincludeMPgraphics % redundant \processMPgraphic{#3}% \endgroup} -\long\def\startuseMPgraphic +\long\unexpanded\def\startuseMPgraphic {\dodoublegroupempty\dostartuseMPgraphic} \long\def\dostartuseMPgraphic#1#2#3\stopuseMPgraphic {\long\setgvalue{\@@MPG#1}{\handleuseMPgraphic{#1}{#2}{#3}}} -\long\def\startusableMPgraphic % redundant but handy +\long\unexpanded\def\startusableMPgraphic % redundant but handy {\dodoublegroupempty\dostartusableMPgraphic} \long\def\dostartusableMPgraphic#1#2#3\stopusableMPgraphic @@ -496,14 +521,14 @@ {\begingroup \def\@@meta{#1:}% \prepareMPvariables{#2}% - \enableincludeMPgraphics + \enableincludeMPgraphics % redundant \global\advance\MPobjectcounter\plusone \setobject{MP}{\number\MPobjectcounter}\hbox{\processMPgraphic{#3}}% was vbox, graphic must end up as hbox \setxvalue{\@@MPG#1}{\noexpand\reuseMPbox{\number\MPobjectcounter}{\MPllx}{\MPlly}{\MPurx}{\MPury}}% \getvalue{\@@MPG#1}% \endgroup} -\long\def\startreusableMPgraphic +\long\unexpanded\def\startreusableMPgraphic {\dodoublegroupempty\dostartreusableMPgraphic} \long\def\dostartreusableMPgraphic#1#2#3\stopreusableMPgraphic @@ -542,7 +567,7 @@ \def\overlaypagestamp {\MPpageprefix\overlaywidth:\overlayheight:\overlaydepth:\MPcolor\overlaycolor:\MPcolor\overlaylinecolor} -\long\def\startuniqueMPpagegraphic +\long\unexpanded\def\startuniqueMPpagegraphic {\dodoublegroupempty\dostartuniqueMPpagegraphic} \long\def\dostartuniqueMPpagegraphic#1#2#3\stopuniqueMPpagegraphic @@ -774,7 +799,7 @@ {\iffirstargument \startuseMPgraphic{#1}#2\stopuseMPgraphic \else - \startuseMPgraphic{mprun}#1\stopuseMPgraphic + \startuseMPgraphic{mprun}#2\stopuseMPgraphic \fi} % for old time sake @@ -1057,37 +1082,13 @@ %D \macros %D {startMPcolor} -%D -%D The following time consuming method uses \METAPOST\ to -%D calculate a color. This enables a match between colors -%D resulting from a complex calculation (e.g. for a title -%D page) and those in the text. - -% \startuseMPgraphic{somecolors} -% color c[] ; c[1] := .7[red,green] ; c[2] := .7[blue,yellow] ; -% \stopuseMPgraphic - -% \startMPcolor[shade-1][t=.2,a=1] -% \includeMPgraphic{somecolors} ; fill fullcircle withcolor c[1] ; -% \stopMPcolor - -% \startMPcolor[shade-2][t=.2,a=1] -% \includeMPgraphic{somecolors} ; fill fullcircle withcolor c[2] ; -% \stopMPcolor - -% \blackrule[width=\hsize,height=4cm,color=shade-1] -% \blackrule[width=\hsize,height=4cm,color=shade-2] -\def\startMPcolor - {\dodoubleempty\dostartMPcolor} +\long\unexpanded\def\startMPcolor#1\stopMPcolor + {\writestatus \m!metapost % eventually this placeholder will go away + {\string\startMPcolor...\stopMPcolor\space is obsolete,\space + use \string\defineintermediatecolor\space instead}} -\long\def\dostartMPcolor[#1][#2]#3\stopMPcolor % slow but sometimes handy - {\startnointerference - \def\handleMPgraycolor{\normalexpanded{\noexpand\defineglobalcolor[#1][s=\!MPgMPa1,#2]}}% - \def\handleMPrgbcolor {\normalexpanded{\noexpand\defineglobalcolor[#1][r=\!MPgMPa1,g=\!MPgMPa2,b=\!MPgMPa3,#2]}}% - \def\handleMPcmykcolor{\normalexpanded{\noexpand\defineglobalcolor[#1][c=\!MPgMPa1,m=\!MPgMPa2,y=\!MPgMPa3,k=\!MPgMPa4,#2]}}% - \processMPgraphic{#3}% - \stopnointerference} +\let\stopMPcolor\relax %D New: @@ -1171,10 +1172,10 @@ \reuseMPgraphic{\@@MPG#1@S@}% \fi} -\def\startstaticMPfigure#1#2\stopstaticMPfigure +\unexpanded\def\startstaticMPfigure#1#2\stopstaticMPfigure {\startreusableMPgraphic{\@@MPG#1@S@}#2\stopreusableMPgraphic} -\long\def\startstaticMPgraphic +\long\unexpanded\def\startstaticMPgraphic {\dodoublegroupempty\dostartstaticMPgraphic} \long\def\dostartstaticMPgraphic#1#2#3\stopstaticMPgraphic @@ -1247,13 +1248,13 @@ \stopMPinitializations %D \macros -%D {\setupMPgraphics} +%D {setupMPgraphics} %D %D Here is a generic setup command: \newtoks \everysetupMPgraphics -\def\setupMPgraphics[#1]% +\unexpanded\def\setupMPgraphics[#1]% {\getparameters[\??mp][#1]% \the\everysetupMPgraphics} |