[NTG-context] Saving Metafun Graphic for use outside ConTeXt

Keith McKay mckaymeister at gmail.com
Thu Apr 5 13:10:49 CEST 2018


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

//

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ntg.nl/pipermail/ntg-context/attachments/20180405/363f4a58/attachment.html>


More information about the ntg-context mailing list