Re: [NTG-context] MP figure continuation
On Fri, 6 Jan 2023 15:43:07 +0100 Alexandre Christe via ntg-context wrote: > Dear list, > > Is there a way to "continue" an MP figure? Like keeping the axes, > etc. and just adding code to the figure? > > Maybe I missed something, otherwise I'd find it super useful. > > Thanks in advance and happy new year, > Alex Another solution is to save the picture: \startMPcode draw fullcircle scaled 1cm ; picture mypicture ; mypicture := currentpicture ; \stopMPcode Then, the next call to \startMPcode (or whatever you use) will have access to the saved picture. \startMPcode currentpicture := mypicture ; draw unitsquare scaled 1cm withcolor red ; \stopMPcode currentpicture is reset for each MP call. Of course, you must not use save mypicture ; picture mypicture ; because that will make it local. Alan ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context webpage : https://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : https://contextgarden.net ___
Re: [NTG-context] MP figure continuation
Aye, thanks Mikael and Gavin. Hard 2023 re-start... Le ven. 6 janv. 2023 à 15:58, Gavin a écrit : > Hi Alex, > > > Is there a way to "continue" an MP figure? Like keeping the axes, etc. > and just adding code to the figure? > > Buffers might be what you want. From the MetaFun manual: > > > Buffers can be used to stepwise build graphics. By putting code in > multiple buffers, you can selectively process this code. [p.124] > > http://www.pragma-ade.nl/general/manuals/metafun-p.pdf > > Hope that helps. > > Gavin ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context webpage : https://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : https://contextgarden.net ___
Re: [NTG-context] MP figure continuation
Hi Alex, > Is there a way to "continue" an MP figure? Like keeping the axes, etc. and > just adding code to the figure? Buffers might be what you want. From the MetaFun manual: > Buffers can be used to stepwise build graphics. By putting code in multiple > buffers, you can selectively process this code. [p.124] http://www.pragma-ade.nl/general/manuals/metafun-p.pdf Hope that helps. Gavin ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context webpage : https://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : https://contextgarden.net ___
Re: [NTG-context] MP figure continuation
On Fri, Jan 6, 2023 at 3:43 PM Alexandre Christe via ntg-context wrote: > > Dear list, > > Is there a way to "continue" an MP figure? Like keeping the axes, etc. and > just adding code to the figure? > > Maybe I missed something, otherwise I'd find it super useful. > > Thanks in advance and happy new year, > Alex Hi Alex, Maybe there are other ways, but one can use \includeMPgraphic. One simple example given below. /Mikael \starttext \startuseMPgraphic{vanderwaerdenbas} u:=3cm ; def vdwbas(expr x) = abs(x-round x) enddef ; def vdw(expr n,x) = if n = 0: vdwbas(x) else: vdwbas(x*pow(4,n))/pow(4,n) fi enddef ; path xaxis, yaxis ; xaxis = ((-1.1,0)--(1.1,0)) scaled u ; yaxis = ((0,-0.1)--(0,0.6)) scaled u ; drawarrow xaxis withpen pencircle scaled 0.25 ; drawarrow yaxis withpen pencircle scaled 0.25 ; \stopuseMPgraphic \startuseMPgraphic{vanderwaerden0} \includeMPgraphic{vanderwaerdenbas} draw function(1,"x","vdw(0,x)",epsed(-1),epsed(1),1/1000) scaled u ; \stopuseMPgraphic \startuseMPgraphic{vanderwaerden1} \includeMPgraphic{vanderwaerdenbas} draw function(1,"x","vdw(1,x)",epsed(-1),epsed(1),1/1000) scaled u ; \stopuseMPgraphic \startuseMPgraphic{vanderwaerden2} \includeMPgraphic{vanderwaerdenbas} draw function(1,"x","vdw(2,x)",epsed(-1),epsed(1),1/1000) scaled u ; \stopuseMPgraphic \startuseMPgraphic{vanderwaerden3} \includeMPgraphic{vanderwaerdenbas} draw function(1,"x","vdw(3,x)",epsed(-1),epsed(1),1/1000) scaled u ; \stopuseMPgraphic \startuseMPgraphic{vanderwaerden01} \includeMPgraphic{vanderwaerdenbas} draw function(1,"x","vdw(1,x)+vdw(0,x)",epsed(-1),epsed(1),1/1000) scaled u ; \stopuseMPgraphic \startuseMPgraphic{vanderwaerden012} \includeMPgraphic{vanderwaerdenbas} draw function(1,"x","vdw(2,x)+vdw(1,x)+vdw(0,x)",epsed(-1),epsed(1),1/1000) scaled u ; \stopuseMPgraphic \startuseMPgraphic{vanderwaerden0123} \includeMPgraphic{vanderwaerdenbas} draw function(1,"x","vdw(3,x)+vdw(2,x)+vdw(1,x)+vdw(0,x)",epsed(-1),epsed(1),1/1000) scaled u ; \stopuseMPgraphic \startplacefigure[reference=fig:vdw] \startcombination[nx=2,ny=4] {\useMPgraphic{vanderwaerden0}} {(a)} {\useMPgraphic{vanderwaerden0}} {(b)} {\useMPgraphic{vanderwaerden1}} {(c)} {\useMPgraphic{vanderwaerden01}} {(d)} {\useMPgraphic{vanderwaerden2}} {(e)} {\useMPgraphic{vanderwaerden012}} {(f)} {\useMPgraphic{vanderwaerden3}} {(g)} {\useMPgraphic{vanderwaerden0123}}{(h)} \stopcombination \stopplacefigure \stoptext ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context webpage : https://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : https://contextgarden.net ___
[NTG-context] MP figure continuation
Dear list, Is there a way to "continue" an MP figure? Like keeping the axes, etc. and just adding code to the figure? Maybe I missed something, otherwise I'd find it super useful. Thanks in advance and happy new year, Alex ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context webpage : https://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : https://contextgarden.net ___