diff options
author | Hans Hagen <pragma@wxs.nl> | 2009-07-17 13:16:00 +0200 |
---|---|---|
committer | Hans Hagen <pragma@wxs.nl> | 2009-07-17 13:16:00 +0200 |
commit | b32da8747292384893ea07a0a5659b24eb216c10 (patch) | |
tree | 375c6cd142330f37405076299c4d282b666640f9 /tex/context/base/meta-pdf.mkiv | |
parent | 18304b4851a1a4af0b4bc614e2e61673e40c62a7 (diff) | |
download | context-b32da8747292384893ea07a0a5659b24eb216c10.tar.gz |
stable 2009.07.17 13:16
Diffstat (limited to 'tex/context/base/meta-pdf.mkiv')
-rw-r--r-- | tex/context/base/meta-pdf.mkiv | 702 |
1 files changed, 115 insertions, 587 deletions
diff --git a/tex/context/base/meta-pdf.mkiv b/tex/context/base/meta-pdf.mkiv index 906633802..fa9627fbe 100644 --- a/tex/context/base/meta-pdf.mkiv +++ b/tex/context/base/meta-pdf.mkiv @@ -11,17 +11,6 @@ %C therefore copyrighted by \PRAGMA. See mreadme.pdf for %C details. -%D Formerly known as supp-pdf.tex and supp-mpe.tex. - -% \useMPgraphic{1} -% \testfeatureonce{250}{\setbox0\hbox{\convertMPtoPDF{test-mps-mpgraph.1}{1}{1}}} -% -% 8.4 : mkii, direct parsing by tex -% 11.8 : mkiv, dirty conversion (10.8 with dirty tricks) -% 14.5 : mkiv, clean conversion -% 7.4 : mkiv, simulated clean direct lua from mp -% 0.3 : time taken by tex to handle converted code - \registerctxluafile{meta-pdf}{1.003} %D We will clean up the color mess later. @@ -30,13 +19,6 @@ \unprotect -\ifx\PDFcode \undefined \let\PDFcode \gobbleoneargument \fi -\ifx\PDFcomment\undefined \def\PDFcomment#1{\PDFcode{\letterpercent\space#1}} \fi - -%D First we define a handy constant: - -\bgroup \catcode`\%=\@@other \xdef\letterpercent{\string%} \egroup - %D \macros %D {convertMPtoPDF} %D @@ -57,67 +39,25 @@ %D \convertMPtoPDF{mp-pra-1.eps}{.5}{.5} %D \stoptyping -%D \macros -%D {makeMPintoPDFobject,lastPDFMPobject} -%D -%D For experts there are a few more options. When attributes -%D are to be added, the code must be embedded in an object -%D accompanied with the appropriate directives. One can -%D influence this process with \type {\makeMPintoPDFobject}. -%D -%D This option defaults to~0, because \CONTEXT\ takes care -%D of objects at another level, which saves some bytes. -%D -%D \starttabulate[|l|l|p|] -%D \NC 0 \NC never \NC don't use an object \NC\NR -%D \NC 1 \NC always \NC always use an object \NC\NR -%D \NC 2 \NC optional \NC use object when needed \NC\NR -%D \stoptabulate -%D -%D The last object number used is avaliable in the macro -%D \type {\lastPDFMPobject}. - -\ifx\makeMPintoPDFobject \undefined \chardef\makeMPintoPDFobject \zerocount \fi -\ifx\blackoutMPgraphic \undefined \chardef\blackoutMPgraphic \plusone \fi -\ifx\everyMPtoPDFconversion\undefined \newtoks\everyMPtoPDFconversion \fi - -\let\lastPDFMPobject \!!zerocount -\let\currentPDFresources\empty -\let\setMPextensions \relax - \def\PDFMPformoffset - {\ifx\objectoffset\undefined\zeropoint\else\objectoffset\fi} - -\def\resetMPvariables#1#2#3% - {\global\let\MPwidth \!!zeropoint - \global\let\MPheight\!!zeropoint - \global\let\MPllx \!!zerocount - \global\let\MPlly \!!zerocount - \global\let\MPurx \!!zerocount - \global\let\MPury \!!zerocount - \xdef\MPxscale {#2}\ifx\MPxscale\empty\let\MPxscale\!!plusone\fi - \xdef\MPyscale {#3}\ifx\MPyscale\empty\let\MPyscale\!!plusone\fi - \xdef\MPfilename {#1}} + {\ifdefined\objectoffset\objectoffset\else\zeropoint\fi} %D The main macro: -\def\convertMPtoPDF#1#2#3% watch the transparency reset - {\resetMPvariables{#1}{#2}{#3}% - \vbox\bgroup +\def\convertMPtoPDF#1#2#3% scaling no longer supported at this level (so #2 & #3 ignored) + {\vbox\bgroup + \message{[MP to PDF]}% + \xdef\MPfilename{#1}% + \glet\MPwidth \!!zeropoint + \glet\MPheight\!!zeropoint + \glet\MPllx \!!zerocount + \glet\MPlly \!!zerocount + \glet\MPurx \!!zerocount + \glet\MPury \!!zerocount \forgetall \offinterlineskip - %\ifcase\blackoutMPgraphic\or\PDFcode{0 g 0 G}\fi % fixed in mp \setbox\scratchbox\vbox\bgroup - \setnormalcatcodes % we can be in verbatim or so - \message{[MP to PDF]}% - \startMPresources - \PDFcomment{mps begin}% - \PDFcode{q 1 0 0 1 0 0 cm}% - \ctxlua{mptopdf.convertmpstopdf("\MPfilename")}\removeunwantedspaces - \dohandleMPresettransparency % a bit messy here, should be a toks - \PDFcode{Q}% - \PDFcomment{mps end}% - \stopMPresources + \ctxlua{mptopdf.convertmpstopdf("\MPfilename")}\removeunwantedspaces \egroup \setbox\scratchbox\hbox\bgroup \hskip-\MPllx\onebasepoint @@ -135,53 +75,33 @@ \dopackageMPgraphic\scratchbox \egroup} -\let\processMPtoPDFfile\convertMPtoPDF - -%D A common hook. - -\let\MPfshowcommand\empty - -%D Objects. - -\def\dopackageMPgraphic#1% #1 = boxregister - {\ifcase\makeMPintoPDFobject\or\or\ifx\currentPDFresources\empty\else - % an existing value of 2 signals object support (set elsewhere) - \chardef\makeMPintoPDFobject\plusone - \fi\fi - \ifcase\makeMPintoPDFobject - \box#1% - \or - \scratchdimen\PDFMPformoffset\relax - \ifdim\scratchdimen>\zeropoint % compensate for error - \setbox#1\vbox spread 2\scratchdimen - {\forgetall\vss\hbox spread 2\scratchdimen{\hss\box#1\hss}\vss}% - \fi - \setMPPDFobject{\currentPDFresources}{#1}% - \ifdim\scratchdimen>\zeropoint % compensate for error - \vbox to \MPheight - {\forgetall\vss\hbox to \MPwidth{\hss\getMPPDFobject\hss}\vss}% - \else - \getMPPDFobject - \fi - \global\let\currentPDFresources\empty - \else - \box#1% - \fi} +%D Objects (move all to backend) + +% \def\dopackageMPgraphic#1% #1 = boxregister +% {\scratchdimen\PDFMPformoffset\relax +% \ifdim\scratchdimen>\zeropoint % compensate for error +% \setbox#1\vbox spread 2\scratchdimen +% {\forgetall\vss\hbox spread 2\scratchdimen{\hss\box#1\hss}\vss}% +% \fi +% \setMPPDFobject{#1}% +% \ifdim\scratchdimen>\zeropoint % compensate for error +% \vbox to \MPheight +% {\forgetall\vss\hbox to \MPwidth{\hss\getMPPDFobject\hss}\vss}% +% \else +% \getMPPDFobject +% \fi} +% +% \def\setMPPDFobject#1% boxnumber +% {\the\pdfbackendeveryxform +% \finalizeobjectbox{#1}% +% \immediate\pdfxform resources{\pdfcurrentresources}#1% +% \edef\getMPPDFobject{\noexpand\pdfrefxform\the\pdflastxform}} +% +% \let\getMPPDFobject\relax -\def\setMPPDFobject#1#2% resources boxnumber - {\ifx\pdfxform\undefined - \def\getMPPDFobject{\box#2}% - \else\ifx\pdftexversion\undefined - \def\getMPPDFobject{\box#2}% - \else\ifnum\pdftexversion<14 - \def\getMPPDFobject{\box#2}% - \else - \ifx\everyPDFxform\undefined\else\the\everyPDFxform\fi - \immediate\pdfxform resources{#1}#2% - \edef\getMPPDFobject{\noexpand\pdfrefxform\the\pdflastxform}% - \fi\fi\fi} +% we don't need to package as each page has all resources anyway -\let\getMPPDFobject\relax +\let\dopackageMPgraphic\box %D \macros %D {deleteMPgraphic, @@ -243,32 +163,6 @@ \newconditional\manyMPspecials \settrue\manyMPspecials -%D In case of \PDF, we need to prepare resourcs. - -\newtoks\MPstartresources -\newtoks\MPstopresources - -\def\startMPresources - {\the\MPstartresources} - -\def\stopMPresources - {\the\MPstopresources} - -%D Some day we may consider collecting local resources. - -\appendtoks - \global\let\currentPDFresources\empty % kind of redundant -\to \MPstartresources - -% \appendtoks -% \collectPDFresources -% \global\let\currentPDFresources\collectedPDFresources -% \to \MPstopresources - -\appendtoksonce - \the\everyPDFxform -\to \MPstopresources - %D Since colors are not subjected to transformations, we can %D only use colors as signal. In our case, we use a dummy colored %D path with a red color component of \type {0.n}, so \type @@ -278,25 +172,11 @@ \newif\ifMPcmykcolors \newif\ifMPspotcolors -\def\dohandleMPrgb #1#2#3{\revokeMPtransparencyspecial\execcolorR #1:#2:#3:0:0\od} -\def\dohandleMPcmyk#1#2#3#4{\revokeMPtransparencyspecial\execcolorC#1:#2:#3:#4:0:0\od} -\def\dohandleMPgray #1{\revokeMPtransparencyspecial\execcolorS #1:0:0\od} -\def\dohandleMPspot#1#2#3#4{\revokeMPtransparencyspecial\execcolorP#1:#2:#3:#4:0:0\od} - -%D Specials: - -\settrue \manyMPspecials \newcount\nofMParguments \let\extraMPpathcode\empty - -\def\@@MP {@@MP} -\def\@@MPSK{@MPSK@} - -\def\MPspecial{\@@MPSK\@@MPSK\gMPs\nofMParguments} - -\def\defineMPspecial#1#2% - {\setvalue{\@@MPSK\@@MPSK#1}{#2}} - -%D Special number~1 is dedicated to \CMYK\ support. If you -%D want to know why: look at this: +%D We support specials but assume that the files are somewhat simple +%D ones wo we have dropped a few. The reason is that runtime \METAPOST\ +%D processing now uses \MPLIB\ so we only need to deal with the +%D conversion here. See meta-pdh.mkiv (and older files) for more +%D details. Here we just give a few examples. %D %D \startbuffer[mp] %D fill fullcircle xyscaled (3cm,1cm) withcolor \MPcolor{test} ; @@ -326,38 +206,11 @@ %D no conversion to \RGB, %D support in \METAPOST} %D {\setupcolors[cmyk=ja,state=start]\getbuffer[cmyk]} - -\defineMPspecial{1} - {\ifMPcmykcolors - \setxvalue{\@@MPSK\gMPs6}{\noexpand\dohandleMPcmykcolor{\gMPs2}{\gMPs3}{\gMPs4}{\gMPs5}}% - \fi} - -\defineMPspecial{2} - {\ifMPspotcolors - \setxvalue{\@@MPSK\gMPs6}{\noexpand\dohandleMPspotcolor{\gMPs2}{\gMPs3}{\gMPs4}{\gMPs5}}% -% \checkMPspot{\gMPs2}{\gMPs3}{\gMPs4}{\gMPs5}% - \fi} - -% \def\checkMPspot#1#2#3#4% -% {\normalexpanded{\noexpand\resolveMPspotcolor#1 #2 #3 #4}\end -% \ifx\MPspotspace\MPresolvedspace -% \edef\MPspotspacespec{/\MPspotspace\space}% -% \doifinstringelse\MPspotspacespec\currentMPcolorspaces -% \donothing\registerMPcolorspace -% \fi} - -\let\revokeMPtransparencyspecial\relax - -\def\dohandleMPrgbcolor #1#2#3{\revokeMPtransparencyspecial\execcolorR #1:#2:#3:0:0\od} -\def\dohandleMPcmykcolor#1#2#3#4{\revokeMPtransparencyspecial\execcolorC#1:#2:#3:#4:0:0\od} -\def\dohandleMPgraycolor #1{\revokeMPtransparencyspecial\execcolorS #1:0:0\od} -\def\dohandleMPspotcolor#1#2#3#4{\revokeMPtransparencyspecial\execcolorP#1:#2:#3:#4:0:0\od} - +%D %D Transparency support used specials 60 (rgb) and 61 %D (cmyk). %D -%D \startbufferFshade - +%D \startbuffer %D u := 2cm ; path p ; p := fullcircle scaled u shifted (u/4,0); %D %D fill p rotated 90 withcolor transparent(1,.5,yellow) ; @@ -390,28 +243,6 @@ %D %D \startlinecorrection \processMPbuffer \stoplinecorrection %D -%D We save all the three components needed in one macro, -%D just to save hash space. - -\def\dohandleMPrgbtransparency #1#2#3#4#5{\execcolorR #1:#2:#3:#4:#5\od\let\revokeMPtransparencyspecial\dorevokeMPtransparencyspecial} -\def\dohandleMPcmyktransparency#1#2#3#4#5#6{\execcolorC#1:#2:#3:#4:#5:#6\od\let\revokeMPtransparencyspecial\dorevokeMPtransparencyspecial} -\def\dohandleMPgraytransparency #1#2#3{\execcolorS #1:#2:#3\od\let\revokeMPtransparencyspecial\dorevokeMPtransparencyspecial} -\def\dohandleMPspottransparency#1#2#3#4#5#6{\execcolorP#1:#2:#3:#4:#5:#6\od\let\revokeMPtransparencyspecial\dorevokeMPtransparencyspecial} - -\def\dorevokeMPtransparencyspecial - {\PDFcode{\PDFtransparencyresetidentifier\space gs}% - \let\revokeMPtransparencyspecial\relax} - -\defineMPspecial{3} % rgb - {\setxvalue{\@@MPSK\gMPs6}{\noexpand\dohandleMPrgbtransparency{\gMPs3}{\gMPs4}{\gMPs5}{\gMPs1}{\gMPs2}}} - -\defineMPspecial{4} % cmyk - {\setxvalue{\@@MPSK\gMPs7}{\noexpand\dohandleMPcmyktransparency{\gMPs3}{\gMPs4}{\gMPs5}{\gMPs6}{\gMPs1}{\gMPs2}}} - -\defineMPspecial{5} % spot - {\setxvalue{\@@MPSK\gMPs7}{\noexpand\dohandleMPspottransparency{\gMPs3}{\gMPs4}{\gMPs5}{\gMPs6}{\gMPs1}{\gMPs2}}% - }%\checkMPspot{\gMPs3}{\gMPs4}{\gMPs5}{\gMPs6}} - %D Shading is an example of a more advanced graphic feature, %D but users will seldom encounter those complications. Here %D we only show a few simple examples, but many other @@ -448,9 +279,7 @@ %D \stopuniqueMPgraphic %D \stopbuffer %D -%D \typebuffer -%D -%D \getbuffer +%D \typebuffer \getbuffer %D %D These graphics can be hooked into the overlay mechanism, %D which is available in many commands. @@ -461,9 +290,7 @@ %D \defineoverlay[demo 3][\uniqueMPgraphic {DuotoneShade}] %D \stopbuffer %D -%D \typebuffer -%D -%D \getbuffer +%D \typebuffer \getbuffer %D %D These backgrounds can for instance be applied to \type %D {\framed}: @@ -506,8 +333,6 @@ %D \stopcombination %D \stoplinecorrection %D -%D \blank -%D %D \startlinecorrection %D \startcombination[5*1] %D {\SomeShade{20}{circular}{0}{.9green}{.3green}} {circular 0} @@ -518,8 +343,6 @@ %D \stopcombination %D \stoplinecorrection %D -%D \blank -%D %D \startlinecorrection %D \startcombination[4*1] %D {\SomeShade{30}{linear}{0}{.3red}{.9red}} {linear 0} @@ -545,96 +368,7 @@ %D \NC /C1 \NC outer shade \NC \NR %D \NC /N \NC smaller values, bigger inner circles \NC \NR %D \stoptabulate - -\newcount\currentPDFshade % 0 % global (document wide) counter - -\def\dosetMPsomePDFshade#1#2% - {\immediate\pdfobj - {<</FunctionType 2 - /Domain [\gMPs1 \gMPs2] - /C0 [\MPshadeA] - /C1 [\MPshadeB] - /N \gMPs3>>}% - \immediate\pdfobj - {<</ShadingType #1 - /ColorSpace /\MPresolvedspace - /Function \the\pdflastobj\space 0 R - /Coords [\MPshadeC] - /Extend [true true]>>}% - \global\advance\currentPDFshade \plusone - \appendtoPDFdocumentshades{/Sh\the\currentPDFshade\space\the\pdflastobj\space0 R }% - \setxvalue{\@@MPSK#2}{\noexpand\dohandleMPshade{\the\currentPDFshade}}} - -\def\dosetMPlinearshade {\dosetMPsomePDFshade2}% #1 -\def\dosetMPcircularshade{\dosetMPsomePDFshade3}% #1 - -\defineMPspecial{30} - {\normalexpanded{\noexpand\resolveMPrgbcolor{\gMPs4}{\gMPs5}{\gMPs6}}\to\MPshadeA - \normalexpanded{\noexpand\resolveMPrgbcolor{\gMPs{9}}{\gMPs{10}}{\gMPs{11}}}\to\MPshadeB - \edef\MPshadeC{\gMPs7 \gMPs8 \gMPs{12} \gMPs{13}}% - \dosetMPlinearshade{\gMPs{14}}} - -\defineMPspecial{31} - {\normalexpanded{\noexpand\resolveMPrgbcolor{\gMPs4}{\gMPs5}{\gMPs6}}\to\MPshadeA - \normalexpanded{\noexpand\resolveMPrgbcolor{\gMPs{10}}{\gMPs{11}}{\gMPs{12}}}\to\MPshadeB - \edef\MPshadeC{\gMPs7 \gMPs8 \gMPs9 \gMPs{13} \gMPs{14} \gMPs{15}}% - \dosetMPcircularshade{\gMPs{16}}} - -\defineMPspecial{32} - {\normalexpanded{\noexpand\resolveMPcmykcolor{\gMPs4}{\gMPs5}{\gMPs6}{\gMPs7}}\to\MPshadeA - \normalexpanded{\noexpand\resolveMPcmykcolor{\gMPs{10}}{\gMPs{11}}{\gMPs{12}}{\gMPs{13}}}\to\MPshadeB - \edef\MPshadeC{\gMPs8 \gMPs9 \gMPs{14} \gMPs{15}}% - \dosetMPlinearshade{\gMPs{16}}} - -\defineMPspecial{33} - {\normalexpanded{\noexpand\resolveMPcmykcolor{\gMPs4}{\gMPs5}{\gMPs6}{\gMPs7}}\to\MPshadeA - \normalexpanded{\noexpand\resolveMPcmykcolor{\gMPs{11}}{\gMPs{12}}{\gMPs{13}}{\gMPs{14}}}\to\MPshadeB - \edef\MPshadeC{\gMPs8 \gMPs9 \gMPs{10} \gMPs{15} \gMPs{16} \gMPs{17}}% - \dosetMPcircularshade{\gMPs{18}}} - -\defineMPspecial{34} - {\normalexpanded{\noexpand\resolveMPspotcolor{\gMPs4}{\gMPs5}{\gMPs6}{\gMPs7}}\to\MPshadeA - \normalexpanded{\noexpand\resolveMPspotcolor{\gMPs{10}}{\gMPs{11}}{\gMPs{12}}{\gMPs{13}}}\to\MPshadeB - \edef\MPshadeC{\gMPs8 \gMPs9 \gMPs{14} \gMPs{15}}% - \dosetMPlinearshade{\gMPs{16}}} - -\defineMPspecial{35} - {\normalexpanded{\noexpand\resolveMPcmykcolor{\gMPs4}{\gMPs5}{\gMPs6}{\gMPs7}}\to\MPshadeA - \normalexpanded{\noexpand\resolveMPcmykcolor{\gMPs{11}}{\gMPs{12}}{\gMPs{13}}{\gMPs{14}}}\to\MPshadeB - \edef\MPshadeC{\gMPs8 \gMPs9 \gMPs{10} \gMPs{15} \gMPs{16} \gMPs{17}}% - \dosetMPcircularshade{\gMPs{18}}} - -\newconditional\ignoreMPpath - -\def\dohandleMPshade#1% - {\revokeMPtransparencyspecial - \settrue\ignoreMPpath - \def\extraMPpathcode{/Sh#1 sh Q}% - \chardef\finiMPpath\zerocount - \PDFcode{q /Pattern cs}} - -\defineMPspecial{10} - {\setxvalue{\@@MPSK\gMPs8}% - {\noexpand\handleMPfigurespecial{\gMPs1}{\gMPs2}{\gMPs3}{\gMPs4}{\gMPs5}{\gMPs6}{\gMPs7}{\gMPs8}}} - -\def\handleMPfigurespecial#1#2#3#4#5#6#7#8% todo : combine with ext fig - {\global\letvalue{\@@MPSK#8}\empty - \vbox to \zeropoint - {\vss - \hbox to \zeropoint - {\ifcase\pdfoutput\or % will be hooked into the special driver - \doiffileelse{#7} - {\doifundefinedelse{mps:x:#7} - {\immediate\pdfximage\!!width\onebasepoint\!!height\onebasepoint{#7}% - \setxvalue{mps:x:#7}{\pdfrefximage\the\pdflastximage}}% - {\message{[reusing figure #7]}}% - \PDFcode{q #1 #2 #3 #4 #5 #6 cm}% - \rlap{\getvalue{mps:x:#7}}% - \PDFcode{Q}} - {\message{[unknown figure #7]}}% - \fi - \hss}}} - +%D %D An example of using both special features is the %D following. %D @@ -653,294 +387,88 @@ %D \stopMPpage %D \stoptyping -\defineMPspecial{20} - {\setxvalue{\@@MPSK\gMPs6}% - {\noexpand\handleMPhyperlink{\gMPs1}{\gMPs2}{\gMPs3}{\gMPs4}{\gMPs5}{\gMPs6}}} - -\def\handleMPhyperlink#1#2#3#4#5#6% - {\global\letvalue{\@@MPSK#6}\empty - \setbox\scratchbox\hbox - {\setbox\scratchbox\null - \wd\scratchbox\dimexpr-#1\onebasepoint+#3\onebasepoint\relax - \ht\scratchbox\dimexpr-#2\onebasepoint+#4\onebasepoint\relax - \incolorfalse - \gotobox{\box\scratchbox}[#5]}% - \setbox\scratchbox\hbox - {\hskip\dimexpr\MPxoffset\onebasepoint+#1\onebasepoint\relax - \raise\dimexpr\MPyoffset\onebasepoint+#2\onebasepoint\relax - \box\scratchbox}% - \smashbox\scratchbox - \box\scratchbox} - -%D This special (number 50) passes positions to a tex file. -%D This method uses a two||pass approach an (mis|)|used the -%D context positioning macros. In \type {core-pos} we will -%D implement the low level submacro needed. -%D -%D \startbuffer -%D \definelayer[test] -%D -%D \setlayer -%D [test] -%D [x=\MPx{somepos-1},y=\MPy{somepos-1}] -%D {Whatever we want here!} -%D -%D \setlayer -%D [test] -%D [x=\MPx{somepos-2},y=\MPy{somepos-2}] -%D {Whatever we need there!} -%D -%D \startuseMPgraphic{oeps} -%D draw fullcircle scaled 6cm withcolor red ; -%D register ("somepos-1",1cm,2cm,center currentpicture) ; -%D register ("somepos-2",4cm,3cm,(-1cm,-2cm)) ; -%D \stopuseMPgraphic -%D -%D \framed[background=test,offset=overlay]{\useMPgraphic{oeps}} -%D \stopbuffer -%D -%D \typebuffer -%D -%D Here the width and height are not realy used, but one can -%D imagine situations where tex has to work with values -%D calculated by \METAPOST. -%D -%D \startlinecorrection -%D \getbuffer -%D \stoplinecorrection -%D -%D Later we will implement a more convenient macro: -%D -%D \starttyping -%D \setMPlayer [test] [somepos-1] {Whatever we want here!} -%D \setMPlayer [test] [somepos-2] {Whatever we need there!} -%D \stoptyping - -\defineMPspecial{50} % x y width height label - {\dosavepositionwhd - {\gMPs5}% - {0}% - {\the\dimexpr-\MPllx\onebasepoint+\gMPs1\onebasepoint\relax} - {\the\dimexpr\gMPs2\onebasepoint-\scratchdimen+\MPury\onebasepoint\relax}% scratchdimen ? - {\the\dimexpr\gMPs3\onebasepoint\relax}% - {\the\dimexpr\gMPs4\onebasepoint\relax}% - {0pt}} - -%D A few auxiliary macros. This will move to colo-ini. - -\def\MPgrayspace{DeviceGray} -\def\MPrgbspace {DeviceRGB} -\def\MPcmykspace{DeviceCMYK} -\let\MPspotspace\MPgrayspace - -\def\MPcmykBlack{0 0 0 0} -\def\MPcmykWhite{0 0 0 1} - -\def\startMPcolorresolve - {\bgroup - \def\dostartgraycolormode##1% - {\global\let\MPresolvedspace\MPgrayspace - \xdef\MPresolvedcolor{##1}}% - \def\dostartrgbcolormode ##1##2##3% - {\global\let\MPresolvedspace\MPrgbspace - \xdef\MPresolvedcolor{##1 ##2 ##3}}% - \def\dostartcmykcolormode##1##2##3##4% - {\global\let\MPresolvedspace\MPcmykspace - \xdef\MPresolvedcolor{##1 ##2 ##3 ##4}}% - \def\dostartspotcolormode##1##2% - {\global\let\MPspotspace\empty % left over ? - \xdef\MPresolvedspace{##1}% - \xdef\MPresolvedcolor{##2}% - \global\let\MPspotspace\MPresolvedspace}% signal - \dostartgraycolormode\!!zerocount} % kind of hackery initialization - -\let\stopMPcolorresolve\egroup - -\def\resolveMPrgbcolor#1#2#3\to#4% - {\startMPcolorresolve - \execcolorR#1:#2:#3:0:0\od - \stopMPcolorresolve - \let#4\MPresolvedcolor} - -\def\resolveMPcmykcolor#1#2#3#4\to#5% - {\startMPcolorresolve - \execcolorC#1:#2:#3:#4:0:0\od - \stopMPcolorresolve - \let#5\MPresolvedcolor} - -\def\resolveMPgraycolor#1\end\to#2% - {\startMPcolorresolve - \execcolorS#1:0:0\od - \stopMPcolorresolve - \let#2\MPresolvedcolor} - -\def\resolveMPspotcolor#1#2#3#4\end\to#5% - {\startMPcolorresolve - \ifnum#2>\plusone - \checkmultitonecolor{#1}% - \fi - \execcolorP#1:#2:#3:#4:0:0\od - \stopMPcolorresolve - \let#5\MPresolvedcolor} - \startMPinitializations mp_shade_version := 2 ; \stopMPinitializations -% will be done better - -\def\MPStextext#1#2#3#4#5% if we clean up this plugin model, we can - {\def\MPtextdata{#3}% % delegate the splitter to lua + redesign - \def\MPtextsize{#2}% - \def\lastMPmoveX{#4}% - \def\lastMPmoveY{#5}% - \defconvertedcommand\MPtextdata\MPtextdata % no edef - \splitstring\MPtextdata\at::::\to\MPtexttag\and\MPtextnumber - \executeifdefined{handleMPtext\MPtexttag} - {\setbox\scratchbox\hbox - {\font\temp=#1\space at #2\onebasepoint - \let\c\char - \temp - \MPfshowcommand{#3}}% - \setbox\scratchbox\hbox - {\hskip#4\onebasepoint - \raise#5\onebasepoint - \box\scratchbox}% - \smashbox\scratchbox - \box\scratchbox}} - -%D We save the special variables on a stack. It's not that -%D fast, but it make implementing the special more convenient. - -\def\MPSbegin - {\nofMParguments\zerocount} - -\def\MPSend - {\csname\MPspecial\endcsname} - -\def\MPSset - {\advance\nofMParguments\plusone - \expandafter\def\csname\@@MP\number\nofMParguments\endcsname} +%D This is done much cleaner in \MPLIB. -\def\gMPs#1{\csname\@@MP\number#1\endcsname} +% %D A common hook. +% +% \let\MPfshowcommand\empty +% +% \def\MPStextext#1#2#3#4#5% if we clean up this plugin model, we can +% {\def\MPtextdata{#3}% % delegate the splitter to lua + redesign +% \def\MPtextsize{#2}% +% \def\lastMPmoveX{#4}% +% \def\lastMPmoveY{#5}% +% \defconvertedcommand\MPtextdata\MPtextdata % no edef +% \splitstring\MPtextdata\at::::\to\MPtexttag\and\MPtextnumber +% \executeifdefined{handleMPtext\MPtexttag} +% {\setbox\scratchbox\hbox +% {\font\temp=#1\space at #2\onebasepoint +% \let\c\char +% \temp +% \MPfshowcommand{#3}}% +% \setbox\scratchbox\hbox +% {\hskip#4\onebasepoint +% \raise#5\onebasepoint +% \box\scratchbox}% +% \smashbox\scratchbox +% \box\scratchbox}} + +\unexpanded\def\MPStextext#1#2#3#4#5% if we clean up this plugin model, we can + {\setbox\scratchbox\hbox + {\font\temp=#1\space at #2\onebasepoint \let\c\char \temp #3}% + \setbox\scratchbox\hbox + {\hskip#4\onebasepoint \raise#5\onebasepoint \box\scratchbox}% + \smashbox\scratchbox + \box\scratchbox} %D The boundingbox. \def\MPSboundingbox#1#2#3#4% - {\xdef\MPllx{#1}% - \xdef\MPlly{#2}% - \xdef\MPurx{#3}% - \xdef\MPury{#4}% + {\xdef\MPllx{#1}\xdef\MPlly{#2}\xdef\MPurx{#3}\xdef\MPury{#4}% \xdef\MPwidth {\the\dimexpr#3\onebasepoint-#1\onebasepoint\relax}% \xdef\MPheight{\the\dimexpr#4\onebasepoint-#2\onebasepoint\relax}} \MPSboundingbox0000 -\def\MPSspecial#1#2% - {\csname\@@MPSK#2\endcsname} - -%D A path is (in most cases) just a sequence of \PDF\ commands. - -% \newcontitional\ignoreMPpath - -\def\MPSpath - {\PDFcode} - -\def\MPScode % hack, will be improved - {\ifconditional\ignoreMPpath - \PDFcode{h W n}% - \ifx\extraMPpathcode\empty\else - \PDFcode{\extraMPpathcode}% - \let\extraMPpathcode\empty - \fi - \setfalse\ignoreMPpath - \expandafter\gobbleoneargument - \else - \expandafter\PDFcode - \fi} - -\let\MPSrgb \dohandleMPrgb -\let\MPScmyk\dohandleMPcmyk -\let\MPSgray\dohandleMPgray -\let\MPSspot\dohandleMPspot - %D Test code: - -% \startMPcode -% fill fullcircle scaled 3cm withcolor red ; -% fill fullcircle scaled 2cm withcolor green ; -% fill fullcircle scaled 1cm withcolor blue ; -% currentpicture := currentpicture shifted (-4cm,0) ; -% fill fullcircle scaled 3cm withcolor cmyk(0,0,1,0) ; -% fill fullcircle scaled 2cm withcolor cmyk(0,1,0,0) ; -% fill fullcircle scaled 1cm withcolor cmyk(0,0,1,0) ; -% currentpicture := currentpicture shifted (-4cm,0) ; -% draw fullcircle scaled 3cm dashed evenly ; -% draw fullcircle scaled 2cm dashed withdots ; -% draw origin withpen pencircle scaled 3mm; -% currentpicture := currentpicture shifted (-4cm,0) ; -% fill fullcircle scaled 2cm shifted (-.5cm,+.5cm) withcolor transparent(1,.5,red); -% fill fullcircle scaled 2cm shifted (-.5cm,-.5cm) withcolor transparent(1,.5,red); -% fill fullcircle scaled 2cm shifted (+.5cm,+.5cm) withcolor transparent(1,.5,green); -% fill fullcircle scaled 2cm shifted (+.5cm,-.5cm) withcolor transparent(1,.5,cmyk(1,0,1,.5)); -% currentpicture := currentpicture shifted (12cm,-4cm) ; -% draw "o e p s" infont defaultfont scaled 2 shifted (-1cm,0) ; -% currentpicture := currentpicture shifted (-4cm,0) ; -% % bug: shift -% draw fullcircle scaled 3cm withpen pencircle yscaled 3mm xscaled 2mm rotated 30 ; -% draw fullcircle scaled 2cm withpen pencircle yscaled 3mm xscaled 2mm rotated 20 withcolor red ; -% filldraw fullcircle scaled 1cm withpen pencircle yscaled 3mm xscaled 2mm rotated 10 withcolor green ; -% currentpicture := currentpicture shifted (-4cm,0) ; -% % shade cannot handle shift -% circular_shade(fullcircle scaled 3cm,0,.2red,.9green) ; -% circular_shade(fullcircle scaled 3cm shifted(+4cm,0),0,cmyk(1,0,0,0),cmyk(0,1,0,0)) ; -% filldraw boundingbox currentpicture enlarged -3cm withpen pencircle scaled 1pt withcolor .5white ; -% \stopMPcode - -% We cannot use attributes for switching colors in mp literals because -% grouping (qQ) interferes. - -\ifx\colorversion\undefined \else \ifnum\colorversion>\plusone - - \def\dohandleMPgraycolor #1{\ctxlua{ctx.pdffinishtransparency() - ctx.pdfgrayliteral(\the\currentcolormodel,#1)}} - \def\dohandleMPrgbcolor #1#2#3{\ctxlua{ctx.pdffinishtransparency() - ctx.pdfrgbliteral (\the\currentcolormodel,#1,#2,#3)}} - \def\dohandleMPcmykcolor#1#2#3#4{\ctxlua{ctx.pdffinishtransparency() - ctx.pdfcmykliteral(\the\currentcolormodel,#1,#2,#3,#4)}} - \def\dohandleMPspotcolor#1#2#3#4{\ctxlua{ctx.pdffinishtransparency() - ctx.pdfspotliteral(\the\currentcolormodel,"#1",#2,"#3","#4")}} - - % we can combine the next calls - - \def\dohandleMPgraytransparency #1#2#3{\ctxlua{ctx.pdfgrayliteral(\the\currentcolormodel,#1) - ctx.pdftransparencyliteral(#2,#3)}} - \def\dohandleMPrgbtransparency #1#2#3#4#5{\ctxlua{ctx.pdfrgbliteral (\the\currentcolormodel,#1,#2,#3) - ctx.pdftransparencyliteral(#4,#5)}} - \def\dohandleMPcmyktransparency#1#2#3#4#5#6{\ctxlua{ctx.pdfcmykliteral(\the\currentcolormodel,#1,#2,#3,#4) - ctx.pdftransparencyliteral(#5,#6)}} - \def\dohandleMPspottransparency#1#2#3#4#5#6{\ctxlua{ctx.pdfspotliteral(\the\currentcolormodel,"#1",#2,"#3","#4") - ctx.pdftransparencyliteral(#5,#6)}} - - \def\dohandleMPresettransparency {\ctxlua{ctx.pdffinishtransparency()}} - - \def\resolveMPgraycolor #1\to#2{\ctxlua{ctx.resolvempgraycolor("\strippedcsname#2","MPresolvedspace",\number\currentcolormodel,#1)}} - \def\resolveMPrgbcolor #1#2#3\to#4{\ctxlua{ctx.resolvemprgbcolor ("\strippedcsname#4","MPresolvedspace",\number\currentcolormodel,#1,#2,#3)}} - \def\resolveMPcmykcolor#1#2#3#4\to#5{\ctxlua{ctx.resolvempcmykcolor("\strippedcsname#5","MPresolvedspace",\number\currentcolormodel,#1,#2,#3,#4)}} - - \def\resolveMPspotcolor#1#2#3#4\to#5% unchecked - {\ctxlua{ctx.resolvempspotcolor("\strippedcsname#5","MPresolvedspace",\number\currentcolormodel,"#1",#2,"#3","#4")}% - \xdef\MPresolvedspace{#1}% - \xdef\MPresolvedcolor{#4}% - \global\let\MPspotspace\MPresolvedspace} - - % used as callers - - \let\MPSgray\dohandleMPgraycolor - \let\MPSrgb \dohandleMPrgbcolor - \let\MPScmyk\dohandleMPcmykcolor - \let\MPspot \dohandleMPspotcolor - -\fi \fi +%D +%D \startbuffer +%D \startMPcode +%D fill fullcircle scaled 3cm withcolor red ; +%D fill fullcircle scaled 2cm withcolor green ; +%D fill fullcircle scaled 1cm withcolor blue ; +%D currentpicture := currentpicture shifted (-4cm,0) ; +%D fill fullcircle scaled 3cm withcolor cmyk(0,0,1,0) ; +%D fill fullcircle scaled 2cm withcolor cmyk(0,1,0,0) ; +%D fill fullcircle scaled 1cm withcolor cmyk(0,0,1,0) ; +%D currentpicture := currentpicture shifted (-4cm,0) ; +%D draw fullcircle scaled 3cm dashed evenly ; +%D draw fullcircle scaled 2cm dashed withdots ; +%D draw origin withpen pencircle scaled 3mm; +%D currentpicture := currentpicture shifted (-4cm,0) ; +%D fill fullcircle scaled 2cm shifted (-.5cm,+.5cm) withcolor transparent(1,.5,red); +%D fill fullcircle scaled 2cm shifted (-.5cm,-.5cm) withcolor transparent(1,.5,red); +%D fill fullcircle scaled 2cm shifted (+.5cm,+.5cm) withcolor transparent(1,.5,green); +%D fill fullcircle scaled 2cm shifted (+.5cm,-.5cm) withcolor transparent(1,.5,cmyk(1,0,1,.5)); +%D currentpicture := currentpicture shifted (12cm,-4cm) ; +%D draw "o e p s" infont defaultfont scaled 2 shifted (-1cm,0) ; +%D currentpicture := currentpicture shifted (-4cm,0) ; +%D % bug: shift +%D draw fullcircle scaled 3cm withpen pencircle yscaled 3mm xscaled 2mm rotated 30 ; +%D draw fullcircle scaled 2cm withpen pencircle yscaled 3mm xscaled 2mm rotated 20 withcolor red ; +%D filldraw fullcircle scaled 1cm withpen pencircle yscaled 3mm xscaled 2mm rotated 10 withcolor green ; +%D currentpicture := currentpicture shifted (-4cm,0) ; +%D % shade cannot handle shift +%D circular_shade(fullcircle scaled 3cm,0,.2red,.9green) ; +%D circular_shade(fullcircle scaled 3cm shifted(+4cm,0),0,cmyk(1,0,0,0),cmyk(0,1,0,0)) ; +%D filldraw boundingbox currentpicture enlarged -3cm withpen pencircle scaled 1pt withcolor .5white ; +%D \stopMPcode +%D \stopbuffer +%D +%D \typebuffer \startlinecorrection \getbuffer \stoplinecorrection \protect \endinput |