Thanx Aditya
very much for your Metapost example. This I certainly sufficient for the production of simple images for my ideas. I attach source code, which outlines how I imagined inserting Asymptote images into Context. In the lower part of commented code is fully functional, compiled ConTEXt of TeX Live 2016 (included in the package is also Asymptote). My idea is that Asymptote code is part of my ConTeXt macro and parameters of macro are passed into Asymptote. My example does not work because Asymptote is probably not enough linked with Context. I am very grateful that You would to deal with my problem.
I am not sure whether it will do Asymptote example as in the case Metapost. That's why I use filter in my own example (taken from https://mailman.ntg.nl/pipermail/ntg-context/2015/080581.html ).
Thank you once again.
Jaroslav Hajtmar
\usemodule[filter]
\defineexternalfilter
[ASY]
[
filter={asy -tex "context" -outformat pdf
-outname \externalfilteroutputfile},
output=\externalfilterbasefile.pdf,
cache=yes,
readcommand=\ReadImage,
]
\define[1]\ReadImage{\externalfigure[#1]}
\define[1]\mycircle{
\startASY
import graph;
draw(Circle((0,0),#1));
\stopASY
}
\starttext
\mycircle{20}
\mycircle{30}
\mycircle{40}
\stoptext
%% simple asymptote example (compiled ConTeXt (LuaTeX) from TeX Live 2016)
%
%\usemodule[filter]
%
%\defineexternalfilter
% [ASY]
% [
% filter={asy -tex "context" -outformat pdf
% -outname \externalfilteroutputfile},
% output=\externalfilterbasefile.pdf,
% cache=yes,
% readcommand=\ReadImage,
% ]
%
%\define[1]\ReadImage{\externalfigure[#1]}
%
%\starttext
%\startASY
%import graph;
%draw(Circle((0,0),20));
%\stopASY
%\stoptext
Dne 19.12.16 17:19, ntg-context za uživatele Aditya Mahajan napsal(a):
On Mon, 19 Dec 2016, Jaroslav Hajtmar wrote:
> There is a similar possibility, at least in Metapost? For simpler
> pictures it would probably suffice ....
The ability to pass parameters to metapost has been around since the
beginning. See the metafun manual for details (search for MPvar). For
simple images, you can also do:
\define[1]\Circle{\startMPcode draw fullcircle scaled #1*cm; \stopMPcode}
\Circle{1} \Circle{2} \Circle{3}
> Is there a way to pass the ConTeXt parameter which influenced the
> creation of the Asymptote image? My point eg. the ability to define
> macros, which gave its parameters to Asymptote procedure or function and
> depending on these parameters, the image created by Asymptote looked
> differently.
In principle, something similar to \MPvar can work for asymptote as well
(or one could do parse the content in Lua rather than expand variables in
TeX).
> Before starting work on an illustrative example I am asking, whether it
> makes sense to deal with such a thing ... I suppose the impossibility of
> combining asymptote code and such Lua code (or not?).
ConTeXt and Metapost are very well integrated, even in MkII. The same
ideas could work with other graphic backends as well (Asymptote, tikz, and
others). But it does require a good knowledge of the graphics package.
I am willing to write the code at the context end, if someone who knows
asymptote can tell me what needs to be done at the asymptote end.
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://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : http://contextgarden.net
___________________________________________________________________________________