Dear all, I'd like to know what is the status of Asymptote in Context. To my knowledge, metapost/metafun only support 2D (except with the additional libraries from Roegel, which would have to be cleaned up a bit). Otherwise, what shall be used for 3D drawings in Context? TikZ? Something else? Thanks in advance. Alex
Hi Alex, I don’t know the status of Asymptote. I am using TikZ and pgfplots for 3D, with satisfactory results (example below). However, it is slow, so use the buffer mechanism to prevent redrawing with every run. TIkZ/pgfplots is the best short term solution for diagrams I need right now. I am concerned that TikZ will eventually not work with ConTeXt, so for a long term solution I am trying to make diagrams with Metapost, using Lua to do the heavy computational work. This is not easy, but the diagrams are super fast, and I think they will always work. Hope that helps. Gavin
On Dec 6, 2021, at 1:43 AM, Alexandre Christe via ntg-context
wrote: Dear all,
I'd like to know what is the status of Asymptote in Context. To my knowledge, metapost/metafun only support 2D (except with the additional libraries from Roegel, which would have to be cleaned up a bit).
Otherwise, what shall be used for 3D drawings in Context? TikZ? Something else?
Thanks in advance.
Alex ___________________________________________________________________________________ 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 ___________________________________________________________________________________
Dear Gavin,
Le 6 déc. 2021 à 10:11, Gavin via ntg-context
a écrit : Hi Alex,
I don’t know the status of Asymptote. I am using TikZ and pgfplots for 3D, with satisfactory results (example below). However, it is slow, so use the buffer mechanism to prevent redrawing with every run.
TIkZ/pgfplots is the best short term solution for diagrams I need right now. I am concerned that TikZ will eventually not work with ConTeXt, so for a long term solution I am trying to make diagrams with Metapost, using Lua to do the heavy computational work. This is not easy, but the diagrams are super fast, and I think they will always work.
I would be very interested to see an example of a Metafun drawing made with the help of LuaTeX to speed up some calculations. Thanks !
Hope that helps. Gavin
Fabrice.
On Mon, 6 Dec 2021, Alexandre Christe via ntg-context wrote:
Dear all,
I'd like to know what is the status of Asymptote in Context. To my knowledge, metapost/metafun only support 2D (except with the additional libraries from Roegel, which would have to be cleaned up a bit).
Depends on the kind of support you want. It is relatively easy to define an environment \startasymptote .... \stopasymptote such that the content of the environment is processed by asympotote and read back as an image (using the filter module). With some effort, it is also possible to pass variables from context to asymptote. The reverse communication is more complicated but not really needed for 3D drawing. Aditya
On Mon, 6 Dec 2021, Alexandre Christe via ntg-context wrote:
Dear all,
I'd like to know what is the status of Asymptote in Context. To my knowledge, metapost/metafun only support 2D (except with the additional libraries from Roegel, which would have to be cleaned up a bit).
Depends on the kind of support you want. It is relatively easy to define an environment
\startasymptote .... \stopasymptote
such that the content of the environment is processed by asympotote and read back as an image (using the filter module). With some effort, it is also possible to pass variables from context to asymptote. The reverse communication is more complicated but not really needed for 3D drawing.
On 12/7/2021 7:29 AM, Aditya Mahajan via ntg-context wrote: there is a module m-asymptote but i admit i sort of gave up on it: getting a stable bin can be a problem, the way text is handled is very latexish (and the context part too hard coded) so we're talking 'more dependencies that i find reasonable' here (i want to look into 3d mp at some point but first some other things) 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 -----------------------------------------------------------------
Hi all, It would be nice to either support Metapost 3D or Asymptote. Right now I generate images separately and embed them in PDF using externalfigure command which works but I have to maintain all the graphics separately. Respect, Shiv
Hi Shiv and Fabrice,
On Dec 30, 2023, Shiv Shankar Dayal wrote: It would be nice to either support Metapost 3D or Asymptote.
On Dec 6, 2021, Fabrice L wrote: I would be very interested to see an example of a Metafun drawing made with the help of LuaTeX to speed up some calculations.
I made a module that draws 3D globes with MetaPost and Lua. This was my first step toward drawing general projections. If anyone would like to join this project, I’d love some help. The globes module is only about 300 lines of code, and most of the challenge was hiding paths and parts of paths that are on the back side of the globe. Anybody could get up to speed pretty quickly. (I am completely new to both MetaPost and Lua, so I tried to be very clear in my coding.) My goal is a drawing process which starts with Lua tables containing data in arbitrary coordinates. The data could be any number of dimensions, and need not be rectangular. (For the globes the data is latitude and longitude points on the countries' boundaries.) The tables could be from an outside source (like the geographic data) or it could be calculated in Lua (for graphing functions or doing simulations). Lua does all of the calculations to project this data down to two dimensional, rectangular coordinates. Lua then passes these two dimensional points, or paths made from them, to MetaPost. MetaPost uses the points and paths to draw dots, curves and areas, to place labels, etc. The only transformation performed by MetaPost is the final scaling for drawing everything on the page. You can find the globe module on GitHub: https://github.com/GavinPolhemus/luageo I am relatively new to Git as well, so have patience if you start commenting or contributing there. I’ll learn fastest if there are collaborators! Gavin
On 12/30/2023 8:04 PM, Shiv Shankar Dayal wrote:
Hi all,
It would be nice to either support Metapost 3D or Asymptote. Right now I generate images separately and embed them in PDF using externalfigure command which works but I have to maintain all the graphics separately. next year we will pick up 3 (2.5, projections) in mp (either native or in macros) ... there will be no support for asymptote beyond what we have now
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 Sun, 31 Dec 2023, Shiv Shankar Dayal wrote:
It would be nice to either support Metapost 3D or Asymptote. Right now I generate images separately and embed them in PDF using externalfigure command which works but I have to maintain all the graphics separately.
It is possible to obtain simple integration for asymptote using the filter module: https://github.com/adityam/filter Using that you could define an asymptote environment so that: \startbuffer[asymptote-preamble] .... \stopbuffer \starttext \startasymptote % Asymptote figure \stopasymptote \stoptext saves the content of the asymptote-preamble and the figure in a separate file, runs asymptote to generate a PDF figure and includes the figure. The results are cached so the asymptote is re-run only if the content of the figure environment changes. A drawback of this approach is that the labels are generated by asymptote. That means that the font, colors, and any macros needed for the figures need to be redefined at both context and asymptote end. Aditya
Below is how I have used Asymptote in the past with the Context filter module: download portable ghostsctipt create dir c:\context\ghostscript and install from https://portableapps.com/apps/utilities/ghostscript_portable download non-portable asymptote create dir c:\context\asymptote and install from http://asymptote.sourceforge.net/ create file c:\context\asy.bat with context ASYMPTOTE_GS=C:context/ghostscript/bin/gswin64.exe C:/context/asymptote/asy.exe %* test with: \usemodule[filter] \defineexternalfilter[ASY] [filter={/context/asy.bat -tex context -outformat pdf -outname \externalfilteroutputfile}, output=\externalfilterbasefile.pdf, cache=yes, readcommand=\ReadImage,] \define[1]\ReadImage{\externalfigure[#1]} \starttext Testing if we can include an asymptote image \startplacefigure[location={here}, title={An Asymptote figure}] \startASY size(10cm); import graph; real f(real x) {return sin(x);} draw(graph(f,-3,3,300),blue); \stopASY \stopplacefigure \stoptext OR alternatively: \usemodule[filter] \defineexternalfilter[ASY] [filter={/context/asy.bat -tex context -outformat pdf -outname \externalfilteroutputfile}, output=\externalfilterbasefile.pdf, cache=yes, readcommand=\ReadImage,] \define[1]\ReadImage{\externalfigure[#1]} \starttext Testing if we can include an asymptote image \startplacefigure[location={here}, title={An Asymptote figure}] \startASY unitsize(1cm); draw((-.1,0) -- (2,0), arrow=Arrow(TeXHead)); draw((0,-.1) -- (0,2), arrow=Arrow(TeXHead)); draw((0,0) .. (1,1) .. (2,sqrt(2))); \stopASY \stopplacefigure \stoptext Op 31/12/2023 om 00:33 schreef Aditya Mahajan:
On Sun, 31 Dec 2023, Shiv Shankar Dayal wrote:
It would be nice to either support Metapost 3D or Asymptote. Right now I generate images separately and embed them in PDF using externalfigure command which works but I have to maintain all the graphics separately. It is possible to obtain simple integration for asymptote using the filter module:
https://github.com/adityam/filter
Using that you could define an asymptote environment so that:
\startbuffer[asymptote-preamble] .... \stopbuffer
\starttext
\startasymptote % Asymptote figure \stopasymptote
\stoptext
saves the content of the asymptote-preamble and the figure in a separate file, runs asymptote to generate a PDF figure and includes the figure. The results are cached so the asymptote is re-run only if the content of the figure environment changes.
A drawback of this approach is that the labels are generated by asymptote. That means that the font, colors, and any macros needed for the figures need to be redefined at both context and 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 / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror) archive : https://github.com/contextgarden/context wiki : https://wiki.contextgarden.net ___________________________________________________________________________________
Thanks for all the help. I have decided to use Metapost as it is tightly integrated with Asymptote and I find it fun. -- Respect, Shiv Shankar Dayal
participants (10)
-
Aditya Mahajan
-
Alan Braslau
-
Alexandre Christe
-
Fabrice L
-
Gavin
-
Gavin
-
Hans Hagen
-
Jeroen
-
Shiv Shankar Dayal
-
shivshankar.dayal@gmail.com