summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/mlib-pps.mkiv
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/context/base/mlib-pps.mkiv')
-rw-r--r--Master/texmf-dist/tex/context/base/mlib-pps.mkiv136
1 files changed, 112 insertions, 24 deletions
diff --git a/Master/texmf-dist/tex/context/base/mlib-pps.mkiv b/Master/texmf-dist/tex/context/base/mlib-pps.mkiv
index 357f85b1a1f..cb6120066af 100644
--- a/Master/texmf-dist/tex/context/base/mlib-pps.mkiv
+++ b/Master/texmf-dist/tex/context/base/mlib-pps.mkiv
@@ -5,7 +5,7 @@
%D subtitle=Basics,
%D author=Hans Hagen,
%D date=\currentdate,
-%D copyright=PRAGMA]
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
%C
%C This module is part of the \CONTEXT\ macro||package and is
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
@@ -17,44 +17,132 @@
%D Todo: catch nested graphics like external figures with dummies.
-% \newtoks\everyMPLIBtext % not yet used
+% todo: figure out why this is shifted
+%
+% \setupbodyfont[palatino]
+%
+% \starttext
+% \startMPpage
+% draw textext("123") ;
+% \stopMPpage
+% \stoptext
+%
+% A slightly larger picture works ok so maybe there is some kind
+% of interference with the page builder.
-% \appendtoks
-% \let\handleuseMPgraphic \thirdofthreearguments
-% \let\handlereusableMPgraphic\thirdofthreearguments
-% \to \everyMPLIBtext
+\newbox \MPtextbox
+\newtoks\everyMPLIBsettext % not used
-% this will move !
+\newconditional\MPLIBtextgetdone
-% Instead of preallocated boxes we now use a table of lists so that we
-% have no limitation. Typically an example of a next version solution
-% due to \LUATEX\ evolving.
+% \def\MPLIBsettext#1% #2%
+% {\dowithnextbox{\ctxlua{metapost.settext(\number\nextbox,#1)}}\hbox}
-\newbox \MPtextbox
-\newtoks\everyMPLIBsettext
+\def\MPLIBsettext#1% #2%
+ {\ifconditional\MPLIBtextgetdone
+ \else
+ \cldcontext{metapost.tex.get()}% MPenvironments are depricated
+ \settrue\MPLIBtextgetdone % no \global needed
+ \fi
+ \dowithnextbox{\ctxlua{metapost.settext(\number\nextbox,#1)}}\hbox}
+
+\def\MPLIBgettextscaled#1#2#3% why a copy .. can be used more often
+ {\ctxlua{metapost.gettext(\number\MPtextbox,#1)}%
+ \vbox to \zeropoint{\vss\hbox to \zeropoint{\scale[\c!sx=#2,\c!sy=#3]{\raise\dp\MPtextbox\box\MPtextbox}\forcecolorhack\hss}}}
\def\MPLIBfigure#1#2%
{\setbox\scratchbox\hbox{\externalfigure[#1][\c!mask=#2]}%
\ctxlua{metapost.edefsxsy(\number\wd\scratchbox,\number\ht\scratchbox,0)}%
\vbox to \zeropoint{\vss\hbox to \zeropoint{\scale[\c!sx=\sx,\c!sy=\sy]{\box\scratchbox}\hss}}}
-\def\MPLIBsettext#1% #2%
- {\dowithnextbox{\ctxlua{metapost.settext(\number\nextbox,#1)}}\hbox}
-
-\def\MPLIBgettextscaled#1#2#3% why a copy .. can be used more often
- {\ctxlua{metapost.gettext(\number\MPtextbox,#1)}% we need the colorhack or else the color backend does not sync
- \vbox to \zeropoint{\vss\hbox to \zeropoint{\scale[\c!sx=#2,\c!sy=#3]{\raise\dp\MPtextbox\box\MPtextbox}\forcecolorhack\hss}}}
-
-\def\MPLIBgraphictext#1%
+% horrible:
+
+\def\MPLIBgettextscaledcm#1#2#3#4#5#6#7#8#9% 2-7: sx,rx,ry,sy,tx,ty
+ {\ctxlua{metapost.gettext(\number\MPtextbox,#1)}%
+ \setbox\MPbox\hbox\bgroup
+ \dotransformnextbox{#2}{#3}{#4}{#5}{#6}{#7}% does push pop
+ \vbox to \zeropoint\bgroup
+ \vss
+ \hbox to \zeropoint \bgroup
+ \scale[\c!sx=#8,\c!sy=#9]{\raise\dp\MPtextbox\box\MPtextbox}%
+ \forcecolorhack % needed ? already in the scale macro
+ % % This gives: LuaTeX warning: Misplaced \pdfrestore .. don't ask me why.
+ %
+ % \dostartscaling{#8}{#9}%
+ % \raise\dp\MPtextbox\box\MPtextbox
+ % \dostopscaling
+ \hss
+ \egroup
+ \egroup
+ \egroup
+ \smashbox\MPbox
+ \box\MPbox}
+
+\def\MPLIBgraphictext#1% use at mp end
{\startTEXpage[\c!scale=10000]#1\stopTEXpage}
-\def\MPLIBpositionwhd#1#2#3#4#5%
- {\dosavepositionwhd{#1}{0}{#2sp}{#3sp}{#4sp}{#5sp}{0sp}}
+%D \startbuffer
+%D \definelayer[test]
+%D
+%D \setlayerframed
+%D [test]
+%D [x=\MPx{somepos-1},y=\MPy{somepos-1}]
+%D [width=\MPw{somepos-1},height=\MPh{somepos-1}]
+%D {Whatever we want here!}
+%D
+%D \setlayerframed
+%D [test]
+%D [x=\MPx{somepos-2},y=\MPy{somepos-2}]
+%D [width=\MPw{somepos-2},height=\MPh{somepos-2}]
+%D {Whatever we need there!}
+%D
+%D \startuseMPgraphic{oeps}
+%D draw fullcircle scaled 6cm withcolor red ;
+%D register ("somepos-1",5cm,1cm,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 \startlinecorrection \getbuffer \stoplinecorrection
+
+\def\MPLIBpositionwhd#1#2#3#4#5% bp !
+ {\dosavepositionwhd{#1}\zerocount{#2\onebasepoint}{#3\onebasepoint}{#4\onebasepoint}{#5\onebasepoint}\zeropoint}
\def\MPLIBextrapass#1%
- {\ctxlua{metapost.graphic_extra_pass(#1)}}
+ {\ctxlua{metapost.graphic_extra_pass("#1")}}
+
+% \def\MPLIBresettexts
+% {\ctxlua{metapost.resettextexts()}}
\def\MPLIBresettexts
- {\ctxlua{metapost.resettextexts()}}
+ {\ctxlua{metapost.resettextexts()}%$
+ \setfalse\MPLIBtextgetdone}
+
+%D Experiment
+
+\def\doMPLIBstopgroup#1#2#3#4#5#6% some day this might happen elsewhere
+ {\egroup
+ \setbox\scratchbox\hbox{\hskip\onebasepoint\box\scratchbox}% weird correction
+ \wd\scratchbox \dimexpr#5\onebasepoint-#3\onebasepoint+2\onebasepoint\relax
+ \ht\scratchbox #6\onebasepoint
+ \dp\scratchbox-#4\onebasepoint
+ \pdfxform
+ attr {/Group << /S /Transparency /I \ifnum#1=1 true \else false \fi /K \ifnum#1=1 true \else false \fi >>}
+ resources {\pdfbackendcurrentresources}
+ \scratchbox
+ \setbox\scratchbox\hbox\bgroup\hskip-\onebasepoint\pdfrefxform\pdflastxform\egroup
+ \setbox\scratchbox\hbox\bgroup\hskip-\onebasepoint\pdfrefxform\pdflastxform\egroup
+ \wd\scratchbox\zeropoint
+ \ht\scratchbox\zeropoint
+ \dp\scratchbox\zeropoint
+ \box\scratchbox
+ \endgroup}
+
+\def\MPLIBstartgroup#1#2#3#4#5#6% isolated 0/1, knockout 0/1 llx lly urx ury
+ {\begingroup
+ \setbox\scratchbox\hbox\bgroup
+ \def\MPLIBstopgroup{\doMPLIBstopgroup{#1}{#2}{#3}{#4}{#5}{#6}}}
\protect \endinput