Re: [NTG-context] Using MPgraphics as externalfigures?

2012-08-03 Thread Mari Voipio
Hi Marco  al,

On Thu, Aug 2, 2012 at 11:34 AM, Marco Patzer home...@lavabit.com wrote:
 Read http://wiki.contextgarden.net/Metapost

I was on http://wiki.contextgarden.net/Mpgraphic which I actually
found for informative, but not quite enough for my very dummy level.


 and 3.3 Integrated Graphics in the MetaFun Manual.

*This* was my missing link (and I was being pretty stupid). I dug the
book out of my pile of ConTeXt papers and found exactly what I needed,
at the end of chapter 3.3, pages 115-117 in my paper copy.


To  answer to myself (in case somebody else ever looks for this);

At least in theory the key to the problem is to create a file
somefile.mp, then write the MP code in the file

beginfig{01}
   .
   .
   .
endfig ;
end .


The whole file is used by

\startMPrun
   input somefile ;
\stopMPrun

and the individual figure is available in the virtual file mprun.01.
Thus it can be included with
\externalfigure[mprun.01][width=0.5\textwidth] %etcetera


Page 117 even has an example of exactly the type of combination I'm
trying to achieve, so now it's just down to creating the graphic(s)
file(s). As my braiding graphics come in groups (steps and variations,
to be exact), this solution looks like a winner for now.


 \defineframed
   [graphicframe]
   [frame=on,offset=none]

 \define[1]\MPframed
   {\graphicframe{\useMPgraphic{#1}}}

 \startuseMPgraphic{first}
   fill fullcircle scaled 2cm withcolor red;
 \stopuseMPgraphic

 \startreusableMPgraphic{second}
   fill fullsquare rotated 45 scaled 2cm withcolor blue;
 \stopreusableMPgraphic

 \startbuffer [third]
   fill fullsquare scaled 1cm withcolor green;
 \stopbuffer

 \starttext
   \useMPgraphic{first}
   \reuseMPgraphic{second}
   \processMPbuffer [third]
   \MPframed{second}
 \stoptext


Thank you! I'll have to delve into this bit once the current
almost-past-deadline project is done, looks like this'll take a bit of
processing before it starts to make sense to me (my computer has no
such problems...).


Now, time for some recoding, thanks once more!

Mari
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


Re: [NTG-context] Using MPgraphics as externalfigures?

2012-08-03 Thread Aditya Mahajan

On Thu, 2 Aug 2012, Mari Voipio wrote:


Hi All,

I'm being a bit clueless about the MPgraphics again...

I've got a pile of instructional graphics that will be used and reused
in a project. My first try is/was an unwieldy buffer construction, but
I'm sure there's a better way than

\placefigure[here]
[fig: 5 loop departed setup]
{The start position for a 5-loop braid with departed loops}
{\framed{\getbuffer[setup 5-loop basic]}}


Come to think of it, is there another way of framing the incoming
graphic? I don't want to include the frames in the MPcode as I may not
always want them, but that \framed{\getbuffer} construction is
downright ugly.


(Untested code, but this should work)

\startbuffer[figure 1]
  draw fullcircle scaled 1cm;
\stopbuffer

\startbuffer[frame]
  draw (bbox currentpicture) withcolor blue;
\stopbuffer

\processMPbuffer[figure 1, frame]

Basically, you can concatinate various buffers in \processMPbuffer.

Aditya
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


Re: [NTG-context] Using MPgraphics as externalfigures?

2012-08-02 Thread Marco Patzer
On 2012-08-02 Mari Voipio mari.voi...@iki.fi wrote:

Hi Mari,

 I'm being a bit clueless about the MPgraphics again...

Read http://wiki.contextgarden.net/Metapost and 3.3 Integrated
Graphics in the MetaFun Manual.

 Any ideas of how to do this in a smart way? Preferably without having
 to go into the bowels of ConTeXt to get it done...

\defineframed
  [graphicframe]
  [frame=on,offset=none]

\define[1]\MPframed
  {\graphicframe{\useMPgraphic{#1}}}

\startuseMPgraphic{first}
  fill fullcircle scaled 2cm withcolor red;
\stopuseMPgraphic

\startreusableMPgraphic{second}
  fill fullsquare rotated 45 scaled 2cm withcolor blue;
\stopreusableMPgraphic

\startbuffer [third]
  fill fullsquare scaled 1cm withcolor green;
\stopbuffer

\starttext
  \useMPgraphic{first}
  \reuseMPgraphic{second}
  \processMPbuffer [third]
  \MPframed{second}
\stoptext


Marco

___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


[NTG-context] Using MPgraphics as externalfigures?

2012-08-01 Thread Mari Voipio
Hi All,

I'm being a bit clueless about the MPgraphics again...

I've got a pile of instructional graphics that will be used and reused
in a project. My first try is/was an unwieldy buffer construction, but
I'm sure there's a better way than

\placefigure[here]
[fig: 5 loop departed setup]
{The start position for a 5-loop braid with departed loops}
{\framed{\getbuffer[setup 5-loop basic]}}


Come to think of it, is there another way of framing the incoming
graphic? I don't want to include the frames in the MPcode as I may not
always want them, but that \framed{\getbuffer} construction is
downright ugly.


I think the solution to my problem can be found somewhere in the
\startreuseagleMPgraphic and \reuseMPgraphic, but I don't seem to be
able to figure out the last bits...


On the moment my MPgraphics have

\startbuffer[g1]
\startMPcode
...
\stopMPcode
\stopbuffer

but that's probably an overkill... And I'd really prefer to have the
graphic as just a pic so I can easily use them as external figures.


Of course one option would be to pdf the MPgraphics and then to insert
the pdf, but I'd prefer to skip that step.


Any ideas of how to do this in a smart way? Preferably without having
to go into the bowels of ConTeXt to get it done...


Thank you,

Mari
___
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___