diff options
author | Taco Hoekwater <taco@elvenkind.com> | 2011-06-01 08:54:21 +0000 |
---|---|---|
committer | Taco Hoekwater <taco@elvenkind.com> | 2011-06-01 08:54:21 +0000 |
commit | d7ccb42582f85acf30568913610ccf4d602023fb (patch) | |
tree | 7292e3545a420676878e7451b68892d360c62cb6 /Master/texmf-dist/tex/context/base/meta-ini.mkiv | |
parent | 2d62a6fe9b80def59c392268022f1f9a2d6e358f (diff) |
commit context 2011.05.18
git-svn-id: svn://tug.org/texlive/trunk@22719 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/context/base/meta-ini.mkiv')
-rw-r--r-- | Master/texmf-dist/tex/context/base/meta-ini.mkiv | 185 |
1 files changed, 54 insertions, 131 deletions
diff --git a/Master/texmf-dist/tex/context/base/meta-ini.mkiv b/Master/texmf-dist/tex/context/base/meta-ini.mkiv index 61acbca32c7..e95eb178604 100644 --- a/Master/texmf-dist/tex/context/base/meta-ini.mkiv +++ b/Master/texmf-dist/tex/context/base/meta-ini.mkiv @@ -13,6 +13,8 @@ \writestatus{loading}{MetaPost Graphics / Initializations} +\registerctxluafile{meta-ini}{1.001} + \unprotect %D Instead of sharing code with \MKII, I decided to copy @@ -134,8 +136,6 @@ \def\endMPgraphicgroup {\endgroup} -\newconditional \METAFUNinitialized - \def\MPaskedfigure{false} \def\currentMPinitializations @@ -160,19 +160,18 @@ \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 + \setbox\MPgraphicbox\hbox\bgroup % ; added 20100901 (as in mkii) \normalexpanded{\noexpand\ctxlua{metapost.graphic( "\currentMPgraphicinstance", "\currentMPgraphicformat", - \!!bs#1\!!es, - \!!bs\currentMPinitializations\!!es, - \!!bs\currentMPpreamble\!!es, + \!!bs#1;\!!es, + \!!bs\currentMPinitializations;\!!es, + \!!bs\currentMPpreamble;\!!es, \MPaskedfigure )}}% \egroup @@ -202,36 +201,10 @@ {\let\handleuseMPgraphic \thirdofthreearguments \let\handlereusableMPgraphic\thirdofthreearguments} -\let\MPdrawingdata\empty - \newif\ifMPdrawingdone \MPdrawingdonefalse -\def\resetMPdrawing - {\globallet\MPdrawingdata\empty - \global\MPdrawingdonefalse} - -\def\pushMPdrawing - {\globalpushmacro\MPdrawingdata - \globallet\MPdrawingdata\empty} - -\def\popMPdrawing - {\globalpopmacro\MPdrawingdata} - -\def\getMPdrawing{\dosinglegroupempty\dogetMPdrawing} - -\def\startMPdrawing - {\dosingleempty\dostartMPdrawing} - -\long\def\dostartMPdrawing[#1]#2\stopMPdrawing - {\relax - \bgroup - \enableincludeMPgraphics - \presetMPdefinitions % in case #2 has measures - \doifelse{#1}{-}{\convertargument#2\to\asciia}{\long\def\asciia{#2}}% - \long\xdef\MPdrawingdata{\MPdrawingdata\asciia}% - \egroup} - -\let\stopMPdrawing\relax +\def\finalizeMPdrawing + {\MPdrawingdonetrue} \let\MPdrawingdata\empty @@ -267,6 +240,14 @@ \let\stopMPdrawing\relax +\long\def\MPdrawing#1% + {\relax + \bgroup + \enableincludeMPgraphics + \presetMPdefinitions + \long\xdef\MPdrawingdata{\MPdrawingdata#1}% + \egroup} + \let\stopMPclip\relax \long\def\startMPclip#1#2\stopMPclip % todo: store at the lua end or just store less @@ -424,10 +405,9 @@ %D \uniqueMPgraphic{meta:hash}{gap=10pt,angle=30} %D \stoptyping -\newcount\MPobjectcounter -\newbox \MPgraphicbox - -\chardef\MPboxmode\zerocount +\newcount \MPobjectcounter +\newbox \MPgraphicbox +\newconstant\MPboxmode \def\doobeyMPboxdepth % mode = 1 {\setbox\MPgraphicbox\hbox{\hskip\MPllx\onebasepoint\raise\MPlly\onebasepoint\box\MPgraphicbox}} @@ -439,9 +419,9 @@ \ht\MPgraphicbox\the\ht\MPgraphicbox \dp\MPgraphicbox\the\dp\MPgraphicbox}} -\def\obeyMPboxdepth {\chardef\MPboxmode\plusone} -\def\ignoreMPboxdepth{\chardef\MPboxmode\plustwo} -\def\normalMPboxdepth{\chardef\MPboxmode\zerocount} +\def\obeyMPboxdepth {\MPboxmode\plusone} +\def\ignoreMPboxdepth{\MPboxmode\plustwo} +\def\normalMPboxdepth{\MPboxmode\zerocount} % compatibility hack: @@ -660,8 +640,6 @@ def data_mpy_file = "\MPdataMPYfile" enddef ; \stopMPextensions -\chardef\currentMPgraphic\plusone - \def\getMPdata {\let\MPdata\secondoftwoarguments \startreadingfile @@ -670,15 +648,6 @@ % \stopnointerference \stopreadingfile} -%D \macros -%D {MPrunfile} -%D -%D This one is more abstract and does not assume knowledge -%D of buffer prefixes. - -\def\MPrunfile#1% - {\bufferprefix mprun.#1} - %D For the moment, the next one is a private macro: \def\processMPbuffer @@ -702,7 +671,7 @@ % we need this trick because tex.sprint does not interprets newlines and the scanner % stops at a newline; also, we do need to flush the buffer under a normal catcode % regime in order to expand embedded tex macros; #1 can be a list - \processMPgraphic{\ctxlua{buffers.feedback("\currentMPgraphicname")}}% + \processMPgraphic{\ctxcommand{feedback("\currentMPgraphicname")}}% \endMPgraphicgroup}} \def\runMPbuffer @@ -735,8 +704,6 @@ \def\resetMPenvironment {\ctxlua{metapost.tex.reset()}} -\resetMPenvironment - \def\useMPenvironmentbuffer[#1]% {\ctxlua{metapost.tex.set(buffers.content("#1"))}} @@ -774,6 +741,23 @@ \let\stopMPcode\relax +\def\MPcode{\dosinglegroupempty\doMPcode} + +\def\doMPcode + {\iffirstargument + \expandafter\dodoMPcode + \else + \expandafter\nodoMPcode + \fi} + +\def\dodoMPcode#1#2% + {\beginMPgraphicgroup{#1::\s!dummy}% name does not matter + \processMPgraphic{#2}% + \endMPgraphicgroup} + +\def\nodoMPcode#1#2% + {\processMPgraphic{#2}} + % a bit nasty (also needed for compatibility: % \startMPrun input mp-www.mp ; \stopMPrun @@ -846,17 +830,7 @@ %D Loading specific \METAPOST\ related definitions is %D accomplished by: -\def\douseMPlibrary#1% - {\ifcsname\c!file\f!metapostprefix#1\endcsname\else - \letvalueempty{\c!file\f!metapostprefix#1}% - \makeshortfilename[\truefilename{\f!metapostprefix#1}]% - \startreadingfile - \readsysfile\shortfilename{\showmessage\m!metapost1{#1}}\donothing - \stopreadingfile - \fi} - -\def\useMPlibrary[#1]% - {\processcommalist[#1]\douseMPlibrary} +\unexpanded\def\useMPlibrary[#1]{\ctxlua{metapost.uselibrary(\!!bs#1\!!es)}} %D \macros %D {setMPtext, MPtext, MPstring, MPbetex} @@ -905,6 +879,7 @@ \stopMPextensions \startMPinitializations + CurrentLayout:="\currentlayout"; OverlayWidth:=\overlaywidth; OverlayHeight:=\overlayheight; OverlayDepth:=\overlayheight; @@ -990,58 +965,6 @@ \newtoks\everyinsertMPfile -% removed in backend: -% -% \def\doinsertMPfile#1% -% {\doiffileelse{./#1}{\includeMPasPDF{./#1}}{\message{[MP #1]}}} -% -% \let\insertMPfileARG\insertMPfile -% -% \def\insertMPfile#1#2% in context #2 is empty -% {\doifelsenothing{#2}{\doinsertMPfile{#1}}{\insertMPfileARG{#1}{#2}}} -% -% \def\includeMPasEPS#1% untested !! -% {\bgroup -% \message{[MP as EPS #1]}% -% \the\everyinsertMPfile -% \dogetEPSboundingbox{#1}\!!widtha\!!heighta\!!widthb\!!heightb -% \setbox\scratchbox\vbox to \!!heightb -% {\vfill -% \let \@@DriverImageType \c!mps -% \def \@@DriverImageFile {#1}% -% \edef\@@DriverImageWidth {\the\!!widthb }% -% \edef\@@DriverImageHeight{\the\!!heightb}% -% \doinsertfile}% -% \wd\scratchbox\!!widthb -% \dp\scratchbox\zeropoint -% \box\scratchbox -% \egroup} -% -% \def\includeMPasPDF#1% -% {\bgroup -% \the\everyinsertMPfile -% \ifinobject \else \chardef\makeMPintoPDFobject\plustwo \fi % when needed -% \convertMPtoPDF{#1}{1}{1}% no \plusone ! -% \egroup} -% -% %D So, using a low level approach (thereby avoiding the slower -% %D figure analysis macros) pays off. This kind of -% %D optimizations are a bit tricky since we must make sure that -% %D special resources end up in the (PDF) files. Because the -% %D \METAPOST\ to \PDF\ can handle objects itself, it is not -% %D that complicated. -% -% %D We hook a couple of initializations into the graphic -% %D macros. -% -% \appendtoks -% \let\figuretypes\c!mps -% \runutilityfilefalse -% \consultutilityfilefalse -% \to \everyinsertMPfile -% -% %D One more: (still needed?) - \startMPextensions def initialize_form_numbers = do_initialize_numbers; @@ -1105,8 +1028,8 @@ %D Usage: %D %D \starttyping -%D \defineproperty[one][layer][state=start] -%D \defineproperty[two][layer][state=stop] +%D \defineviewerlayer[one][state=start] +%D \defineviewerlayer[two][state=stop] %D %D \startuseMPgraphic{step-1} %D fill fullcircle scaled 10cm withcolor red ; @@ -1116,8 +1039,8 @@ %D fill fullcircle scaled 5cm withcolor green ; %D \stopuseMPgraphic %D -%D \setlayer[mp]{\property[one]{\useMPgraphic{step-1}}} -%D \setlayer[mp]{\property[two]{\useMPgraphic{step-2}}} +%D \setlayer[mp]{\viewerlayer[one]{\useMPgraphic{step-1}}} +%D \setlayer[mp]{\viewerlayer[two]{\useMPgraphic{step-2}}} %D %D \ruledhbox{\flushlayer[mp]} %D \stoptyping @@ -1210,7 +1133,7 @@ %D In any case we need to tell the converter what the inherited color %D is to start with. Case~3 is kind of unpredictable as it closely %D relates to the order in which paths are flushed. If you want to -%Dinherit automatically from the surrounding, you can best stick to +%D inherit automatically from the surrounding, you can best stick to %D variant 1. Variant 0 (an isolated graphic) is the default. %D %D \startbuffer @@ -1226,21 +1149,21 @@ %D \stopuseMPgraphic %D %D \starttabulate -%D \NC 0\quad \NC \chardef\MPcolormethod0 \green XX\quad \useMPgraphic{test}\quad XX \NC \NR -%D \NC 1\quad \NC \chardef\MPcolormethod1 \green XX\quad \useMPgraphic{test}\quad XX \NC \NR -%D \NC 2\quad \NC \chardef\MPcolormethod2 \green XX\quad \useMPgraphic{test}\quad XX \NC \NR -%D \NC 3\quad \NC \chardef\MPcolormethod3 \green XX\quad \useMPgraphic{test}\quad XX \NC \NR +%D \NC 0\quad \NC \MPcolormethod0 \green XX\quad \useMPgraphic{test}\quad XX \NC \NR +%D \NC 1\quad \NC \MPcolormethod1 \green XX\quad \useMPgraphic{test}\quad XX \NC \NR +%D \NC 2\quad \NC \MPcolormethod2 \green XX\quad \useMPgraphic{test}\quad XX \NC \NR +%D \NC 3\quad \NC \MPcolormethod3 \green XX\quad \useMPgraphic{test}\quad XX \NC \NR %D \stoptabulate %D \stopbuffer %D %D \typebuffer \getbuffer -\chardef\MPcolormethod\zerocount +\newconstant\MPcolormethod % can be faster, just \appendtoks - \ctxlua{metapost.set_outer_color(\number\MPcolormethod,\number\currentcolormodel,\number\dogetattribute{color},\number\dogetattribute{transparency})}% + \ctxlua{metapost.setoutercolor(\number\MPcolormethod,\number\currentcolormodel,\number\dogetattribute{color},\number\dogetattribute{transparency})}% \to \everyMPgraphic \startMPinitializations @@ -1264,7 +1187,7 @@ %D behave in unexpected ways. \appendtoks - \doifelse\@@mpcolor\v!global{\chardef\MPcolormethod\plusone}{\chardef\MPcolormethod\zerocount}% + \doifelse\@@mpcolor\v!global{\MPcolormethod\plusone}{\MPcolormethod\zerocount}% \to \everysetupMPgraphics \setupMPgraphics |