[NTG-context] Re: Status of Asymptote

2024-01-10 Thread shivshankar . dayal
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
___
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
___


[NTG-context] Re: Status of Asymptote

2024-01-03 Thread Jeroen
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
___

___
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
___


[NTG-context] Re: Status of Asymptote

2023-12-30 Thread 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
___


[NTG-context] Re: Status of Asymptote

2023-12-30 Thread Hans Hagen

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
-

___
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
___


[NTG-context] Re: Status of Asymptote

2023-12-30 Thread Alan Braslau via ntg-context

On 30/12/23 30/12/23, 12:04, Shiv Shankar Dayal wrote:


It would be nice to either support Metapost 3D


Very simple MP pseudo 3D is included in
tex/texmf-context/metapost/context/base/mpiv/mp-tres.mpiv

Alan
___
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
___


[NTG-context] Re: Status of Asymptote

2023-12-30 Thread Gavin via ntg-context
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
___
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
___


[NTG-context] Re: Status of Asymptote

2023-12-30 Thread Shiv Shankar Dayal

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

___
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
___