David Arnold wrote:
Hans,
In mfun-004.tex, I find:
\startuseMPgraphic{axis} tickstep := 1cm ; ticklength := 2mm ; drawticks unitsquare xscaled 4cm yscaled 3cm shifted (-1cm,-1cm) ; tickstep := tickstep/2 ; ticklength := ticklength/2 ; drawticks unitsquare xscaled 4cm yscaled 3cm shifted (-1cm,-1cm) ; \stopuseMPgraphic
\startlinecorrection[blank] \startMPcode \includeMPgraphic{axis} drawpoint "1cm,1.5cm" ; \stopMPcode \stoplinecorrection
If the axis graphic is going to be "reused" over and over again, why didn't you use \startreusableMPgraphic?
in that case i should have used overlays or so since re-use is not part of mp itself (when we use tex for such an overlay one needs to position them); the problem in the current implementation is that the reference points are not saved, so you need a patched \douseMPbox % \def\douseMPbox#1% % {\global\advance\MPobjectcounter\plusone % \setobject{MP}{\number\MPobjectcounter}\vbox % {\forgetall % \loadMPgraphic{\MPgraphicfile.\the\currentMPgraphic}{}% % \deallocateMPslot\currentMPgraphic % \placeMPgraphic}% % \setxvalue{#1}% % {\noexpand\dosetMPboxXY{\MPllx}{\MPlly}{\MPurx}{\MPury}% % \noexpand\getobject{MP}{\number\MPobjectcounter}}} % % \def\dosetMPboxXY#1#2#3#4% % {\xdef\MPllx{#1}\xdef\MPlly{#2}\xdef\MPurx{#3}\xdef\MPury{#4}}% % % less memory: \def\douseMPbox#1% {\global\advance\MPobjectcounter\plusone \setobject{MP}{\number\MPobjectcounter}\vbox {\forgetall \loadMPgraphic{\MPgraphicfile.\the\currentMPgraphic}{}% \deallocateMPslot\currentMPgraphic \placeMPgraphic}% \setxvalue{#1}% {\noexpand\dodouseMPbox{\number\MPobjectcounter}{\MPllx}{\MPlly}{\MPurx}{\MPury}}} \def\dodouseMPbox#1#2#3#4#5% space delimiting would save some tokens {\xdef\MPllx{#2}% but it's not worth the effort and looks \xdef\MPlly{#3}% ugly as well \xdef\MPurx{#4}% \xdef\MPury{#5}% \getobject{MP}{#1}} \starttext \setupcolors[state=start] \startreusableMPgraphic{axis} tickstep := 1cm ; ticklength := 2mm ; drawticks unitsquare xscaled 4cm yscaled 3cm shifted (-1cm,-1cm) ; tickstep := tickstep/2 ; ticklength := ticklength/2 ; drawticks unitsquare xscaled 4cm yscaled 3cm shifted (-1cm,-1cm) ; \stopreusableMPgraphic \startuseMPgraphic{one} drawpoint "1cm,1.5cm" ; \stopuseMPgraphic \definelayer[mp][preset=mp] \setlayer[mp]{\reuseMPgraphic{axis}} \setlayer[mp]{\useMPgraphic{one}} \ruledhbox{\flushlayer[mp]} \startuseMPgraphic{two} drawpoint "1.5cm,2.0cm" ; \stopuseMPgraphic \definelayer[mp][preset=mp] \setlayer[mp]{\reuseMPgraphic{axis}} \setlayer[mp]{\useMPgraphic{two}} \ruledhbox{\flushlayer[mp]} \definelayer[davan][preset=mp] \setlayer[davan]{\reuseMPgraphic{axis}} \setlayer[davan]{\useMPgraphic{one}} \setlayer[davan]{\useMPgraphic{two}} \setlayerframed[davan][x=0cm,y=0cm,location=middle,align=middle]{\blue Origin} \setlayerframed[davan][x=1cm,y=1cm]{\red Interesting} \ruledhbox{\flushlayer[davan]} \stoptext I leave it to you to figure out what happens here -) (i'll move the patch to the core) Hans