ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Using MPgraphics as externalfigures?
@ 2012-08-02  3:56 Mari Voipio
  2012-08-02  8:34 ` Marco Patzer
  2012-08-03 21:28 ` Aditya Mahajan
  0 siblings, 2 replies; 4+ messages in thread
From: Mari Voipio @ 2012-08-02  3:56 UTC (permalink / raw)
  To: mailing list for ConTeXt users

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
___________________________________________________________________________________


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

* Re: Using MPgraphics as externalfigures?
  2012-08-02  3:56 Using MPgraphics as externalfigures? Mari Voipio
@ 2012-08-02  8:34 ` Marco Patzer
  2012-08-03 19:45   ` Mari Voipio
  2012-08-03 21:28 ` Aditya Mahajan
  1 sibling, 1 reply; 4+ messages in thread
From: Marco Patzer @ 2012-08-02  8:34 UTC (permalink / raw)
  To: ntg-context

On 2012-08-02 Mari Voipio <mari.voipio@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
___________________________________________________________________________________


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

* Re: Using MPgraphics as externalfigures?
  2012-08-02  8:34 ` Marco Patzer
@ 2012-08-03 19:45   ` Mari Voipio
  0 siblings, 0 replies; 4+ messages in thread
From: Mari Voipio @ 2012-08-03 19:45 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Hi Marco & al,

On Thu, Aug 2, 2012 at 11:34 AM, Marco Patzer <homerow@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
___________________________________________________________________________________


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

* Re: Using MPgraphics as externalfigures?
  2012-08-02  3:56 Using MPgraphics as externalfigures? Mari Voipio
  2012-08-02  8:34 ` Marco Patzer
@ 2012-08-03 21:28 ` Aditya Mahajan
  1 sibling, 0 replies; 4+ messages in thread
From: Aditya Mahajan @ 2012-08-03 21:28 UTC (permalink / raw)
  To: mailing list for ConTeXt users

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
___________________________________________________________________________________


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

end of thread, other threads:[~2012-08-03 21:28 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-08-02  3:56 Using MPgraphics as externalfigures? Mari Voipio
2012-08-02  8:34 ` Marco Patzer
2012-08-03 19:45   ` Mari Voipio
2012-08-03 21:28 ` Aditya Mahajan

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).