Saving Metafun Graphic for use outside ConTeXt
Dear Readers, I have been playing about with METAFUN over the last few days trying to get a feel for it. I was wondering if it is possible to save the graphics produced in a context document for use outside. On looking at the Metapost manual I see you can using the following commands save a graphic as an svg file. /outputformat := "svg"; / /outputtemplate := "test.svg";/ // I have tried adding this to some MPcode in a ConteXt document but these lines seem to be ignored since no svg file is produced apart from the usual ConTeXt files. Is this expected behaviour? I have been able to get svg files using mpost on the command line. Here is a minimum working example (which I'm sure could be coded more elegantly): /\starttext/ // /\startMPcode/ // /outputformat := "svg";/ // /outputtemplate := "test.svg";/ // /beginfig(1)/ // /randomseed:= uniformdeviate infinity;/ // /path pat;/ // /x:=uniformdeviate(5);/ // /y:=uniformdeviate(5);/ // /pat:=(x,y);/ // /for i = 1 upto 5:/ // /a:=uniformdeviate(5);/ // /b:=uniformdeviate(5);/ // /pat := pat...(a,b);/ // /endfor;/ // /pat:=pat..(0,5);/ // /draw pat scaled 10pt;/ // /picture pic;/ // /pic:=currentpicture;/ // /endfig;/ // /\stopMPcode/ // /\stoptext/ Best Wishes Keith //
On 4/5/2018 1:10 PM, Keith McKay wrote:
Dear Readers,
I have been playing about with METAFUN over the last few days trying to get a feel for it. I was wondering if it is possible to save the graphics produced in a context document for use outside. On looking at the Metapost manual I see you can using the following commands save a graphic as an svg file.
forget about producing svg this way ... (1) it would not work with fonts, and (2) mplib in luatex has svg and png output disabled. % file: mpsvg.tex \startMPpage draw textext("Does it work?") ; draw boundingbox currentpicture enlarged 2mm withcolor "darkred" ; \stopMPpage % process context mpsvg mutool convert -o mpsvg.svg mpsvg.pdf Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------
Thanks Hans for the advice. I use a mac-mini and it seems that mupdf, of which mutools is part off, does not have a macOS version, or I would have to build from source. However it looks like I can use Inkscape with a wee bit thought to do pretty much the same. Thanks again for your help. Keith On 05/04/2018 13:39, Hans Hagen wrote:
On 4/5/2018 1:10 PM, Keith McKay wrote:
Dear Readers,
I have been playing about with METAFUN over the last few days trying to get a feel for it. I was wondering if it is possible to save the graphics produced in a context document for use outside. On looking at the Metapost manual I see you can using the following commands save a graphic as an svg file.
forget about producing svg this way ... (1) it would not work with fonts, and (2) mplib in luatex has svg and png output disabled.
% file: mpsvg.tex
\startMPpage
draw textext("Does it work?") ;
draw boundingbox currentpicture enlarged 2mm withcolor "darkred" ;
\stopMPpage
% process
context mpsvg
mutool convert -o mpsvg.svg mpsvg.pdf
Hans
----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------
On Thu, 5 Apr 2018 15:28:34 +0100
Keith McKay
I use a mac-mini and it seems that mupdf, of which mutools is part off, does not have a macOS version, or I would have to build from source. However it looks like I can use Inkscape with a wee bit thought to do pretty much the same.
mupdf is available on MacPorts... Alan
On 05/04/2018 18:24, Alan Braslau wrote:
On Thu, 5 Apr 2018 15:28:34 +0100 Keith McKay
wrote: I use a mac-mini and it seems that mupdf, of which mutools is part off, does not have a macOS version, or I would have to build from source. However it looks like I can use Inkscape with a wee bit thought to do pretty much the same.
mupdf is available on MacPorts...
...also in Homebrew (mupdf formula, or mupdf-tools if you don't need the viewer). Nicola
Thanks Nicola and Alan. I'll look into that. Best Wishes Keith On 05/04/2018 17:42, Nicola wrote:
On 05/04/2018 18:24, Alan Braslau wrote:
On Thu, 5 Apr 2018 15:28:34 +0100 Keith McKay
wrote: I use a mac-mini and it seems that mupdf, of which mutools is part off, does not have a macOS version, or I would have to build from source. However it looks like I can use Inkscape with a wee bit thought to do pretty much the same.
mupdf is available on MacPorts...
...also in Homebrew (mupdf formula, or mupdf-tools if you don't need the viewer).
Nicola
___________________________________________________________________________________
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://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___________________________________________________________________________________
Maybe this script could help a bit too. Use with following code scheme in ConTeXt: \starttex t\startMPpage % Your Metapost/metafun code here \stopMPpage \stoptext It will produce a standalone image in a pdf. dr. Hans van der Meer
On 5 Apr 2018, at 18:45, Keith McKay
wrote: Thanks Nicola and Alan. I'll look into that.
Best Wishes
Keith
On 05/04/2018 17:42, Nicola wrote:
On 05/04/2018 18:24, Alan Braslau wrote:
On Thu, 5 Apr 2018 15:28:34 +0100 Keith McKay
mailto:mckaymeister@gmail.com wrote: I use a mac-mini and it seems that mupdf, of which mutools is part off, does not have a macOS version, or I would have to build from source. However it looks like I can use Inkscape with a wee bit thought to do pretty much the same.
mupdf is available on MacPorts...
...also in Homebrew (mupdf formula, or mupdf-tools if you don't need the viewer).
Nicola
___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl mailto:ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl http://www.pragma-ade.nl/ / http://context.aanhet.net http://context.aanhet.net/ archive : https://bitbucket.org/phg/context-mirror/commits/ https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net http://contextgarden.net/ ___________________________________________________________________________________
___________________________________________________________________________________ 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://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___________________________________________________________________________________
Thanks dr. Hans! It certainly will. Best Wishes Keith On 05/04/2018 19:55, dr. Hans van der Meer wrote:
Maybe this script could help a bit too.
Use with following code scheme in ConTeXt:
\starttex t\startMPpage % Your Metapost/metafun code here \stopMPpage \stoptext
It will produce a standalone image in a pdf.
dr. Hans van der Meer
On 5 Apr 2018, at 18:45, Keith McKay
mailto:mckaymeister@gmail.com> wrote: Thanks Nicola and Alan. I'll look into that.
Best Wishes
Keith
On 05/04/2018 17:42, Nicola wrote:
On 05/04/2018 18:24, Alan Braslau wrote:
On Thu, 5 Apr 2018 15:28:34 +0100 Keith McKay
wrote: I use a mac-mini and it seems that mupdf, of which mutools is part off, does not have a macOS version, or I would have to build from source. However it looks like I can use Inkscape with a wee bit thought to do pretty much the same.
mupdf is available on MacPorts...
...also in Homebrew (mupdf formula, or mupdf-tools if you don't need the viewer).
Nicola
___________________________________________________________________________________
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://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___________________________________________________________________________________
___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl mailto:ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___________________________________________________________________________________
___________________________________________________________________________________ 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://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net ___________________________________________________________________________________
participants (5)
-
Alan Braslau
-
dr. Hans van der Meer
-
Hans Hagen
-
Keith McKay
-
Nicola