Skip to content

Instantly share code, notes, and snippets.

@dohyunkim
Created January 27, 2014 05:49
Show Gist options
  • Select an option

  • Save dohyunkim/8643793 to your computer and use it in GitHub Desktop.

Select an option

Save dohyunkim/8643793 to your computer and use it in GitHub Desktop.
sharing metapost variables between mplibcode environments: a proof of concept
\documentclass{article}
\usepackage{luamplib}
\everymplib{
if (readfrom "mymplibtmp.mp" <> EOF):
input mymplibtmp;
fi;
closefrom "mymplibtmp.mp";
if unknown u: u := 10; fi;
beginfig(0);
}
\everyendmplib{
endfig;
write "u := " & decimal u &";" to "mymplibtmp.mp";
write EOF to "mymplibtmp.mp";
}
\begin{document}
\raggedright\leavevmode
\newcount\n \n=0
\loop \ifnum\n<50 \advance\n by 1
\begin{mplibcode}
draw fullcircle scaled u;
%randomseed := u; u := uniformdeviate 50;
u := 1.25u;
if u > 50: u := 2 fi;
\end{mplibcode}
\repeat
\end{document}
@dohyunkim
Copy link
Author

out of date due to recent update of luamplib.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment