ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* MP figure continuation
@ 2023-01-06 14:43 Alexandre Christe via ntg-context
  2023-01-06 14:53 ` Mikael Sundqvist via ntg-context
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Alexandre Christe via ntg-context @ 2023-01-06 14:43 UTC (permalink / raw)
  To: mailing list for ConTeXt users; +Cc: Alexandre Christe


[-- Attachment #1.1: Type: text/plain, Size: 226 bytes --]

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

[-- Attachment #1.2: Type: text/html, Size: 345 bytes --]

[-- Attachment #2: Type: text/plain, Size: 496 bytes --]

___________________________________________________________________________________
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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: MP figure continuation
  2023-01-06 14:43 MP figure continuation Alexandre Christe via ntg-context
@ 2023-01-06 14:53 ` Mikael Sundqvist via ntg-context
  2023-01-06 14:58 ` Gavin via ntg-context
  2023-01-07  2:35 ` Alan Braslau via ntg-context
  2 siblings, 0 replies; 5+ messages in thread
From: Mikael Sundqvist via ntg-context @ 2023-01-06 14:53 UTC (permalink / raw)
  To: mailing list for ConTeXt users; +Cc: Mikael Sundqvist

On Fri, Jan 6, 2023 at 3:43 PM Alexandre Christe via ntg-context
<ntg-context@ntg.nl> 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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: MP figure continuation
  2023-01-06 14:43 MP figure continuation Alexandre Christe via ntg-context
  2023-01-06 14:53 ` Mikael Sundqvist via ntg-context
@ 2023-01-06 14:58 ` Gavin via ntg-context
  2023-01-06 15:02   ` Alexandre Christe via ntg-context
  2023-01-07  2:35 ` Alan Braslau via ntg-context
  2 siblings, 1 reply; 5+ messages in thread
From: Gavin via ntg-context @ 2023-01-06 14:58 UTC (permalink / raw)
  To: mailing list for ConTeXt users; +Cc: Gavin

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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: MP figure continuation
  2023-01-06 14:58 ` Gavin via ntg-context
@ 2023-01-06 15:02   ` Alexandre Christe via ntg-context
  0 siblings, 0 replies; 5+ messages in thread
From: Alexandre Christe via ntg-context @ 2023-01-06 15:02 UTC (permalink / raw)
  To: Gavin; +Cc: Alexandre Christe, mailing list for ConTeXt users


[-- Attachment #1.1: Type: text/plain, Size: 564 bytes --]

Aye, thanks Mikael and Gavin. Hard 2023 re-start...

Le ven. 6 janv. 2023 à 15:58, Gavin <gavinpublic@comcast.net> 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

[-- Attachment #1.2: Type: text/html, Size: 1026 bytes --]

[-- Attachment #2: Type: text/plain, Size: 496 bytes --]

___________________________________________________________________________________
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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: MP figure continuation
  2023-01-06 14:43 MP figure continuation Alexandre Christe via ntg-context
  2023-01-06 14:53 ` Mikael Sundqvist via ntg-context
  2023-01-06 14:58 ` Gavin via ntg-context
@ 2023-01-07  2:35 ` Alan Braslau via ntg-context
  2 siblings, 0 replies; 5+ messages in thread
From: Alan Braslau via ntg-context @ 2023-01-07  2:35 UTC (permalink / raw)
  To: Alexandre Christe via ntg-context; +Cc: Alan Braslau

On Fri, 6 Jan 2023 15:43:07 +0100
Alexandre Christe via ntg-context <ntg-context@ntg.nl> 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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-01-07  2:35 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-06 14:43 MP figure continuation Alexandre Christe via ntg-context
2023-01-06 14:53 ` Mikael Sundqvist via ntg-context
2023-01-06 14:58 ` Gavin via ntg-context
2023-01-06 15:02   ` Alexandre Christe via ntg-context
2023-01-07  2:35 ` Alan Braslau via ntg-context

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).