ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Status of Asymptote
@ 2021-12-06  8:43 Alexandre Christe via ntg-context
  2021-12-06 15:11 ` Gavin via ntg-context
  2021-12-07  6:29 ` Aditya Mahajan via ntg-context
  0 siblings, 2 replies; 12+ messages in thread
From: Alexandre Christe via ntg-context @ 2021-12-06  8:43 UTC (permalink / raw)
  To: ntg-context; +Cc: Alexandre Christe


[-- Attachment #1.1: Type: text/plain, Size: 322 bytes --]

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

[-- Attachment #1.2: Type: text/html, Size: 448 bytes --]

[-- Attachment #2: Type: text/plain, Size: 493 bytes --]

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

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Status of Asymptote
  2021-12-06  8:43 Status of Asymptote Alexandre Christe via ntg-context
@ 2021-12-06 15:11 ` Gavin via ntg-context
  2021-12-06 17:33   ` Fabrice L via ntg-context
  2021-12-07  6:29 ` Aditya Mahajan via ntg-context
  1 sibling, 1 reply; 12+ messages in thread
From: Gavin via ntg-context @ 2021-12-06 15:11 UTC (permalink / raw)
  To: mailing list for ConTeXt users; +Cc: Gavin

[-- Attachment #1: Type: text/plain, Size: 600 bytes --]

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



[-- Attachment #2: chapter07-t-b-1970d2b3267b0f295617c8a8d3f078eb.pdf --]
[-- Type: application/pdf, Size: 17229 bytes --]

[-- Attachment #3: Type: text/plain, Size: 971 bytes --]




> On Dec 6, 2021, at 1:43 AM, Alexandre Christe via ntg-context <ntg-context@ntg.nl> 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
> ___________________________________________________________________________________


[-- Attachment #4: Type: text/plain, Size: 493 bytes --]

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

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Status of Asymptote
  2021-12-06 15:11 ` Gavin via ntg-context
@ 2021-12-06 17:33   ` Fabrice L via ntg-context
  0 siblings, 0 replies; 12+ messages in thread
From: Fabrice L via ntg-context @ 2021-12-06 17:33 UTC (permalink / raw)
  To: mailing list for ConTeXt users; +Cc: Fabrice L

Dear Gavin,

> Le 6 déc. 2021 à 10:11, Gavin via ntg-context <ntg-context@ntg.nl> 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.


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

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Status of Asymptote
  2021-12-06  8:43 Status of Asymptote Alexandre Christe via ntg-context
  2021-12-06 15:11 ` Gavin via ntg-context
@ 2021-12-07  6:29 ` Aditya Mahajan via ntg-context
  2021-12-07  8:42   ` Hans Hagen via ntg-context
  1 sibling, 1 reply; 12+ messages in thread
From: Aditya Mahajan via ntg-context @ 2021-12-07  6:29 UTC (permalink / raw)
  To: Alexandre Christe via ntg-context; +Cc: Aditya Mahajan

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

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Status of Asymptote
  2021-12-07  6:29 ` Aditya Mahajan via ntg-context
@ 2021-12-07  8:42   ` Hans Hagen via ntg-context
  2023-12-30 19:04     ` [NTG-context] " Shiv Shankar Dayal
  0 siblings, 1 reply; 12+ messages in thread
From: Hans Hagen via ntg-context @ 2021-12-07  8:42 UTC (permalink / raw)
  To: mailing list for ConTeXt users; +Cc: Hans Hagen

On 12/7/2021 7:29 AM, Aditya Mahajan via ntg-context wrote:
> 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.
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
-----------------------------------------------------------------
___________________________________________________________________________________
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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [NTG-context] Re: Status of Asymptote
  2021-12-07  8:42   ` Hans Hagen via ntg-context
@ 2023-12-30 19:04     ` Shiv Shankar Dayal
  2023-12-30 20:33       ` Gavin via ntg-context
                         ` (3 more replies)
  0 siblings, 4 replies; 12+ messages in thread
From: Shiv Shankar Dayal @ 2023-12-30 19:04 UTC (permalink / raw)
  To: ntg-context

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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [NTG-context] Re: Status of Asymptote
  2023-12-30 19:04     ` [NTG-context] " Shiv Shankar Dayal
@ 2023-12-30 20:33       ` Gavin via ntg-context
  2023-12-30 20:44       ` Alan Braslau via ntg-context
                         ` (2 subsequent siblings)
  3 siblings, 0 replies; 12+ messages in thread
From: Gavin via ntg-context @ 2023-12-30 20:33 UTC (permalink / raw)
  To: mailing list for ConTeXt users; +Cc: shivshankar.dayal, Gavin

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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [NTG-context] Re: Status of Asymptote
  2023-12-30 19:04     ` [NTG-context] " Shiv Shankar Dayal
  2023-12-30 20:33       ` Gavin via ntg-context
@ 2023-12-30 20:44       ` Alan Braslau via ntg-context
  2023-12-30 21:48       ` Hans Hagen
  2023-12-30 23:33       ` Aditya Mahajan
  3 siblings, 0 replies; 12+ messages in thread
From: Alan Braslau via ntg-context @ 2023-12-30 20:44 UTC (permalink / raw)
  To: mailing list for ConTeXt users, Shiv Shankar Dayal; +Cc: Alan Braslau

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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [NTG-context] Re: Status of Asymptote
  2023-12-30 19:04     ` [NTG-context] " Shiv Shankar Dayal
  2023-12-30 20:33       ` Gavin via ntg-context
  2023-12-30 20:44       ` Alan Braslau via ntg-context
@ 2023-12-30 21:48       ` Hans Hagen
  2023-12-30 23:33       ` Aditya Mahajan
  3 siblings, 0 replies; 12+ messages in thread
From: Hans Hagen @ 2023-12-30 21:48 UTC (permalink / raw)
  To: ntg-context

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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [NTG-context] Re: Status of Asymptote
  2023-12-30 19:04     ` [NTG-context] " Shiv Shankar Dayal
                         ` (2 preceding siblings ...)
  2023-12-30 21:48       ` Hans Hagen
@ 2023-12-30 23:33       ` Aditya Mahajan
  2024-01-03 11:39         ` Jeroen
  3 siblings, 1 reply; 12+ messages in thread
From: Aditya Mahajan @ 2023-12-30 23:33 UTC (permalink / raw)
  To: mailing list for ConTeXt users

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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [NTG-context] Re: Status of Asymptote
  2023-12-30 23:33       ` Aditya Mahajan
@ 2024-01-03 11:39         ` Jeroen
  2024-01-11  6:00           ` shivshankar.dayal
  0 siblings, 1 reply; 12+ messages in thread
From: Jeroen @ 2024-01-03 11:39 UTC (permalink / raw)
  To: ntg-context

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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [NTG-context] Re: Status of Asymptote
  2024-01-03 11:39         ` Jeroen
@ 2024-01-11  6:00           ` shivshankar.dayal
  0 siblings, 0 replies; 12+ messages in thread
From: shivshankar.dayal @ 2024-01-11  6:00 UTC (permalink / raw)
  To: ntg-context

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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2024-01-11  6:04 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-06  8:43 Status of Asymptote Alexandre Christe via ntg-context
2021-12-06 15:11 ` Gavin via ntg-context
2021-12-06 17:33   ` Fabrice L via ntg-context
2021-12-07  6:29 ` Aditya Mahajan via ntg-context
2021-12-07  8:42   ` Hans Hagen via ntg-context
2023-12-30 19:04     ` [NTG-context] " Shiv Shankar Dayal
2023-12-30 20:33       ` Gavin via ntg-context
2023-12-30 20:44       ` Alan Braslau via ntg-context
2023-12-30 21:48       ` Hans Hagen
2023-12-30 23:33       ` Aditya Mahajan
2024-01-03 11:39         ` Jeroen
2024-01-11  6:00           ` shivshankar.dayal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).